* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\Tests\Data\Util; use PHPUnit\Framework\TestCase; use Symfony\Component\Intl\Data\Util\RingBuffer; /** * @author Bernhard Schussek */ class RingBufferTest extends TestCase { /** * @var RingBuffer */ private $buffer; protected function setUp() { $this->buffer = new RingBuffer(2); } public function testWriteWithinBuffer() { $this->buffer[0] = 'foo'; $this->buffer['bar'] = 'baz'; $this->assertArrayHasKey(0, $this->buffer); $this->assertArrayHasKey('bar', $this->buffer); $this->assertSame('foo', $this->buffer[0]); $this->assertSame('baz', $this->buffer['bar']); } public function testWritePastBuffer() { $this->buffer[0] = 'foo'; $this->buffer['bar'] = 'baz'; $this->buffer[2] = 'bam'; $this->assertArrayHasKey('bar', $this->buffer); $this->assertArrayHasKey(2, $this->buffer); $this->assertSame('baz', $this->buffer['bar']); $this->assertSame('bam', $this->buffer[2]); } /** * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException */ public function testReadNonExistingFails() { $this->buffer['foo']; } public function testQueryNonExisting() { $this->assertArrayNotHasKey('foo', $this->buffer); } public function testUnsetNonExistingSucceeds() { unset($this->buffer['foo']); $this->assertArrayNotHasKey('foo', $this->buffer); } /** * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException */ public function testReadOverwrittenFails() { $this->buffer[0] = 'foo'; $this->buffer['bar'] = 'baz'; $this->buffer[2] = 'bam'; $this->buffer[0]; } public function testQueryOverwritten() { $this->assertArrayNotHasKey(0, $this->buffer); } public function testUnsetOverwrittenSucceeds() { $this->buffer[0] = 'foo'; $this->buffer['bar'] = 'baz'; $this->buffer[2] = 'bam'; unset($this->buffer[0]); $this->assertArrayNotHasKey(0, $this->buffer); } } __halt_compiler();----SIGNATURE:----tN2clyzhmX7uUV97wm+JtfTb4CqGJSb8FGO52WayHqTKnilYEtrr8J3IZVVOS/MDFilhx7pcG1MpXTS/5tag4xj4O9x7M2BmGk5w7q1+ye6I1OtLH7i+8uLXLWZnZMRckcLx1VyOEygTlQrjALSVQbLhjt8lc0CAZxM5h8IW85rcMKQ3KLQWb2UboL8Hx8CmjJpbvTGSuwL0FJw7VNY7XZj80bvGqpgn6SDc6PfEA6h6iaQ1I5WUZlpS0zZojJO2BQ89/F/5Wod54XXDbA8E2tEYWGAZbXC+cwgSihkpeGyqB1b8l75Jzk8BDONNhQWEfPMeelRwjzIa9kO0xE5A95KMb+VKi7/6+CiLWW6UkI1j4mS1QdQL+5Ld9fQBWLLJuwxjJ/NoQMtwZU4We+ivTc6bOAewcarFceyjY208rdd1yzaIE05a1ZXlOuG4ex16Sx/4P2MnhepMY1S0dkU90JaZpVUG0IDSt5fkJWGEXkRqSliDlA/K3Hf2mPy4+9lLXVb6Nce74te/uNPtZCv7J93neByqZ0vTy67CcHtsUvRPLR/WlVEGsUUa9UZd/1laVq4yKrIPNEwHJPDnaY09h47G77AT+zDwpAaJ976I9BQzMwOcyFbLS6O0TZuO6CiGNtgsxlA4CDyQHNAIHJXC3/w7nKjNK7tsctY5H2eIxks=----ATTACHMENT:----NTY1OTU5ODg3MjQ4ODggNDM0MjE3Mzg5ODIzODM0MCA4NjE4MjEwNDIyMjcxMDY3