Ejemplo n.º 1
0
 public function testWrite()
 {
     $data = [['abc']];
     $result = [['def']];
     $fileReader = new Json(new DummyFileReader());
     $dataMapper = $this->getMockBuilder('Balloon\\Mapper\\DataMapper')->disableOriginalConstructor()->getMock();
     $dataMapper->expects($this->once())->method('unmapObjects')->with($data)->will($this->returnValue($result));
     $dataMapperDecorator = new DataMapperDecorator($fileReader, $dataMapper);
     $this->assertSame(29, $dataMapperDecorator->write($data));
     $this->assertSame($result, $fileReader->read());
 }
Ejemplo n.º 2
0
 public function testRemoveAll()
 {
     $data = [['key1' => 'value1'], ['key2' => 'value2']];
     $fileReader = new DummyFileReader();
     $jsonFileReader = new Json($fileReader);
     $jsonFileReader->write($data);
     $fileManager = new FileManager($jsonFileReader);
     $result = $fileManager->removeAll();
     $this->assertSame(4, $result);
     $result = $fileManager->getAll();
     $this->assertSame([], $result);
 }