Skip to content

Commit

Permalink
split test into multiple sub-scenarios involving `PersistentCollectio…
Browse files Browse the repository at this point in the history
…n` key checking #6110
  • Loading branch information
Ocramius committed Nov 26, 2016
1 parent 3dadfa4 commit 1486c8f
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions tests/Doctrine/Tests/ORM/PersistentCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Doctrine\Tests\ORM;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\DriverMock;
Expand Down Expand Up @@ -85,9 +84,9 @@ public function testNextInitializesCollection()
}

/**
* Test that PersistentCollection::clear() clear elements, and reset keys
* @group 6110
*/
public function testClear()
public function testRemovingElementsAlsoRemovesKeys()
{
$this->setUpPersistentCollection();

Expand All @@ -96,12 +95,27 @@ public function testClear()

$this->collection->removeElement('dummy');
$this->assertEquals([], array_keys($this->collection->toArray()));
}

/**
* @group 6110
*/
public function testClearWillAlsoClearKeys()
{
$this->setUpPersistentCollection();

$this->collection->add('dummy');
$this->collection->clear();
$this->assertEquals([], array_keys($this->collection->toArray()));
}

/**
* @group 6110
*/
public function testClearWillAlsoResetKeyPositions()
{
$this->setUpPersistentCollection();

// test fix clear doesn't reset collection keys when collection is empty
$this->collection->add('dummy');
$this->collection->removeElement('dummy');
$this->collection->clear();
Expand Down

0 comments on commit 1486c8f

Please sign in to comment.