Skip to content

Commit

Permalink
Merge pull request #93 from kwiateusz/UnitTestsUpdate
Browse files Browse the repository at this point in the history
Last change from assertTrue($a instanceof $b) to assertInstanceOf
  • Loading branch information
guilhermeblanco committed Aug 15, 2011
2 parents 2ee3cde + a47af43 commit b9a24b5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 59 deletions.
110 changes: 55 additions & 55 deletions tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
}

/**
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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]);
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]);
}

/**
Expand Down Expand Up @@ -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));
}

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -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']);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Doctrine/Tests/ORM/Mapping/ClassMetadataTest.php
Expand Up @@ -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')),
Expand Down
Expand Up @@ -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']);
Expand All @@ -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']);
Expand All @@ -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']);

Expand Down

0 comments on commit b9a24b5

Please sign in to comment.