From 4f5b44bd3bd490309eb2ba7b44df4769816ba729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 3 Aug 2013 19:26:54 +0200 Subject: twig implementation --- .../Tests/ResourceBundle/Util/RingBufferTest.php | 101 +++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php (limited to 'vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php') diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php new file mode 100644 index 00000000..d6f7d8a0 --- /dev/null +++ b/vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php @@ -0,0 +1,101 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Intl\Tests\ResourceBundle\Util; + +use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer; + +/** + * @author Bernhard Schussek + */ +class RingBufferTest extends \PHPUnit_Framework_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->assertTrue(isset($this->buffer[0])); + $this->assertTrue(isset($this->buffer['bar'])); + $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->assertTrue(isset($this->buffer['bar'])); + $this->assertTrue(isset($this->buffer[2])); + $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->assertFalse(isset($this->buffer['foo'])); + } + + public function testUnsetNonExistingSucceeds() + { + unset($this->buffer['foo']); + + $this->assertFalse(isset($this->buffer['foo'])); + } + + /** + * @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->assertFalse(isset($this->buffer[0])); + } + + public function testUnsetOverwrittenSucceeds() + { + $this->buffer[0] = 'foo'; + $this->buffer['bar'] = 'baz'; + $this->buffer[2] = 'bam'; + + unset($this->buffer[0]); + + $this->assertFalse(isset($this->buffer[0])); + } +} -- cgit v1.2.3