4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\Tests\ResourceBundle\Util
;
14 use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer
;
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 class RingBufferTest
extends \PHPUnit_Framework_TestCase
26 protected function setUp()
28 $this->buffer
= new RingBuffer(2);
31 public function testWriteWithinBuffer()
33 $this->buffer
[0] = 'foo';
34 $this->buffer
['bar'] = 'baz';
36 $this->assertTrue(isset($this->buffer
[0]));
37 $this->assertTrue(isset($this->buffer
['bar']));
38 $this->assertSame('foo', $this->buffer
[0]);
39 $this->assertSame('baz', $this->buffer
['bar']);
42 public function testWritePastBuffer()
44 $this->buffer
[0] = 'foo';
45 $this->buffer
['bar'] = 'baz';
46 $this->buffer
[2] = 'bam';
48 $this->assertTrue(isset($this->buffer
['bar']));
49 $this->assertTrue(isset($this->buffer
[2]));
50 $this->assertSame('baz', $this->buffer
['bar']);
51 $this->assertSame('bam', $this->buffer
[2]);
55 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
57 public function testReadNonExistingFails()
62 public function testQueryNonExisting()
64 $this->assertFalse(isset($this->buffer
['foo']));
67 public function testUnsetNonExistingSucceeds()
69 unset($this->buffer
['foo']);
71 $this->assertFalse(isset($this->buffer
['foo']));
75 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
77 public function testReadOverwrittenFails()
79 $this->buffer
[0] = 'foo';
80 $this->buffer
['bar'] = 'baz';
81 $this->buffer
[2] = 'bam';
86 public function testQueryOverwritten()
88 $this->assertFalse(isset($this->buffer
[0]));
91 public function testUnsetOverwrittenSucceeds()
93 $this->buffer
[0] = 'foo';
94 $this->buffer
['bar'] = 'baz';
95 $this->buffer
[2] = 'bam';
97 unset($this->buffer
[0]);
99 $this->assertFalse(isset($this->buffer
[0]));