/** @test */
 public function it_should_not_mutate_source_data()
 {
     $memory = null;
     $dotArray = DotArray::init($memory);
     $dotArray->read('foo.bar', 'foobar');
     $this->assertEquals(null, $memory);
 }
 /** @test */
 public function it_should_not_pass_by_reference_when_written()
 {
     $memory = null;
     $dotArray = DotArray::init($memory);
     $value = $dotArray->write('foo.bar', 'foobar');
     $value = 'something else';
     $this->assertEquals('foobar', $dotArray->read('foo.bar'));
 }
 /** @test */
 public function it_can_check_if_has_property()
 {
     $memory = null;
     $dotArray = DotArray::init($memory);
     $dotArray->write('foo.bar', 'foobar');
     $this->assertTrue($dotArray->open('foo')->has('bar'));
     $this->assertFalse($dotArray->open('foo')->has('foo'));
 }
 /** @test */
 public function it_should_support_dot_paths()
 {
     $memory = null;
     $dotArray = DotArray::init($memory);
     $dotArray->open('foo.bar')->write(['a' => 1, 'b' => 2]);
     $dotArray->append('foo.bar', ['c' => 3]);
     $this->assertEquals(1, $dotArray->read('foo.bar.a'));
     $this->assertEquals(2, $dotArray->read('foo.bar.b'));
     $this->assertEquals(3, $dotArray->read('foo.bar.c'));
 }
 /** @test */
 public function showroom()
 {
     $memory = null;
     $dotArray = DotArray::init($memory);
     $mercedes = $dotArray->open('cars.mercedes');
     $mercedes->write(['model' => 'S', 'origin' => 'germany']);
     $mercedes->append(['passengers' => 4]);
     $mercedes->write('colour', 'blue');
     $this->assertCount(4, $dotArray->read('cars.mercedes'));
 }