Skip to content

Commit

Permalink
Few more converts from assertTrue($a instance of $b) to assertInstanceOf
Browse files Browse the repository at this point in the history
  • Loading branch information
kwiateusz committed Jul 26, 2011
1 parent 1ea3e54 commit 7261060
Show file tree
Hide file tree
Showing 21 changed files with 104 additions and 104 deletions.
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ORM/Functional/BasicFunctionalTest.php
Expand Up @@ -46,7 +46,7 @@ public function testBasicUnitsOfWorkWithOneToManyAssociation()
$this->_em->flush();
$this->assertTrue($this->_em->contains($ph));
$this->assertTrue($this->_em->contains($user));
//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
//$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers);

// Update name
$user->name = 'guilherme';
Expand Down Expand Up @@ -92,7 +92,7 @@ public function testOneToManyAssociationModification()
$this->_em->persist($user);
$this->_em->flush();

//$this->assertTrue($user->phonenumbers instanceof \Doctrine\ORM\PersistentCollection);
//$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $user->phonenumbers);

// Remove the first element from the collection
unset($user->phonenumbers[0]);
Expand Down
36 changes: 18 additions & 18 deletions tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php
Expand Up @@ -50,8 +50,8 @@ public function testCRUD()
$entities = $query->getResult();

$this->assertEquals(2, count($entities));
$this->assertTrue($entities[0] instanceof CompanyPerson);
$this->assertTrue($entities[1] instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $entities[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[1]);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertTrue(is_numeric($entities[1]->getId()));
$this->assertEquals('Roman S. Borschel', $entities[0]->getName());
Expand All @@ -65,15 +65,15 @@ public function testCRUD()
$entities = $query->getResult();

$this->assertEquals(1, count($entities));
$this->assertTrue($entities[0] instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $entities[0]);
$this->assertTrue(is_numeric($entities[0]->getId()));
$this->assertEquals('Guilherme Blanco', $entities[0]->getName());
$this->assertEquals(100000, $entities[0]->getSalary());

$this->_em->clear();

$guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco'));
$this->assertTrue($guilherme instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $guilherme);
$this->assertEquals('Guilherme Blanco', $guilherme->getName());

$this->_em->clear();
Expand Down Expand Up @@ -110,7 +110,7 @@ public function testMultiLevelUpdateAndFind() {

$manager = $this->_em->find('Doctrine\Tests\Models\Company\CompanyManager', $manager->getId());

$this->assertTrue($manager instanceof CompanyManager);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $manager);
$this->assertEquals('Roman B.', $manager->getName());
$this->assertEquals(119000, $manager->getSalary());
$this->assertEquals('CEO', $manager->getTitle());
Expand All @@ -130,12 +130,12 @@ public function testFindOnBaseClass() {

$person = $this->_em->find('Doctrine\Tests\Models\Company\CompanyPerson', $manager->getId());

$this->assertTrue($person instanceof CompanyManager);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyManager', $person);
$this->assertEquals('Roman S. Borschel', $person->getName());
$this->assertEquals(100000, $person->getSalary());
$this->assertEquals('CTO', $person->getTitle());
$this->assertTrue(is_numeric($person->getId()));
//$this->assertTrue($person->getCar() instanceof CompanyCar);
//$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyCar', $person->getCar());
}

public function testSelfReferencingOneToOne() {
Expand Down Expand Up @@ -167,9 +167,9 @@ public function testSelfReferencingOneToOne() {

$result = $query->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyPerson);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyPerson', $result[0]);
$this->assertEquals('Mary Smith', $result[0]->getName());
$this->assertTrue($result[0]->getSpouse() instanceof CompanyEmployee);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyEmployee', $result[0]->getSpouse());
$this->assertEquals('John Smith', $result[0]->getSpouse()->getName());
$this->assertSame($result[0], $result[0]->getSpouse()->getSpouse());
}
Expand Down Expand Up @@ -229,20 +229,20 @@ public function testLazyLoading1()
$result = $q->getResult();

$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyOrganization);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]);
$this->assertNull($result[0]->getMainEvent());

$events = $result[0]->getEvents();

$this->assertTrue($events instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $events);
$this->assertFalse($events->isInitialized());

$this->assertEquals(2, count($events));
if ($events[0] instanceof CompanyAuction) {
$this->assertTrue($events[1] instanceof CompanyRaffle);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[1]);
} else {
$this->assertTrue($events[0] instanceof CompanyRaffle);
$this->assertTrue($events[1] instanceof CompanyAuction);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyRaffle', $events[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $events[1]);
}
}

Expand All @@ -263,7 +263,7 @@ public function testLazyLoading2()

$result = $q->getResult();
$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyAuction, sprintf("Is of class %s",get_class($result[0])));
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $result[0], sprintf("Is of class %s",get_class($result[0])));

$this->_em->clear();

Expand All @@ -273,12 +273,12 @@ public function testLazyLoading2()
$result = $q->getResult();

$this->assertEquals(1, count($result));
$this->assertTrue($result[0] instanceof CompanyOrganization);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyOrganization', $result[0]);

$mainEvent = $result[0]->getMainEvent();
// mainEvent should have been loaded because it can't be lazy
$this->assertTrue($mainEvent instanceof CompanyAuction);
$this->assertFalse($mainEvent instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\Models\Company\CompanyAuction', $mainEvent);
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $mainEvent);
}

/**
Expand Down
Expand Up @@ -43,9 +43,9 @@ public function testOneToOneAssocToBaseTypeBidirectional()

$related2 = $this->_em->find('Doctrine\Tests\ORM\Functional\CTIRelated', $relatedId);

$this->assertTrue($related2 instanceof CTIRelated);
$this->assertTrue($related2->getCTIParent() instanceof CTIChild);
$this->assertFalse($related2->getCTIParent() instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIRelated', $related2);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $related2->getCTIParent());
$this->assertNotInstanceOf('Doctrine\ORM\Proxy\Proxy', $related2->getCTIParent());
$this->assertEquals('hello', $related2->getCTIParent()->getData());

$this->assertSame($related2, $related2->getCTIParent()->getRelated());
Expand All @@ -69,7 +69,7 @@ public function testManyToManyToCTIHierarchy()
$this->assertFalse($mmrel2->getCTIChildren()->isInitialized());
$this->assertEquals(1, count($mmrel2->getCTIChildren()));
$this->assertTrue($mmrel2->getCTIChildren()->isInitialized());
$this->assertTrue($mmrel2->getCTIChildren()->get(0) instanceof CTIChild);
$this->assertInstanceOf('Doctrine\Tests\ORM\Functional\CTIChild', $mmrel2->getCTIChildren()->get(0));
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/Doctrine/Tests/ORM/Functional/DetachedEntityTest.php
Expand Up @@ -137,14 +137,14 @@ public function testUninitializedLazyAssociationsAreIgnoredOnMerge()
$this->_em->clear();

$address2 = $this->_em->find(get_class($address), $address->id);
$this->assertTrue($address2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $address2->user);
$this->assertFalse($address2->user->__isInitialized__);
$detachedAddress2 = unserialize(serialize($address2));
$this->assertTrue($detachedAddress2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $detachedAddress2->user);
$this->assertFalse($detachedAddress2->user->__isInitialized__);

$managedAddress2 = $this->_em->merge($detachedAddress2);
$this->assertTrue($managedAddress2->user instanceof \Doctrine\ORM\Proxy\Proxy);
$this->assertInstanceOf('Doctrine\ORM\Proxy\Proxy', $managedAddress2->user);
$this->assertFalse($managedAddress2->user === $detachedAddress2->user);
$this->assertFalse($managedAddress2->user->__isInitialized__);
}
Expand Down
Expand Up @@ -47,7 +47,7 @@ public function testBasicManyToManyJoin()
$result = $query->getResult();

$this->assertEquals(2, $this->_em->getUnitOfWork()->size());
$this->assertTrue($result[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $result[0]);
$this->assertEquals('Guilherme', $result[0]->name);
$this->assertEquals(1, $result[0]->getGroups()->count());
$groups = $result[0]->getGroups();
Expand All @@ -56,8 +56,8 @@ public function testBasicManyToManyJoin()
$this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($result[0]));
$this->assertEquals(\Doctrine\ORM\UnitOfWork::STATE_MANAGED, $this->_em->getUnitOfWork()->getEntityState($groups[0]));

$this->assertTrue($groups instanceof \Doctrine\ORM\PersistentCollection);
$this->assertTrue($groups[0]->getUsers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $groups[0]->getUsers());

$groups[0]->getUsers()->clear();
$groups->clear();
Expand Down
Expand Up @@ -117,8 +117,8 @@ protected function _findCategories()
//$query->setHint(Query::HINT_FORCE_PARTIAL_LOAD, true);
$result = $query->getResult();
$this->assertEquals(2, count($result));
$this->assertTrue($result[0] instanceof ECommerceCategory);
$this->assertTrue($result[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $result[1]);
$prods1 = $result[0]->getProducts();
$prods2 = $result[1]->getProducts();
$this->assertTrue($prods1->isInitialized());
Expand Down Expand Up @@ -157,10 +157,10 @@ public function assertLazyLoadFromInverseSide($products)
$this->assertEquals(2, count($secondCategoryProducts)); // lazy-load
$this->assertTrue($secondCategoryProducts->isInitialized());

$this->assertTrue($firstCategoryProducts[0] instanceof ECommerceProduct);
$this->assertTrue($firstCategoryProducts[1] instanceof ECommerceProduct);
$this->assertTrue($secondCategoryProducts[0] instanceof ECommerceProduct);
$this->assertTrue($secondCategoryProducts[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstCategoryProducts[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondCategoryProducts[1]);

$this->assertCollectionEquals($firstCategoryProducts, $secondCategoryProducts);
}
Expand Down Expand Up @@ -192,10 +192,10 @@ public function assertLazyLoadFromOwningSide($categories)
$this->assertEquals(2, count($secondProductCategories)); // lazy-load
$this->assertTrue($secondProductCategories->isInitialized());

$this->assertTrue($firstProductCategories[0] instanceof ECommerceCategory);
$this->assertTrue($firstProductCategories[1] instanceof ECommerceCategory);
$this->assertTrue($secondProductCategories[0] instanceof ECommerceCategory);
$this->assertTrue($secondProductCategories[1] instanceof ECommerceCategory);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $firstProductCategories[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceCategory', $secondProductCategories[1]);

$this->assertCollectionEquals($firstProductCategories, $secondProductCategories);
}
Expand Down
Expand Up @@ -95,10 +95,10 @@ public function assertLoadingOfOwningSide($products)
$this->assertEquals(2, count($firstRelatedBy));
$this->assertEquals(2, count($secondRelatedBy));

$this->assertTrue($firstRelatedBy[0] instanceof ECommerceProduct);
$this->assertTrue($firstRelatedBy[1] instanceof ECommerceProduct);
$this->assertTrue($secondRelatedBy[0] instanceof ECommerceProduct);
$this->assertTrue($secondRelatedBy[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $firstRelatedBy[1]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $secondRelatedBy[1]);

$this->assertCollectionEquals($firstRelatedBy, $secondRelatedBy);
}
Expand Down
Expand Up @@ -69,8 +69,8 @@ public function testEagerLoad()
$products = $firstCart->getProducts();
$secondCart = $result[1];

$this->assertTrue($products[0] instanceof ECommerceProduct);
$this->assertTrue($products[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts());
//$this->assertEquals("Doctrine 1.x Manual", $products[0]->getName());
//$this->assertEquals("Doctrine 2.x Manual", $products[1]->getName());
Expand All @@ -88,8 +88,8 @@ public function testLazyLoadsCollection()
$products = $firstCart->getProducts();
$secondCart = $result[1];

$this->assertTrue($products[0] instanceof ECommerceProduct);
$this->assertTrue($products[1] instanceof ECommerceProduct);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[0]);
$this->assertInstanceOf('Doctrine\Tests\Models\ECommerce\ECommerceProduct', $products[1]);
$this->assertCollectionEquals($products, $secondCart->getProducts());
}

Expand Down
22 changes: 11 additions & 11 deletions tests/Doctrine/Tests/ORM/Functional/NativeQueryTest.php
Expand Up @@ -49,7 +49,7 @@ public function testBasicNativeQuery()
$users = $query->getResult();

$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
}

Expand Down Expand Up @@ -83,9 +83,9 @@ public function testJoinedOneToManyNativeQuery()

$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers();
Expand Down Expand Up @@ -132,11 +132,11 @@ public function testJoinedOneToOneNativeQuery()
$users = $query->getResult();

$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertTrue($users[0]->getAddress() instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
Expand Down Expand Up @@ -185,9 +185,9 @@ public function testJoinedOneToManyNativeQueryWithRSMBuilder()

$users = $query->getResult();
$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertTrue($users[0]->getPhonenumbers()->isInitialized());
$this->assertEquals(1, count($users[0]->getPhonenumbers()));
$phones = $users[0]->getPhonenumbers();
Expand Down Expand Up @@ -226,11 +226,11 @@ public function testJoinedOneToOneNativeQueryWithRSMBuilder()
$users = $query->getResult();

$this->assertEquals(1, count($users));
$this->assertTrue($users[0] instanceof CmsUser);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsUser', $users[0]);
$this->assertEquals('Roman', $users[0]->name);
$this->assertTrue($users[0]->getPhonenumbers() instanceof \Doctrine\ORM\PersistentCollection);
$this->assertInstanceOf('Doctrine\ORM\PersistentCollection', $users[0]->getPhonenumbers());
$this->assertFalse($users[0]->getPhonenumbers()->isInitialized());
$this->assertTrue($users[0]->getAddress() instanceof CmsAddress);
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsAddress', $users[0]->getAddress());
$this->assertTrue($users[0]->getAddress()->getUser() == $users[0]);
$this->assertEquals('germany', $users[0]->getAddress()->getCountry());
$this->assertEquals(10827, $users[0]->getAddress()->getZipCode());
Expand Down

0 comments on commit 7261060

Please sign in to comment.