summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Controller/ContentNegotiationTest.php4
-rw-r--r--tests/Controller/RouteActionTest.php9
-rw-r--r--tests/support/TestHelper.php48
3 files changed, 12 insertions, 49 deletions
diff --git a/tests/Controller/ContentNegotiationTest.php b/tests/Controller/ContentNegotiationTest.php
index 1a390a4..d5e142d 100644
--- a/tests/Controller/ContentNegotiationTest.php
+++ b/tests/Controller/ContentNegotiationTest.php
@@ -38,10 +38,10 @@ class ContentNegotiationTest extends \PHPUnit_Framework_TestCase
$trait->expects($this->once())->method('getRequest')->will($this->returnValue($request));
$trait->expects($this->once())->method('getNegotiator')->with($this->equalTo($type))->will($this->returnValue($negotiator));
- $builtClass = $this->callProtectedMethod($trait, 'getNegotiatorName', [$type]);
+ $buildClass = $this->callProtectedMethod($trait, 'getNegotiatorName', [$type]);
$result = $trait->{$method}($priorities);
- $this->assertEquals($builtClass, $negotiatorClass, "Obtained wrong negotiator class");
+ $this->assertEquals($buildClass, $negotiatorClass, "Obtained wrong negotiator class");
$this->assertEquals($result, $expected, "Obtained result does not match expected result");
}
diff --git a/tests/Controller/RouteActionTest.php b/tests/Controller/RouteActionTest.php
index fcab3ed..3e42d1d 100644
--- a/tests/Controller/RouteActionTest.php
+++ b/tests/Controller/RouteActionTest.php
@@ -14,7 +14,10 @@ class RouteActionTest extends \PHPUnit_Framework_TestCase
use TestHelper {
getController as private _getController;
}
-
+
+ /**
+ * @return string
+ */
protected function getControllerClass()
{
return RouteActionController::class;
@@ -27,7 +30,7 @@ class RouteActionTest extends \PHPUnit_Framework_TestCase
* @param string $className
* @return RouteActionController|\PHPUnit_Framework_MockObject_MockObject
*/
- protected function getController($methods = array(), $className = null)
+ protected function getController($methods = [], $className = null)
{
return $this->_getController(
array_merge($methods, ['getRequest', 'defaultAction', 'runTestAction', 'notFound', 'before', 'after']),
@@ -41,7 +44,7 @@ class RouteActionTest extends \PHPUnit_Framework_TestCase
{
return [
[(object)['args' => ['woo']], 'defaultAction', ['woo']],
- [(object)['action' => 'test-run'], 'testRunAction'],
+ [(object)['action' => 'run-test'], 'runTestAction'],
[(object)['action' => 'non-existent'], 'notFound']
];
}
diff --git a/tests/support/TestHelper.php b/tests/support/TestHelper.php
index 05b40d7..b48f8b0 100644
--- a/tests/support/TestHelper.php
+++ b/tests/support/TestHelper.php
@@ -3,20 +3,15 @@
namespace Jasny\Controller;
use Jasny\Controller;
+use Jasny\TestHelper as Base;
+use PHPUnit_Framework_MockObject_MockObject as MockObject;
/**
* Additional test methods
*/
trait TestHelper
{
- /**
- * Returns a builder object to create mock objects using a fluent interface.
- *
- * @param string $className
- *
- * @return \PHPUnit_Framework_MockObject_MockBuilder
- */
- abstract public function getMockBuilder($className);
+ use Base;
/**
* Get the controller class
@@ -32,7 +27,7 @@ trait TestHelper
* Get mock for controller
*
* @param array $methods Methods to mock
- * @return Controller|Controller\Session|Controller\View\Twig|\PHPUnit_Framework_MockObject_MockObject
+ * @return Controller|Controller\Session|Controller\View|MockObject
*/
public function getController($methods = [], $mockClassName = null)
{
@@ -50,39 +45,4 @@ trait TestHelper
$getMock = trait_exists($class) ? 'getMockForTrait' : 'getMockForAbstractClass';
return $builder->$getMock();
}
-
- /**
- * Set a private or protected property of the given object
- *
- * @param object $object
- * @param string $property
- * @param mixed $value
- */
- protected function setPrivateProperty($object, $property, $value)
- {
- if (!is_object($object)) {
- throw new \InvalidArgumentException("Excpected an object, got a " . gettype($object));
- }
-
- $refl = new \ReflectionProperty($object, $property);
- $refl->setAccessible(true);
- $refl->setValue($object, $value);
- }
-
- /**
- * Call protected method on some object
- *
- * @param object $object
- * @param string $name Method name
- * @param array $args
- * @return mixed Result of method call
- */
- protected function callProtectedMethod($object, $name, $args)
- {
- $class = new \ReflectionClass($object);
- $method = $class->getMethod($name);
- $method->setAccessible(true);
-
- return $method->invokeArgs($object, $args);
- }
}