Commit 04b5d4d4 authored by Tino Goratsch's avatar Tino Goratsch

fixed the unit tests

parent bd62bdcd
......@@ -11,8 +11,8 @@ use ACP3\Core\Environment\ApplicationPath;
use ACP3\Core\Helpers\Formatter\RewriteInternalUri;
use ACP3\Core\Http\Request;
use ACP3\Core\Modules\Helper\ControllerActionExists;
use ACP3\Core\Validation\ValidationRules\InternalUriValidationRule;
use ACP3\Modules\ACP3\Seo\Core\Router\Router;
use ACP3\Modules\ACP3\Seo\Validation\ValidationRules\UriAliasValidationRule;
use Symfony\Component\HttpFoundation\ServerBag;
class RewriteInternalUriTest extends \PHPUnit_Framework_TestCase
......@@ -40,7 +40,7 @@ class RewriteInternalUriTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $uriAliasValidationRuleMock;
private $internalUriValidationRule;
protected function setUp()
{
......@@ -51,7 +51,7 @@ class RewriteInternalUriTest extends \PHPUnit_Framework_TestCase
$this->controllerActionExistsMock,
$this->requestMock,
$this->routerMock,
$this->uriAliasValidationRuleMock
$this->internalUriValidationRule
);
}
......@@ -69,7 +69,7 @@ class RewriteInternalUriTest extends \PHPUnit_Framework_TestCase
$this->routerMock = $this->getMockBuilder(Router::class)
->disableOriginalConstructor()
->getMock();
$this->uriAliasValidationRuleMock = $this->getMockBuilder(UriAliasValidationRule::class)
$this->internalUriValidationRule = $this->getMockBuilder(InternalUriValidationRule::class)
->disableOriginalConstructor()
->getMock();
}
......@@ -94,7 +94,7 @@ HTML;
{
$this->setUpAppPathExpectations();
$this->setUpRequestMockExpectations();
$this->setUpValidationRuleMockExpectations(1, 'foo/bar/baz/', false);
$this->setUpValidationRuleMockExpectations(1, 'foo/bar/baz/', true);
$this->setUpControllerActionExistsMockExpectations(1, 'frontend/foo/bar/baz', false);
$this->setUpRouterMockExpectations(0, '', '');
......@@ -110,7 +110,7 @@ HTML;
{
$this->setUpAppPathExpectations();
$this->setUpRequestMockExpectations();
$this->setUpValidationRuleMockExpectations(1, 'foo/bar/baz/', false);
$this->setUpValidationRuleMockExpectations(1, 'foo/bar/baz/', true);
$this->setUpControllerActionExistsMockExpectations(1, 'frontend/foo/bar/baz', true);
$this->setUpRouterMockExpectations(1, 'foo/bar/baz/', '/foo-bar/');
......@@ -153,7 +153,7 @@ HTML;
*/
private function setUpValidationRuleMockExpectations($callCount, $uri, $isValid)
{
$this->uriAliasValidationRuleMock->expects($this->exactly($callCount))
$this->internalUriValidationRule->expects($this->exactly($callCount))
->method('isValid')
->with($uri)
->willReturn($isValid);
......
......@@ -13,6 +13,7 @@ use ACP3\Core\Session\SessionHandlerInterface;
use ACP3\Core\Validation\Exceptions\ValidationFailedException;
use ACP3\Core\Validation\ValidationRules\FormTokenValidationRule;
use ACP3\Core\Validation\Validator;
use Symfony\Component\EventDispatcher\EventDispatcher;
/**
* Class AbstractFormValidationTest
......@@ -26,6 +27,10 @@ abstract class AbstractFormValidationTest extends \PHPUnit_Framework_TestCase
* @var \ACP3\Core\Validation\AbstractFormValidation
*/
protected $formValidation;
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $eventDispatcherMock;
/**
* @var Translator|\PHPUnit_Framework_MockObject_MockObject
*/
......@@ -53,7 +58,10 @@ abstract class AbstractFormValidationTest extends \PHPUnit_Framework_TestCase
->disableOriginalConstructor()
->setMethods(['t'])
->getMock();
$this->validator = new Validator();
$this->eventDispatcherMock = $this->getMockBuilder(EventDispatcher::class)
->getMock();
$this->validator = new Validator($this->eventDispatcherMock);
}
/**
......
......@@ -19,6 +19,7 @@ abstract class AbstractValidationRuleTest extends \PHPUnit_Framework_TestCase
$this->validator = $this
->getMockBuilder(\ACP3\Core\Validation\Validator::class)
->disableOriginalConstructor()
->getMock();
$this->validator->registerValidationRule($this->validationRule);
......
......@@ -4,9 +4,14 @@ namespace ACP3\Core\Test\Validation\ValidationRules;
use ACP3\Core\Validation\Exceptions\ValidationFailedException;
use ACP3\Core\Validation\ValidationRules\EmailValidationRule;
use ACP3\Core\Validation\Validator;
use Symfony\Component\EventDispatcher\EventDispatcher;
class ValidatorTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $eventDispatcherMock;
/**
* @var Validator
*/
......@@ -16,7 +21,10 @@ class ValidatorTest extends \PHPUnit_Framework_TestCase
{
parent::setUp();
$this->validator = new Validator();
$this->eventDispatcherMock = $this->getMockBuilder(EventDispatcher::class)
->getMock();
$this->validator = new Validator($this->eventDispatcherMock);
}
public function testValidateValidValidationRuleWithValidValue()
......
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