示例#1
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);
 }
示例#2
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);
 }
 /**
  * @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);
 }
示例#4
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);
 }
 /**
  * @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);
 }
 /**
  * @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);
 }