diff options
Diffstat (limited to 'tests/units/Base.php')
-rw-r--r-- | tests/units/Base.php | 68 |
1 files changed, 22 insertions, 46 deletions
diff --git a/tests/units/Base.php b/tests/units/Base.php index 4b54cdb0..6af14ba5 100644 --- a/tests/units/Base.php +++ b/tests/units/Base.php @@ -10,49 +10,7 @@ use SimpleLogger\Logger; use SimpleLogger\File; use Kanboard\Core\Session\FlashMessage; use Kanboard\Core\Session\SessionStorage; - -class FakeHttpClient -{ - private $url = ''; - private $data = array(); - private $headers = array(); - - public function getUrl() - { - return $this->url; - } - - public function getData() - { - return $this->data; - } - - public function getHeaders() - { - return $this->headers; - } - - public function toPrettyJson() - { - return json_encode($this->data, JSON_PRETTY_PRINT); - } - - public function postJson($url, array $data, array $headers = array()) - { - $this->url = $url; - $this->data = $data; - $this->headers = $headers; - return true; - } - - public function postForm($url, array $data, array $headers = array()) - { - $this->url = $url; - $this->data = $data; - $this->headers = $headers; - return true; - } -} +use Kanboard\ServiceProvider\ActionProvider; abstract class Base extends PHPUnit_Framework_TestCase { @@ -75,6 +33,7 @@ abstract class Base extends PHPUnit_Framework_TestCase } $this->container = new Pimple\Container; + $this->container->register(new Kanboard\ServiceProvider\HelperProvider); $this->container->register(new Kanboard\ServiceProvider\AuthenticationProvider); $this->container->register(new Kanboard\ServiceProvider\DatabaseProvider); $this->container->register(new Kanboard\ServiceProvider\ClassProvider); @@ -90,8 +49,18 @@ abstract class Base extends PHPUnit_Framework_TestCase $this->container['logger'] = new Logger; $this->container['logger']->setLogger(new File($this->isWindows() ? 'NUL' : '/dev/null')); - $this->container['httpClient'] = new FakeHttpClient; - $this->container['emailClient'] = $this->getMockBuilder('EmailClient')->setMethods(array('send'))->getMock(); + + $this->container['httpClient'] = $this + ->getMockBuilder('\Kanboard\Core\Http\Client') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('get', 'getJson', 'postJson', 'postForm')) + ->getMock(); + + $this->container['emailClient'] = $this + ->getMockBuilder('\Kanboard\Core\Mail\Client') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('send')) + ->getMock(); $this->container['userNotificationType'] = $this ->getMockBuilder('\Kanboard\Model\UserNotificationType') @@ -99,9 +68,16 @@ abstract class Base extends PHPUnit_Framework_TestCase ->setMethods(array('getType', 'getSelectedTypes')) ->getMock(); + $this->container['objectStorage'] = $this + ->getMockBuilder('\Kanboard\Core\ObjectStorage\FileStorage') + ->setConstructorArgs(array($this->container)) + ->setMethods(array('put', 'moveFile', 'remove', 'moveUploadedFile')) + ->getMock(); + $this->container['sessionStorage'] = new SessionStorage; + $this->container->register(new ActionProvider); - $this->container['flash'] = function($c) { + $this->container['flash'] = function ($c) { return new FlashMessage($c); }; } |