コード例 #1
0
 /**
  * Test applying a callback to each element of the collection
  *
  * @reutrn void
  */
 public function testEach()
 {
     $success = $this->collection->each(function ($value, $key) {
         $this->assertTrue($this->collection->keyExists($key));
         $this->assertEquals($value, $this->collection->get($key));
         $this->collection->set($key, $value * 2);
     });
     $this->assertTrue($success);
     $this->assertAttributeEquals([2, 4, 6], 'elements', $this->collection);
 }
コード例 #2
0
 /**
  * Test validating collection key exists
  *
  * @return void
  */
 public function testKeyExists()
 {
     $this->assertTrue($this->collection->keyExists(2));
     $this->assertFalse($this->collection->keyExists('noop'));
 }