summaryrefslogtreecommitdiff
path: root/server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php
diff options
context:
space:
mode:
authormanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
committermanzerbredes <loic.guegan_secondary@yahoo.fr>2016-03-15 16:17:39 +0100
commit26d10bc0fa4befbac54453228ae1ce89021bdec2 (patch)
tree029d7240ecf7416205e5f76cf9107a6b5bdf8ca3 /server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php
parent8ad216dedf017f3d6de047a25d08db3b98e16361 (diff)
parent03ef74d0cfe675a6e18a91f039182ca1b248d8f5 (diff)
Merge branch 'develop' into loic
Diffstat (limited to 'server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php')
-rw-r--r--server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php b/server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php
new file mode 100644
index 0000000..f5d1fdb
--- /dev/null
+++ b/server/vendor/php-opencloud/common/tests/unit/Common/ArrayAccessTraitTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace OpenCloud\Test\Common;
+
+use OpenCloud\Common\ArrayAccessTrait;
+use OpenCloud\Test\TestCase;
+
+class ArrayAccessTraitTest extends TestCase
+{
+ private $aa;
+
+ public function setUp()
+ {
+ $this->aa = new ArrayAccess();
+ }
+
+ public function test_offset_is_set()
+ {
+ $this->aa->offsetSet('foo', 'bar');
+ $this->assertEquals(['foo' => 'bar'], $this->aa->getElements());
+ }
+
+ public function test_it_appends_if_no_key_is_set()
+ {
+ $this->aa->offsetSet(null, 'bar');
+ $this->assertEquals(['bar'], $this->aa->getElements());
+ }
+
+ public function test_if_checks_if_offset_exists()
+ {
+ $this->aa->offsetSet('bar', 'foo');
+ $this->assertTrue($this->aa->offsetExists('bar'));
+ $this->assertFalse($this->aa->offsetExists('baz'));
+ }
+
+ public function test_if_gets_offset()
+ {
+ $this->aa->offsetSet('bar', 'foo');
+ $this->assertEquals('foo', $this->aa->offsetGet('bar'));
+ $this->assertNull($this->aa->offsetGet('baz'));
+ }
+
+ public function test_it_unsets_offset()
+ {
+ $this->aa->offsetSet('bar', 'foo');
+ $this->aa->offsetUnset('bar');
+ $this->assertNull($this->aa->offsetGet('bar'));
+ }
+}
+
+class ArrayAccess
+{
+ use ArrayAccessTrait;
+
+ public function getElements()
+ {
+ return $this->internalState;
+ }
+}