* * 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:----aF8ohOroB+3QTOPv6qKhXA+27F/5ooMabNbUONseDuX6h2VE8MssbD0dbFnrckbFghosxz1PrvtuhAhYF+WBq8xzM0emFZMCZwAiqMn7IrrYpHrc2spgiuLyJlF3472c7nbV5fmq77eAWjmCxddZb2iRR2Ug2qEJCZ0i/SF7rabp52r5Q8g6GJm9c12p8VsIgJ+uPj5bJU4rAFw+VRWwTbBwSPW7je9KOdvTyM65cLlXlhhc+cSc2poOBJGJmg+vuWFFgK89pvsIJK/SVFkSlKcglyDSNj5kKDQn+QJbrs523/nwKUlHnoe9UJaujUD1dhK2v1lEj2SxZiLoqmK+DOPR1rXa2OvSnYsumtEG4l+n9g8hV8QzVBlZHW+fZyNIypnt+5OMNPezPMO6YFuxGEzL7aznm7Vcl9ZZuDvPvpuKeNCTlzzUS3H9W9gEro3rLPLIzpsx8ULcbvqq9rHyr43pBWovC+wdwkaILIwk8IQX/Ox+QcfcbRGsi49BgY+eU4eNyaHYGHXyVBAQNwhsWs6hpN4MzHhjUMR0/OEf8uV3dHZH0pqLcCZwNNeioyEY8lH8EwDiPyPQTtGe1gC3EsW8WYSmgOCNvyD21WuldM4hGLSK8JEGt8zjSHk6rMcjLdqpMKvHMI0G77UbA52yndd5RXruREal8yOQDpceUfU=----ATTACHMENT:----NzE1MzI1Mjk5ODQ2NTAzNSA2MDI2MTEwMzU3ODgxMDIxIDcyMzgyNzE3NzE1Mzk3Mzg=