Commit 03ede877 authored by Tino Goratsch's avatar Tino Goratsch

increased the unit test coverage of two classes

parent d0badea8
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\Test\Assets;
use ACP3\Core\Assets\Libraries;
use Symfony\Component\EventDispatcher\EventDispatcher;
class LibrariesTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Libraries
*/
private $libraries;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $eventDispatcherMock;
protected function setUp()
{
$this->eventDispatcherMock = $this->getMockBuilder(EventDispatcher::class)
->disableOriginalConstructor()
->getMock();
$this->libraries = new Libraries($this->eventDispatcherMock);
}
public function testAddLibrary()
{
$data = [
'enabled' => false,
'dependencies' => ['jquery'],
'css' => 'foo.css',
'js' => 'bar.js'
];
$this->libraries->addLibrary('foobar', $data);
$this->assertArraySubset(['foobar' => $data], $this->libraries->getLibraries());
}
public function testEnableLibraries()
{
$this->testAddLibrary();
$this->libraries->enableLibraries(['foobar']);
$this->assertEquals(['jquery', 'foobar'], $this->libraries->getEnabledLibraries());
}
}
<?php
/**
* Copyright (c) 2016 by the ACP3 Developers.
* See the LICENCE file at the top-level module directory for licencing details.
*/
namespace ACP3\Core\Test\View\Renderer\Smarty;
use ACP3\Core\View\Renderer\Smarty\PluginInterface;
abstract class AbstractPluginTest extends \PHPUnit_Framework_TestCase
{
/**
* @var PluginInterface
*/
protected $plugin;
public function testExtensionName()
{
$this->assertEquals($this->getExpectedExtensionName(), $this->plugin->getExtensionName());
}
/**
* @return string
*/
abstract protected function getExpectedExtensionName();
}
......@@ -7,31 +7,40 @@
namespace ACP3\Core\Test\View\Renderer\Smarty\Modifiers;
use ACP3\Core\Test\View\Renderer\Smarty\AbstractPluginTest;
use ACP3\Core\View\Renderer\Smarty\Modifiers\PrefixUri;
class PrefixUriTest extends \PHPUnit_Framework_TestCase
class PrefixUriTest extends AbstractPluginTest
{
/**
* @var PrefixUri
*/
private $prefixUri;
protected $plugin;
protected function setUp()
{
$this->prefixUri = new PrefixUri();
$this->plugin = new PrefixUri();
}
public function testAddUriPrefix()
{
$value = 'www.example.com';
$expected = 'http://www.example.com';
$this->assertEquals($expected, $this->prefixUri->process($value));
$this->assertEquals($expected, $this->plugin->process($value));
}
public function testAddUriPrefixNotNeeded()
{
$value = 'http://www.example.com';
$expected = 'http://www.example.com';
$this->assertEquals($expected, $this->prefixUri->process($value));
$this->assertEquals($expected, $this->plugin->process($value));
}
/**
* @return string
*/
protected function getExpectedExtensionName()
{
return 'prefix_uri';
}
}
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