Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Merge b58bad2 into eac5fae
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed Mar 21, 2018
2 parents eac5fae + b58bad2 commit 4fa717d
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function testAddAttachment()

$user = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', 'user_with_attachment');

$this->assertEquals(2, count($user->attachments));
$this->assertCount(2, $user->attachments);
$this->assertArrayHasKey('logo.jpg', $user->attachments);
$this->assertInstanceOf('Doctrine\CouchDB\Attachment', $user->attachments['foo.txt']);
}
Expand Down Expand Up @@ -106,4 +106,4 @@ public function testAddRemoveAttachment()
$this->assertArrayHasKey('logo.jpg', $user->attachments);
$this->assertArrayNotHasKey('foo.txt', $user->attachments);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function testCascadePersistCollection()
$this->dm->clear();

$pUser = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id);
$this->assertEquals(2, count($pUser->groups));
$this->assertCount(2, $pUser->groups);
}

public function testCascadePersistForManagedEntity()
Expand Down Expand Up @@ -76,7 +76,7 @@ public function testCascadePersistForManagedEntity()
$this->dm->clear();

$pUser = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id);
$this->assertEquals(2, count($pUser->groups));
$this->assertCount(2, $pUser->groups);
}

public function testCascadePersistSingleDocument()
Expand Down Expand Up @@ -127,7 +127,7 @@ public function testCascadeManagedDocumentCollectionDuringFlush()
$this->dm->clear();

$pUser = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id);
$this->assertEquals(2, count($pUser->groups));
$this->assertCount(2, $pUser->groups);
}

public function testCascadeManagedDocumentReferenceDuringFlush()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testCascadeRefresh()

$this->dm->flush();

$this->assertEquals(1, count($user->groups));
$this->assertCount(1, $user->groups);

$group1->name = "Test2";
$user->username = "beberlei2";
Expand Down
14 changes: 7 additions & 7 deletions tests/Doctrine/Tests/ODM/CouchDB/Functional/EmbedManyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testFind()
{
$embedder = $this->dm->find($this->type, 1);
$this->assertInstanceOf($this->type, $embedder);
$this->assertEquals(2, count($embedder->embeds));
$this->assertCount(2, $embedder->embeds);
$this->assertEquals('embedded 1', $embedder->embeds[0]->name);
$this->assertEquals('embedded 2', $embedder->embeds[1]->name);
}
Expand All @@ -46,7 +46,7 @@ public function testShouldNotSaveUnchanged()
$embedder = $this->dm->find($this->type, 1);
$this->dm->flush();

$this->assertEquals(0, count($listener->eventArgs));
$this->assertCount(0, $listener->eventArgs);
}

public function testSave()
Expand All @@ -62,7 +62,7 @@ public function testSave()
$this->dm->clear();

$embedder = $this->dm->find($this->type, 1);
$this->assertEquals(3, count($embedder->embeds));
$this->assertCount(3, $embedder->embeds);
$this->assertEquals('new one', $embedder->embeds[2]->name);

$embedder->embeds[0]->name = 'changed';
Expand All @@ -72,10 +72,10 @@ public function testSave()
$this->dm->clear();

$embedder = $this->dm->find($this->type, 1);
$this->assertEquals(3, count($embedder->embeds));
$this->assertCount(3, $embedder->embeds);
$this->assertEquals('foo', $embedder->name);
$this->assertEquals('changed', $embedder->embeds[0]->name);
$this->assertEquals(1, count($embedder->embeds[0]->arrayField));
$this->assertCount(1, $embedder->embeds[0]->arrayField);
$this->assertEquals('bar', $embedder->embeds[0]->arrayField[0]);

}
Expand All @@ -100,7 +100,7 @@ public function testCreate()
$this->assertNull($newOne);
$newOne = $this->dm->find($this->type, 2);
$this->assertNotNull($newOne);
$this->assertEquals(2, count($newOne->embeds));
$this->assertCount(2, $newOne->embeds);
$this->assertEquals('newly embedded 1', $newOne->embeds[0]->name);
$this->assertEquals('newly embedded 2', $newOne->embeds[1]->name);
}
Expand All @@ -125,7 +125,7 @@ public function testAssocCreate()
$this->assertNull($newOne);
$newOne = $this->dm->find($this->type, 2);
$this->assertNotNull($newOne);
$this->assertEquals(2, count($newOne->embeds));
$this->assertCount(2, $newOne->embeds);
$this->assertEquals('newly embedded 1', $newOne->embeds['one']->name);
$this->assertEquals('newly embedded 2', $newOne->embeds['two']->name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function testFind()
$this->assertInstanceOf($this->embeddedType, $embedded);

$nesteds = $embedded->embeds;
$this->assertEquals(2, count($nesteds));
$this->assertCount(2, $nesteds);

$nested = $nesteds[0];
$this->assertInstanceOf($this->nestedType, $nested);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testShouldNotSaveUnchanged()

$this->dm->flush();

$this->assertEquals(0, count($listener->eventArgs));
$this->assertCount(0, $listener->eventArgs);
}

public function testSaveModifiedEmbedded()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testPersistInheritanceReferenceMany()

$parent = $dm->find(__NAMESPACE__ . '\\CODM25Parent', $parent->id);

$this->assertEquals(2, count($parent->childs));
$this->assertCount(2, $parent->childs);
$this->assertInstanceOf(__NAMESPACE__ . '\\CODM25ChildA', $parent->childs[0]);
$this->assertEquals('bar', $parent->childs[0]->foo);
$this->assertInstanceOf(__NAMESPACE__ . '\\CODM25ChildA', $parent->childs[1]);
Expand Down Expand Up @@ -91,7 +91,7 @@ public function testPersistInheritanceEmbedMany()

$parent = $dm->find(__NAMESPACE__ . '\\CODM25Parent', $parent->id);

$this->assertEquals(2, count($parent->embeds));
$this->assertCount(2, $parent->embeds);
$this->assertInstanceOf(__NAMESPACE__ . '\\CODM25ChildA', $parent->embeds[0]);
$this->assertEquals('bar', $parent->embeds[0]->foo);
$this->assertInstanceOf(__NAMESPACE__ . '\\CODM25ChildA', $parent->embeds[1]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testLuceneIndexing()
}
}

$this->assertEquals(1, count($result));
$this->assertCount(1, $result);
foreach ($result AS $user) {
$this->assertEquals($user2->id, $user['id']);
$this->assertEquals(1, $user['score']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testSaveManyToMany()
$user = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
$this->assertInstanceOf('Doctrine\ODM\CouchDB\PersistentCollection', $user->groups);
$this->assertFalse($user->groups->isInitialized);
$this->assertEquals(2, count($user->groups));
$this->assertCount(2, $user->groups);
$this->assertTrue($user->groups->isInitialized);

$group3 = new \Doctrine\Tests\Models\CMS\CmsGroup();
Expand All @@ -63,7 +63,7 @@ public function testSaveManyToMany()
$this->dm->clear();

$user = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $user->id);
$this->assertEquals(3, count($user->groups));
$this->assertCount(3, $user->groups);
}

public function testInverseManyToManyLazyLoad()
Expand All @@ -73,7 +73,7 @@ public function testInverseManyToManyLazyLoad()

$this->assertInstanceOf('Doctrine\ODM\CouchDB\PersistentCollection', $group->users);
$this->assertFalse($group->users->isInitialized);
$this->assertEquals(1, count($group->users));
$this->assertCount(1, $group->users);
$this->assertTrue($group->users->isInitialized);

$this->assertEquals('beberlei', $group->users[0]->getUsername());
Expand All @@ -89,7 +89,7 @@ public function testInverseManyToManyIdentityMap()

$this->assertInstanceOf('Doctrine\ODM\CouchDB\PersistentCollection', $group->users);
$this->assertFalse($group->users->isInitialized);
$this->assertEquals(1, count($group->users));
$this->assertCount(1, $group->users);
$this->assertTrue($group->users->isInitialized);

$this->assertSame($user, $group->users[0]);
Expand All @@ -99,7 +99,7 @@ public function testInverseManyToManySeveralEntries()
{
$group = $this->dm->find('Doctrine\Tests\Models\CMS\CmsGroup', $this->groupIds[1]);

$this->assertEquals(2, count($group->users));
$this->assertCount(2, $group->users);
$this->assertTrue($group->users->isInitialized);
}

Expand All @@ -116,7 +116,7 @@ public function testUpdateInverseSideIsIgnored()
$this->dm->clear();

$user = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userId);
$this->assertEquals(2, count($user->groups));
$this->assertCount(2, $user->groups);
}

public function testFlushingOwningSideWithAssocationChangesTwiceOnlySavesOnce()
Expand Down Expand Up @@ -158,7 +158,7 @@ public function testNoTargetDocument()
$this->dm->clear();

$node = $this->dm->find('Doctrine\Tests\Models\CMS\CmsNode', $node->id);
$this->assertEquals(4, count($node->references));
$this->assertCount(4, $node->references);
$classes = array();
foreach ($node->references AS $reference) {
$classes[] = get_class($reference);
Expand All @@ -183,10 +183,10 @@ public function testPersistKeys()
$this->dm->clear();

$node = $this->dm->find('Doctrine\Tests\Models\CMS\CmsNode', $node->id);
$this->assertEquals(2, count($node->references));
$this->assertCount(2, $node->references);

foreach ($this->groupIds AS $groupId) {
$this->assertTrue(isset($node->references[$groupId]), "References array should be indexed by group id, but key does not exist");
$this->assertArrayHasKey($groupId, $node->references, "References array should be indexed by group id, but key does not exist");
$this->assertInstanceOf('Doctrine\Tests\Models\CMS\CmsGroup', $node->references[$groupId]);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testTraverseInverseSide()

$this->assertInstanceOf('Doctrine\ODM\CouchDB\PersistentCollection', $user->articles);
$this->assertFalse($user->articles->isInitialized);
$this->assertEquals(2, count($user->articles));
$this->assertCount(2, $user->articles);

$this->assertContains($user->articles[0]->id, $this->articleIds);
$this->assertContains($user->articles[1]->id, $this->articleIds);
Expand All @@ -68,6 +68,6 @@ public function testInverseSideChangesAreIgnored()
$this->dm->clear();

$user = $this->dm->find('Doctrine\Tests\Models\CMS\CmsUser', $this->userIds[0]);
$this->assertEquals(2, count($user->articles));
$this->assertCount(2, $user->articles);
}
}
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/ODM/CouchDB/Functional/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public function testQuery()
->setKey('lsmith')
->execute();

$this->assertEquals(1, count($result));
$this->assertCount(1, $result);
$this->assertEquals('lsmith', $result[0]->username);

$result = $this->dm->createQuery('cms', 'username')
->onlyDocs(true)
->setKey('beberlei')
->execute();

$this->assertEquals(1, count($result));
$this->assertCount(1, $result);
$this->assertEquals('beberlei', $result[0]->username);
}
}
24 changes: 12 additions & 12 deletions tests/Doctrine/Tests/ODM/CouchDB/Functional/RepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ public function testFindMany()
$this->dm->flush();

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findMany(array($user1->id, $user2->id));
$this->assertEquals(2, count($users));
$this->assertCount(2, $users);
$this->assertSame($user1, $users[0]);
$this->assertSame($user2, $users[1]);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findMany(array($user1->id, $user2->id), 1, 0);
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
$this->assertSame($user1, $users[0]);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findMany(array($user1->id, $user2->id), 1, 1);
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
$this->assertSame($user2, $users[1]);

$this->dm->clear();
Expand Down Expand Up @@ -74,11 +74,11 @@ public function testFindAll()
$this->dm->flush();

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findAll();
$this->assertEquals(10, count($users));
$this->assertCount(10, $users);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $users);

$groups = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsGroup')->findAll();
$this->assertEquals(0, count($groups), "No results, group is not indexed!");
$this->assertCount(0, $groups, "No results, group is not indexed!");
}

public function testLoadManyWithMissingIds()
Expand All @@ -97,7 +97,7 @@ public function testLoadManyWithMissingIds()
$this->dm->clear();

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findMany(array($user1->id, 'missing-id-2'));
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
}

public function testFindBy()
Expand All @@ -114,22 +114,22 @@ public function testFindBy()

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => 'active'));

$this->assertEquals(5, count($users));
$this->assertCount(5, $users);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $users);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => 'active'), null, 2);
$this->assertEquals(2, count($users));
$this->assertCount(2, $users);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => 'inactive'));

$this->assertEquals(5, count($users));
$this->assertCount(5, $users);
$this->assertContainsOnly('Doctrine\Tests\Models\CMS\CmsUser', $users);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => 'active', 'username' => 'beberlei0'));
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('status' => 'active', 'name' => 'Benjamin'), null, 2);
$this->assertEquals(2, count($users));
$this->assertCount(2, $users);
}

public function testFindByManyConstraints()
Expand All @@ -145,7 +145,7 @@ public function testFindByManyConstraints()
$this->dm->flush();

$users = $this->dm->getRepository('Doctrine\Tests\Models\CMS\CmsUser')->findBy(array('username' => 'beberlei0'));
$this->assertEquals(1, count($users));
$this->assertCount(1, $users);
$this->assertEquals('beberlei0', $users[0]->username);
}

Expand Down

0 comments on commit 4fa717d

Please sign in to comment.