]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/intl/Symfony/Component/Intl/Tests/ResourceBundle/Util/RingBufferTest.php
d6f7d8a076cc8927e2664b241f13acb7e743f368
[github/wallabag/wallabag.git] / vendor / symfony / intl / Symfony / Component / Intl / Tests / ResourceBundle / Util / RingBufferTest.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Intl\Tests\ResourceBundle\Util;
13
14 use Symfony\Component\Intl\ResourceBundle\Util\RingBuffer;
15
16 /**
17 * @author Bernhard Schussek <bschussek@gmail.com>
18 */
19 class RingBufferTest extends \PHPUnit_Framework_TestCase
20 {
21 /**
22 * @var RingBuffer
23 */
24 private $buffer;
25
26 protected function setUp()
27 {
28 $this->buffer = new RingBuffer(2);
29 }
30
31 public function testWriteWithinBuffer()
32 {
33 $this->buffer[0] = 'foo';
34 $this->buffer['bar'] = 'baz';
35
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']);
40 }
41
42 public function testWritePastBuffer()
43 {
44 $this->buffer[0] = 'foo';
45 $this->buffer['bar'] = 'baz';
46 $this->buffer[2] = 'bam';
47
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]);
52 }
53
54 /**
55 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
56 */
57 public function testReadNonExistingFails()
58 {
59 $this->buffer['foo'];
60 }
61
62 public function testQueryNonExisting()
63 {
64 $this->assertFalse(isset($this->buffer['foo']));
65 }
66
67 public function testUnsetNonExistingSucceeds()
68 {
69 unset($this->buffer['foo']);
70
71 $this->assertFalse(isset($this->buffer['foo']));
72 }
73
74 /**
75 * @expectedException \Symfony\Component\Intl\Exception\OutOfBoundsException
76 */
77 public function testReadOverwrittenFails()
78 {
79 $this->buffer[0] = 'foo';
80 $this->buffer['bar'] = 'baz';
81 $this->buffer[2] = 'bam';
82
83 $this->buffer[0];
84 }
85
86 public function testQueryOverwritten()
87 {
88 $this->assertFalse(isset($this->buffer[0]));
89 }
90
91 public function testUnsetOverwrittenSucceeds()
92 {
93 $this->buffer[0] = 'foo';
94 $this->buffer['bar'] = 'baz';
95 $this->buffer[2] = 'bam';
96
97 unset($this->buffer[0]);
98
99 $this->assertFalse(isset($this->buffer[0]));
100 }
101 }