Commits

Arkadiusz Dzięgiel  committed 4b2efa5

fixed single inheritance issue (#2)

  • Participants
  • Parent commits 24ad180
  • Tags v1.2.2

Comments (0)

Files changed (5)

File Behaviors/ExtendBehavior.php

 	
 	public function queryFilter(&$script){
 		//until https://github.com/propelorm/Propel/pull/592 is not merged into propel
-		$script = preg_replace('/(protected function findPkSimple\(\$key, \$con\).*?)\$obj = new ([^(]+)[\(\)]{2}/s','$1\$cls = $2Peer::getOMClass();'."\n\t\t\t".'\$obj = new \$cls', $script);
+		$script = preg_replace('/(protected function findPkSimple\(\$key, \$con\).*?)\$obj = new ([^$][^(]+)[\(\)]{2}/s','$1\$cls = $2Peer::getOMClass();'."\n\t\t\t".'\$obj = new \$cls', $script);
 		//return correct isntance in query::create
 		$script = preg_replace('/(static function create\(.*?\$query = new )([^\(]+)/s','$1static', $script);
 	}

File Tests/Fixtures/Model/ExtendedSiThing.php

+<?php
+namespace Glorpen\Propel\PropelBundle\Tests\Fixtures\Model;
+
+class ExtendedSiThing extends SiThing {
+}

File Tests/Fixtures/Model/SiThing.php

+<?php
+namespace Glorpen\Propel\PropelBundle\Tests\Fixtures\Model;
+
+use Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\om\BaseSiThing;
+
+class SiThing extends BaseSiThing {
+	
+}

File Tests/PropelExtendingTest.php

 
 use Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\BookPeer;
 
+use Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\SiThingQuery;
+
+use Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\SiThing;
+
 /**
  * @author Arkadiusz Dzięgiel
  */
 class PropelExtendingTest extends PropelTestCase {
 	
-	public function setUp()
-	{
+	protected function setUp(){
 		self::$map = array(
 			self::$modelClass => self::$extendedClass,
-			'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\TrianglePerson' => 'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\ExtendedTrianglePerson'
+			'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\TrianglePerson' => 'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\ExtendedTrianglePerson',
+			'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\SiThing' => 'Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\ExtendedSiThing'
 		);
 		
 		$this->loadAndBuild();
 	}
 	
 	public function testService(){
+		
 		$org = 'OriginalClass';
 		$ext = 'ExtendedClass';
 		
 		}catch(\LogicException $e){
 		}
 	}
+	
+	//https://github.com/glorpen/GlorpenPropelBundle/issues/2
+	public function testSingleInheritance(){
+		
+		$this->setUpListener();
+		\Propel::disableInstancePooling();
+		
+		$p = new SiThing();
+		$p->save();
+		
+		$this->assertInstanceOf('Glorpen\Propel\PropelBundle\Tests\Fixtures\Model\ExtendedSiThing', SiThingQuery::create()->findPk($p->getPrimaryKey()));
+	}
 }

File Tests/PropelTestCase.php

 		<behavior name="event" />
 		<behavior name="extend" />
     </table>
+	<table name="si_thing">
+        <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
+        <column name="name" type="varchar" size="255" primaryString="true" />
+			
+		<column name="class_key" type="INTEGER" inheritance="single">
+			<inheritance key="1" class="SiThingA"/>
+			<inheritance key="2" class="SiThingB"/>
+		</column>
+			
+		<behavior name="event" />
+		<behavior name="extend" />
+    </table>
 </database>
 SCHEMA;