From a47af43bc1006178c65ba41052e4aa2b2099fa50 Mon Sep 17 00:00:00 2001 From: kwiateusz Date: Wed, 27 Jul 2011 08:54:06 +0200 Subject: [PATCH] Last change from assertTrue($a instanceof $b) to assertInstanceOf --- .../ORM/Hydration/ObjectHydratorTest.php | 110 +++++++++--------- .../Tests/ORM/Mapping/ClassMetadataTest.php | 2 +- .../AbstractClassMetadataExporterTest.php | 6 +- 3 files changed, 59 insertions(+), 59 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php index ecd50f23726..f2673ac703d 100644 --- a/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php +++ b/tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php @@ -44,8 +44,8 @@ public function testSimpleEntityQuery() $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); $this->assertEquals(2, count($result)); - $this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\CMS\CmsUser); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); $this->assertEquals(1, $result[0]->id); $this->assertEquals('romanb', $result[0]->name); $this->assertEquals(2, $result[1]->id); @@ -116,10 +116,10 @@ public function testSimpleMultipleRootEntityQuery() $this->assertEquals(4, count($result)); - $this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[2] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[3] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[3]); $this->assertEquals(1, $result[0]->id); $this->assertEquals('romanb', $result[0]->name); @@ -173,7 +173,7 @@ public function testCreatesProxyForLazyLoadingWithForeignKeys() $result = $hydrator->hydrateAll($stmt, $rsm); $this->assertEquals(1, count($result)); - $this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\ECommerce\ECommerceProduct); + $this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $result[0]); } /** @@ -231,12 +231,12 @@ public function testMixedQueryFetchJoin() $this->assertTrue(is_array($result[0])); $this->assertTrue(is_array($result[1])); - $this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers); // first user => 2 phonenumbers $this->assertEquals(2, count($result[0][0]->phonenumbers)); @@ -293,8 +293,8 @@ public function testMixedQueryNormalJoin() $this->assertEquals(2, $result[0]['numPhones']); // second user => 1 phonenumber $this->assertEquals(1, $result[1]['numPhones']); - $this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); } /** @@ -359,9 +359,9 @@ public function testMixedQueryFetchJoinCustomIndex() $this->assertEquals('ROMANB', $result[0]['nameUpper']); $this->assertEquals('JWAGE', $result[1]['nameUpper']); - $this->assertTrue($result[0]['1'] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1]['2'] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[0]['1']->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]['1']); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]['2']); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0]['1']->phonenumbers); // first user => 2 phonenumbers. notice the custom indexing by user id $this->assertEquals(2, count($result[0]['1']->phonenumbers)); // second user => 1 phonenumber. notice the custom indexing by user id @@ -469,18 +469,18 @@ public function testMixedQueryMultipleFetchJoin() $this->assertTrue(is_array($result[0])); $this->assertTrue(is_array($result[1])); - $this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][0]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[1]); } /** @@ -604,29 +604,29 @@ public function testMixedQueryMultipleDeepMixedFetchJoin() $this->assertTrue(is_array($result[0])); $this->assertTrue(is_array($result[1])); - $this->assertTrue($result[0][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); - $this->assertTrue($result[1][0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); // phonenumbers - $this->assertTrue($result[0][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[0][0]->phonenumbers[1] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); - $this->assertTrue($result[1][0]->phonenumbers instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[1][0]->phonenumbers[0] instanceof \Doctrine\Tests\Models\CMS\CmsPhonenumber); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[0][0]->phonenumbers[1]); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->phonenumbers); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsPhonenumber', $result[1][0]->phonenumbers[0]); // articles - $this->assertTrue($result[0][0]->articles instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[0][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[1][0]->articles[0] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); - $this->assertTrue($result[1][0]->articles[1] instanceof \Doctrine\Tests\Models\CMS\CmsArticle); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[0][0]->articles[1]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsArticle', $result[1][0]->articles[1]); // article comments - $this->assertTrue($result[0][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection); - $this->assertTrue($result[0][0]->articles[0]->comments[0] instanceof \Doctrine\Tests\Models\CMS\CmsComment); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles[0]->comments); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsComment', $result[0][0]->articles[0]->comments[0]); // empty comment collections - $this->assertTrue($result[0][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[0][0]->articles[1]->comments); $this->assertEquals(0, count($result[0][0]->articles[1]->comments)); - $this->assertTrue($result[1][0]->articles[0]->comments instanceof \Doctrine\ORM\PersistentCollection); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->articles[0]->comments); $this->assertEquals(0, count($result[1][0]->articles[0]->comments)); - $this->assertTrue($result[1][0]->articles[1]->comments instanceof \Doctrine\ORM\PersistentCollection); + $this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $result[1][0]->articles[1]->comments); $this->assertEquals(0, count($result[1][0]->articles[1]->comments)); } @@ -706,8 +706,8 @@ public function testEntityQueryCustomResultSetOrder() $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); $this->assertEquals(2, count($result)); - $this->assertTrue($result[0] instanceof \Doctrine\Tests\Models\Forum\ForumCategory); - $this->assertTrue($result[1] instanceof \Doctrine\Tests\Models\Forum\ForumCategory); + $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\Forum\ForumCategory', $result[1]); $this->assertTrue($result[0] !== $result[1]); $this->assertEquals(1, $result[0]->getId()); $this->assertEquals(2, $result[1]->getId()); @@ -768,8 +768,8 @@ public function testChainedJoinWithEmptyCollections() $result = $hydrator->hydrateAll($stmt, $rsm, array(Query::HINT_FORCE_PARTIAL_LOAD => true)); $this->assertEquals(2, count($result)); - $this->assertTrue($result[0] instanceof CmsUser); - $this->assertTrue($result[1] instanceof CmsUser); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1]); $this->assertEquals(0, $result[0]->articles->count()); $this->assertEquals(0, $result[1]->articles->count()); } @@ -826,19 +826,19 @@ public function testChainedJoinWithEmptyCollections() $this->assertEquals(3, count($result)); - $this->assertTrue($result[0][0] instanceof CmsUser); // User object + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0][0]); // User object $this->assertEquals(1, $result[0]['id']); $this->assertEquals('The First', $result[0]['topic']); $this->assertEquals(1, $result[0]['cid']); $this->assertEquals('First Comment', $result[0]['ctopic']); - $this->assertTrue($result[1][0] instanceof CmsUser); // Same User object + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[1][0]); // Same User object $this->assertEquals(1, $result[1]['id']); // duplicated $this->assertEquals('The First', $result[1]['topic']); // duplicated $this->assertEquals(2, $result[1]['cid']); $this->assertEquals('Second Comment', $result[1]['ctopic']); - $this->assertTrue($result[2][0] instanceof CmsUser); // Same User object + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[2][0]); // Same User object $this->assertEquals(42, $result[2]['id']); $this->assertEquals('The Answer', $result[2]['topic']); $this->assertNull($result[2]['cid']); @@ -877,7 +877,7 @@ public function testResultIteration() $rowNum = 0; while (($row = $iterableResult->next()) !== false) { $this->assertEquals(1, count($row)); - $this->assertTrue($row[0] instanceof \Doctrine\Tests\Models\CMS\CmsUser); + $this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $row[0]); if ($rowNum == 0) { $this->assertEquals(1, $row[0]->id); $this->assertEquals('romanb', $row[0]->name); diff --git a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php index 7f7d3d6cf99..7868fb2fb8c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php @@ -105,7 +105,7 @@ public function testMapManyToManyJoinTableDefaults() )); $assoc = $cm->associationMappings['groups']; - //$this->assertTrue($assoc instanceof \Doctrine\ORM\Mapping\ManyToManyMapping); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $assoc); $this->assertEquals(array( 'name' => 'cmsuser_cmsgroup', 'joinColumns' => array(array('name' => 'cmsuser_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE')), diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index 11b3d113d1e..0dfbcc2f3f0 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -212,7 +212,7 @@ public function testFieldsAreExpored($class) public function testOneToOneAssociationsAreExported($class) { $this->assertTrue(isset($class->associationMappings['address'])); - //$this->assertTrue($class->associationMappings['address'] instanceof \Doctrine\ORM\Mapping\OneToOneMapping); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToOneMapping', $class->associationMappings['address']); $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Address', $class->associationMappings['address']['targetEntity']); $this->assertEquals('address_id', $class->associationMappings['address']['joinColumns'][0]['name']); $this->assertEquals('id', $class->associationMappings['address']['joinColumns'][0]['referencedColumnName']); @@ -234,7 +234,7 @@ public function testOneToOneAssociationsAreExported($class) public function testOneToManyAssociationsAreExported($class) { $this->assertTrue(isset($class->associationMappings['phonenumbers'])); - //$this->assertTrue($class->associationMappings['phonenumbers'] instanceof \Doctrine\ORM\Mapping\OneToManyMapping); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\OneToManyMapping', $class->associationMappings['phonenumbers']); $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Phonenumber', $class->associationMappings['phonenumbers']['targetEntity']); $this->assertEquals('user', $class->associationMappings['phonenumbers']['mappedBy']); $this->assertEquals(array('number' => 'ASC'), $class->associationMappings['phonenumbers']['orderBy']); @@ -255,7 +255,7 @@ public function testOneToManyAssociationsAreExported($class) public function testManyToManyAssociationsAreExported($class) { $this->assertTrue(isset($class->associationMappings['groups'])); - //$this->assertTrue($class->associationMappings['groups'] instanceof \Doctrine\ORM\Mapping\ManyToManyMapping); + //$this->assertInstanceOf('Doctrine\ORM\Mapping\ManyToManyMapping', $class->associationMappings['groups']); $this->assertEquals('Doctrine\Tests\ORM\Tools\Export\Group', $class->associationMappings['groups']['targetEntity']); $this->assertEquals('cms_users_groups', $class->associationMappings['groups']['joinTable']['name']);