for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Modera\UpgradeBundle\Tests\Unit\Entity;
use Modera\UpgradeBundle\Json\JsonFile;
/**
* @author Sergei Vizel <[email protected]>
* @copyright 2014 Modera Foundation
*/
class JsonFileTest extends \PHPUnit_Framework_TestCase
{
* @expectedException RuntimeException
public function testFailureRead()
$jsonFile = new JsonFile(__DIR__.'/undefined.json');
$jsonFile->read();
}
public function testJsonError()
$jsonFile = new JsonFile(__DIR__.'/test_error.json');
public function testSuccessfulRead()
$jsonFile = new JsonFile(__DIR__.'/test_read.json');
$data = $jsonFile->read();
$this->assertEquals(array('test' => 'test'), $data);
public function testFailureWrite()
$jsonFile = new JsonFile(__DIR__.'/undefined/test2.json');
$jsonFile->write(array('failure' => 'failure'));
public function testSuccessfulWrite()
$jsonFile = new JsonFile(__DIR__.'/test_write.json');
$data = array('test' => 'test');
$jsonFile->write($data);
$this->assertEquals($data, $jsonFile->read());
unlink(__DIR__.'/test_write.json');