/** * @test */ public function shouldBeAbleToSetAndGet() { $this->setUp(); $this->collection->set('id', 2); $this->assertEquals(2, $this->collection['id']); $object = new \stdClass(); $object->id = 1; $hash = spl_object_hash($object); $this->collection->set(null, $object); $this->assertEquals($object, $this->collection->get($hash)); $this->assertEquals(3, count($this->collection)); $retrievedObject = $this->collection->get($object); $this->assertEquals($object, $retrievedObject); $this->collection->remove($object); $this->assertEquals(2, count($this->collection)); $keys = $this->collection->getKeys(); $this->assertEquals(['id', 'name'], $keys); $this->assertEquals(true, $this->collection->hasKey('id')); $this->assertEquals('id', $this->collection->keySearch('id')); $this->assertEquals(false, $this->collection->keySearch('parent')); $this->collection->replace(['id' => 2]); $this->assertEquals(1, count($this->collection)); $this->assertEquals(2, $this->collection->get('id')); $this->collection->merge(['id' => 1]); $this->assertEquals([2, 1], $this->collection->get('id')); $this->setUp(); $this->assertEquals(['id' => 1, 'name' => 'Dave'], $this->collection->getAll()); $this->assertEquals(['name' => 'Dave'], $this->collection->getAll(['name'])); $this->collection->clear(); $this->assertEquals(0, count($this->collection)); }