Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

mockery is used in tests

  • Loading branch information...
commit 0267ac840e3fd51d7d2b8509c8f39e97c670cb45 1 parent abfa202
@janmarek authored
View
3  composer.json
@@ -17,5 +17,8 @@
},
"require": {
"nette/nette": "2.0.*"
+ },
+ "require-dev": {
+ "mockery/mockery": "*"
}
}
View
16 tests/CompilerTest.php
@@ -2,9 +2,8 @@
namespace WebLoader\Test;
+use Mockery;
use WebLoader\Compiler;
-use WebLoader\FileCollection;
-use WebLoader\DefaultOutputNamingConvention;
/**
* CompilerTest
@@ -19,12 +18,17 @@ class CompilerTest extends \PHPUnit_Framework_TestCase
protected function setUp()
{
- $fileCollection = new FileCollection(__DIR__ . '/fixtures');
- $fileCollection->addFiles(array(
- 'a.txt', 'b.txt', 'c.txt'
+ $fileCollection = Mockery::mock('WebLoader\IFileCollection');
+ $fileCollection->shouldReceive('getFiles')->andReturn(array(
+ __DIR__ . '/fixtures/a.txt',
+ __DIR__ . '/fixtures/b.txt',
+ __DIR__ . '/fixtures/c.txt',
));
- $convention = new DefaultOutputNamingConvention();
+ $convention = Mockery::mock('WebLoader\IOutputNamingConvention');
+ $convention->shouldReceive('getFilename')->andReturnUsing(function ($files, $compiler) {
+ return 'webloader-' . md5(join(',', $files));
+ });
$this->object = new Compiler($fileCollection, $convention, __DIR__ . '/temp');
View
15 tests/DefaultOutputNamingConventionTest.php
@@ -15,13 +15,12 @@ class DefaultOutputNamingConventionTest extends \PHPUnit_Framework_TestCase
/** @var DefaultOutputNamingConvention */
private $object;
- private $compilerMock;
+ private $compiler;
protected function setUp()
{
$this->object = new DefaultOutputNamingConvention();
- $this->compilerMock = $this->getMockBuilder('Webloader\Compiler')
- ->disableOriginalConstructor()->getMock();
+ $this->compiler = \Mockery::mock('Webloader\Compiler');
}
public function testMultipleFiles()
@@ -31,12 +30,12 @@ public function testMultipleFiles()
__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'b.txt',
);
- $name = $this->object->getFilename($files, $this->compilerMock);
+ $name = $this->object->getFilename($files, $this->compiler);
$this->assertRegExp('/^webloader-[0-9a-f]{12}$/', $name);
// another hash
$files[] = __DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'c.txt';
- $name2 = $this->object->getFilename($files, $this->compilerMock);
+ $name2 = $this->object->getFilename($files, $this->compiler);
$this->assertNotEquals($name, $name2, 'Different file lists results to same filename.');
}
@@ -46,7 +45,7 @@ public function testOneFile()
__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'a.txt',
);
- $name = $this->object->getFilename($files, $this->compilerMock);
+ $name = $this->object->getFilename($files, $this->compiler);
$this->assertRegExp('/^webloader-[0-9a-f]{12}-a$/', $name);
}
@@ -56,7 +55,7 @@ public function testCssConvention()
__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'a.txt',
);
- $name = DefaultOutputNamingConvention::createCssConvention()->getFilename($files, $this->compilerMock);
+ $name = DefaultOutputNamingConvention::createCssConvention()->getFilename($files, $this->compiler);
$this->assertRegExp('/^cssloader-[0-9a-f]{12}-a.css$/', $name);
}
@@ -66,7 +65,7 @@ public function testJsConvention()
__DIR__ . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'a.txt',
);
- $name = DefaultOutputNamingConvention::createJsConvention()->getFilename($files, $this->compilerMock);
+ $name = DefaultOutputNamingConvention::createJsConvention()->getFilename($files, $this->compiler);
$this->assertRegExp('/^jsloader-[0-9a-f]{12}-a.js$/', $name);
}
Please sign in to comment.
Something went wrong with that request. Please try again.