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()); }
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); }