code coverage

This commit is contained in:
John Bintz 2010-02-01 22:41:56 -05:00
parent 1dd4c8a97d
commit 1e3f1f0ab0
2 changed files with 39 additions and 2 deletions

View File

@ -12,10 +12,12 @@ class ComicPressBackendFilesystem extends ComicPressBackend {
$this->source_name = __('Filesystem', 'comicpress'); $this->source_name = __('Filesystem', 'comicpress');
} }
function _getimagesize($file) { return getimagesize($file); }
function dims($size = null) { function dims($size = null) {
$dims = array(); $dims = array();
if ($result = getimagesize($this->files_by_type[$this->ensure_type($size)])) { if ($result = $this->_getimagesize($this->files_by_type[$this->ensure_type($size)])) {
$dims = array_combine(array('width', 'height'), array_slice($result, 0, 2)); $dims = array_combine(array('width', 'height'), array_slice($result, 0, 2));
} }

View File

@ -15,5 +15,40 @@ class ComicPressBackendFilesystemTest extends PHPUnit_Framework_TestCase {
vfsStreamWrapper::setRoot(new vfsStreamDirectory('root')); vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
} }
function testSomething() {} function providerTestDims() {
return array(
array(false, array()),
array(
array(
200, 100, 300
),
array(
'width' => 200,
'height' => 100
)
)
);
}
/**
* @dataProvider providerTestDims
*/
function testDims($getimagesize_return, $expected_result) {
$fs = $this->getMock('ComicPressBackendFilesystem', array('_getimagesize', 'ensure_type'));
$fs->expects($this->once())->method('ensure_type')->with('type')->will($this->returnValue('newtype'));
$fs->expects($this->once())->method('_getimagesize')->with('file')->will($this->returnValue($getimagesize_return));
$fs->files_by_type = array('newtype' => 'file');
$this->assertEquals($expected_result, $fs->dims('type'));
}
function testUrl() {
$fs = $this->getMock('ComicPressBackendFilesystem', array('ensure_type'));
$fs->expects($this->once())->method('ensure_type')->with('type')->will($this->returnValue('newtype'));
$fs->file_urls_by_type = array('newtype' => 'url');
$this->assertEquals('url', $fs->url('type'));
}
} }