/** * Tests the offsets. * * @test * @uses \Bairwell\Hydrator\FailureList::__construct * @covers \Bairwell\Hydrator\FailureList::offsetGet * @covers \Bairwell\Hydrator\FailureList::offsetSet * @covers \Bairwell\Hydrator\FailureList::count * @covers \Bairwell\Hydrator\FailureList::offsetUnset * @covers \Bairwell\Hydrator\FailureList::offsetExists * @covers \Bairwell\Hydrator\FailureList::add */ public function testOffset() { $sut = new FailureList(); /* @var Failure $failure */ $failure = $this->getMockBuilder('\\Bairwell\\Hydrator\\Failure')->disableOriginalConstructor()->getMock(); $sut->add($failure); $this->assertEquals(1, $sut->count()); $this->assertTrue($sut->offsetExists(0)); $this->assertFalse($sut->offsetExists(23)); $this->assertSame($failure, $sut->offsetGet(0)); // now add it in a set position /* @var Failure $failure */ $failure2 = $this->getMockBuilder('\\Bairwell\\Hydrator\\Failure')->disableOriginalConstructor()->getMock(); $sut->offsetSet(23, $failure2); $this->assertEquals(2, $sut->count()); $this->assertTrue($sut->offsetExists(0)); $this->assertTrue($sut->offsetExists(23)); $this->assertSame($failure, $sut->offsetGet(0)); $this->assertSame($failure2, $sut->offsetGet(23)); // unset test $sut->offsetUnset(23); $this->assertEquals(1, $sut->count()); $this->assertTrue($sut->offsetExists(0)); $this->assertFalse($sut->offsetExists(23)); $this->assertSame($failure, $sut->offsetGet(0)); }