示例#1
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::toArray
  */
 public function testToArrayForSomeValues()
 {
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $result = $this->collection->toArray();
     $this->assertEquals(['A', 'B', 'C'], $result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::contains
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testContainsForContainValue()
 {
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $value = 'B';
     $this->dummyType->isValid($value)->willReturn(true);
     $result = $this->collection->contains($value);
     $this->assertTrue($result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::containsAll
  */
 public function testContainsAllWhenContainValue()
 {
     $someCollection = clone $this->collection;
     $someCollection->add('A');
     $someCollection->add('C');
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $result = $this->collection->containsAll($someCollection);
     $this->assertTrue($result);
 }
示例#4
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::equals
  */
 public function testEqualsForTheSameCollections()
 {
     $someCollection = clone $this->collection;
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $someCollection->add('A');
     $someCollection->add('B');
     $someCollection->add('C');
     $result = $this->collection->equals($someCollection);
     $this->assertTrue($result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::toArray
  */
 public function testToArrayForSomeValues()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $result = $this->collection->toArray();
     $this->assertEquals([$a, $b, $c], $result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::contains
  */
 public function testContainsForContainValue()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $this->dummyType->isValid($b)->willReturn(true);
     $result = $this->collection->contains($b);
     $this->assertTrue($result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::containsAll
  */
 public function testContainsAllWhenContainValue()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $someCollection = clone $this->collection;
     $someCollection->add($a);
     $someCollection->add($c);
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $result = $this->collection->containsAll($someCollection);
     $this->assertTrue($result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::equals
  * @covers       CollectionType\Common\Util\UtilTrait::diffArrays
  */
 public function testEqualsForTheSameCollections()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $someCollection = clone $this->collection;
     $this->collection->add($a);
     $this->collection->add($a);
     $this->collection->add($c);
     $someCollection->add($a);
     $someCollection->add($b);
     $someCollection->add($c);
     $result = $this->collection->equals($someCollection);
     $this->assertTrue($result);
 }
示例#9
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::remove
  * @covers       CollectionType\Collection\CollectionAbstract::contains
  * @covers       CollectionType\Common\ValueTypeTrait::validateValueForValueType
  */
 public function testRemoveForCheckingValuesAfterRemove()
 {
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $value = 'B';
     $this->dummyType->isValid($value)->willReturn(true);
     $this->collection->remove($value);
     $result = $this->collection->getAll();
     $this->assertEquals(['A', 'C'], $result);
 }
示例#10
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::getAll
  */
 public function testGetAllForFewValues()
 {
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $this->collection->add('D');
     $this->collection->add('E');
     $result = $this->collection->getAll();
     $this->assertEquals(['A', 'B', 'C', 'D', 'E'], $result);
 }
示例#11
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::removeAll
  */
 public function testRemoveAllWhenContainValueAfterRemove()
 {
     $value = 'A';
     $someCollection = clone $this->collection;
     $someCollection->add($value);
     $this->dummyType->isValid($value)->willReturn(true);
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $this->collection->removeAll($someCollection);
     $result = $this->collection->getAll();
     $this->assertEquals(['B', 'C'], $result);
 }
示例#12
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::clear
  * @covers       CollectionType\Collection\CollectionAbstract::getAll
  */
 public function testClear()
 {
     $this->collection->add('A');
     $this->collection->add('B');
     $this->collection->add('C');
     $this->collection->clear();
     $result = $this->collection->getAll();
     $this->assertEquals([], $result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::remove
  * @covers       CollectionType\Collection\CollectionAbstract::contains
  */
 public function testRemoveForCheckingValuesAfterRemove()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $this->dummyType->isValid($b)->willReturn(true);
     $this->collection->remove($b);
     $result = $this->collection->getAll();
     $this->assertEquals([$a, $c], $result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::removeAll
  */
 public function testRemoveAllWhenContainValueAfterRemove()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $someCollection = clone $this->collection;
     $someCollection->add($a);
     $this->dummyType->isValid($a)->willReturn(true);
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $this->collection->removeAll($someCollection);
     $result = $this->collection->getAll();
     $this->assertEquals([$b, $c], $result);
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::getDifference
  */
 public function testGetDifferenceWhenContainAllValues()
 {
     $valueA = 'A';
     $this->dummyType->isValid($valueA)->willReturn(true);
     $valueB = 'B';
     $this->dummyType->isValid($valueB)->willReturn(true);
     $valueC = 'C';
     $this->dummyType->isValid($valueC)->willReturn(true);
     $someCollection = clone $this->collection;
     $someCollection->add($valueA);
     $someCollection->add($valueB);
     $someCollection->add($valueC);
     $this->collection->add($valueA);
     $this->collection->add($valueB);
     $this->collection->add($valueC);
     $result = $this->collection->getDifference($someCollection);
     $this->assertEquals([], $result->getAll());
 }
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::getAll
  */
 public function testGetAllForFewValues()
 {
     $a = new \stdClass();
     $a->param = 'A';
     $b = new \stdClass();
     $b->param = 'B';
     $c = new \stdClass();
     $c->param = 'C';
     $d = new \stdClass();
     $d->param = 'D';
     $e = new \stdClass();
     $e->param = 'E';
     $this->collection->add($a);
     $this->collection->add($b);
     $this->collection->add($c);
     $this->collection->add($d);
     $this->collection->add($e);
     $result = $this->collection->getAll();
     $this->assertEquals([$a, $b, $c, $d, $e], $result);
 }
示例#17
0
 /**
  * @covers       CollectionType\Collection\CollectionAbstract::equalType
  */
 public function testEqualTypeForTheSameType()
 {
     $result = $this->collection->equalType($this->dummyType->reveal());
     $this->assertTrue($result);
 }