Commit 26d85c2f authored by Tino Goratsch's avatar Tino Goratsch

fix the unit tests

parent a85f9907
Pipeline #18724255 passed with stages
in 9 minutes and 56 seconds
......@@ -8,6 +8,7 @@
namespace ACP3\Core\Test\Assets;
use ACP3\Core\Assets\Libraries;
use ACP3\Core\Http\RequestInterface;
use Symfony\Component\EventDispatcher\EventDispatcher;
class LibrariesTest extends \PHPUnit_Framework_TestCase
......@@ -20,14 +21,17 @@ class LibrariesTest extends \PHPUnit_Framework_TestCase
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $eventDispatcherMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $requestMock;
protected function setUp()
{
$this->eventDispatcherMock = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
$this->eventDispatcherMock = $this->createMock(EventDispatcher::class);
$this->libraries = new Libraries($this->eventDispatcherMock);
$this->libraries = new Libraries($this->requestMock, $this->eventDispatcherMock);
}
public function testAddLibrary()
......@@ -49,6 +53,6 @@ class LibrariesTest extends \PHPUnit_Framework_TestCase
$this->libraries->enableLibraries(['foobar']);
$this->assertEquals(['jquery', 'js-cookie', 'foobar'], $this->libraries->getEnabledLibraries());
$this->assertEquals(['jquery', 'ajax-form', 'foobar'], $this->libraries->getEnabledLibraries());
}
}
......@@ -10,6 +10,7 @@ namespace ACP3\Core\Test;
use ACP3\Core\Assets;
use ACP3\Core\Environment\ApplicationMode;
use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Http\RequestInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class AssetsTest extends \PHPUnit_Framework_TestCase
......@@ -22,6 +23,10 @@ class AssetsTest extends \PHPUnit_Framework_TestCase
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $eventDispatcherMock;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $requestMock;
protected function setUp()
{
......@@ -31,13 +36,14 @@ class AssetsTest extends \PHPUnit_Framework_TestCase
$appPath
->setDesignRootPathInternal(ACP3_ROOT_DIR . 'tests/designs/')
->setDesignPathInternal('acp3/');
$libraries = new Assets\Libraries($this->eventDispatcherMock);
$libraries = new Assets\Libraries($this->requestMock, $this->eventDispatcherMock);
$this->assets = new Assets($appPath, $libraries);
}
private function setUpMockObjects()
{
$this->requestMock = $this->getMockForAbstractClass(RequestInterface::class);
$this->eventDispatcherMock = $this->getMockBuilder(EventDispatcherInterface::class)
->setMethods([
'dispatch',
......@@ -56,7 +62,7 @@ class AssetsTest extends \PHPUnit_Framework_TestCase
public function testDefaultLibrariesEnabled()
{
$libraries = $this->assets->getEnabledLibrariesAsString();
$this->assertEquals('jquery,js-cookie,bootstrap', $libraries);
$this->assertEquals('jquery,ajax-form,bootstrap', $libraries);
}
public function testEnableDatepicker()
......@@ -64,7 +70,7 @@ class AssetsTest extends \PHPUnit_Framework_TestCase
$this->assets->enableLibraries(['datetimepicker']);
$libraries = $this->assets->getEnabledLibrariesAsString();
$this->assertEquals('moment,jquery,js-cookie,bootstrap,datetimepicker', $libraries);
$this->assertEquals('moment,jquery,ajax-form,bootstrap,datetimepicker', $libraries);
}
public function testFetchAdditionalThemeCssFiles()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment