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