* @license MIT * * @covers \ProxyManager\Exception\FileNotWritableException * @group Coverage */ class FileNotWritableExceptionTest extends PHPUnit_Framework_TestCase { public function testFromInvalidMoveOperation() { $exception = FileNotWritableException::fromInvalidMoveOperation('/tmp/a', '/tmp/b'); $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); $this->assertSame( 'Could not move file "/tmp/a" to location "/tmp/b": either the source file is not readable,' . ' or the destination is not writable', $exception->getMessage() ); } public function testFromNotWritableLocationWithNonFilePath() { $exception = FileNotWritableException::fromNonWritableLocation(__DIR__); $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); $this->assertSame( 'Could not write to path "' . __DIR__ . '": exists and is not a file', $exception->getMessage() ); } public function testFromNotWritableLocationWithNonWritablePath() { $path = sys_get_temp_dir() . '/' . uniqid('FileNotWritableExceptionTestNonWritable', true); mkdir($path, 0555); $exception = FileNotWritableException::fromNonWritableLocation($path . '/foo'); $this->assertInstanceOf('ProxyManager\\Exception\\FileNotWritableException', $exception); $this->assertSame( 'Could not write to path "' . $path . '/foo": is not writable', $exception->getMessage() ); } }