Example #1
0
 public function testInstance()
 {
     $this->generateInstance();
     $this->testInstance->expects($this->any())->method('getType')->will($this->returnValue(self::class));
     $this->testInstance->add(0, $this);
     $this->testInstance->offsetSet(0, $this);
     $this->testInstance->push($this);
     $this->testInstance->unshift($this);
     try {
         $this->testInstance->offsetSet(0, $this->testInstance);
     } catch (Exception $e) {
         $this->assertTrue($e instanceof InvalidArgumentException);
     }
 }
Example #2
0
 /**
  * @covers Basics\Collection\TypedList::offsetSet
  * @covers Basics\Collection\TypedList::offsetGet
  */
 public function testOffsetSetAndGetWorkProperly()
 {
     $this->expectSuccessiveCallsOnIsExpectedType(3, true);
     $item0 = $this->expectItem();
     $item1 = $this->expectItem();
     $item2 = $this->expectItem();
     $this->typedList->add($item0);
     $this->typedList->add($item1);
     $this->typedList->add($item2);
     $this->assertSame($item0, $this->typedList[0]);
     $this->assertSame($item1, $this->typedList[1]);
     $this->assertSame($item2, $this->typedList[2]);
     $item1a = $this->expectItem();
     $this->typedList[1] = $item1a;
     $this->assertSame($item1a, $this->typedList->offsetGet(1));
     $item3 = $this->expectItem();
     $this->typedList->offsetSet(3, $item3);
     $this->assertCount(4, $this->typedList);
     $this->assertSame($item3, $this->typedList->offsetGet(3));
 }