Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

add phpunit 6 require #40

Merged
merged 2 commits into from
Feb 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"require": {
"php": "^5.6 || ^7.0",
"phpunit/phpunit": "^4.0 || ^5.0",
"phpunit/phpunit": "^4.0 || ^5.0 || ^6.0",
Copy link
Member

@froschdesign froschdesign Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will not work with the current version of zend-test, because in PHPUnit 6 the class PHPUnit_Framework_TestCase no longer exists.

Copy link
Contributor Author

@samsonasik samsonasik Feb 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can change the code with class_alias:

use PHPUnit\Framework\TestCase;

if (! class_exists(TestCase::class)) {
    class_alias(\PHPUnit_Framework_TestCase::class, TestCase::class);
}

abstract class AbstractControllerTestCase extends TestCase

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go for it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ;)

"zendframework/zend-console": "^2.6",
"zendframework/zend-dom": "^2.6",
"zendframework/zend-eventmanager": "^2.6.2 || ^3.0",
Expand Down
17 changes: 11 additions & 6 deletions test/PHPUnit/Controller/AbstractConsoleControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
*/
namespace ZendTest\Test\PHPUnit\Controller;

use PHPUnit\Framework\ExpectationFailedException;
use Zend\Router\RouteMatch;
use Zend\Test\PHPUnit\Controller\AbstractConsoleControllerTestCase;

if (! class_exists(ExpectationFailedException::class)) {
class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, wish I'd had a chance to review before merge.

All these class_alias calls should likely be in a single file that is added via an autoload_dev section of the composer.json. That way the aliases are created when needed, and outside the class file declarations themselves.


/**
* @group Zend_Test
*/
Expand All @@ -35,7 +40,7 @@ public function testAssertResponseStatusCode()
$this->assertResponseStatusCode(0);

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual status code is "0"' // check actual status code is display
);
$this->assertResponseStatusCode(1);
Expand All @@ -46,15 +51,15 @@ public function testAssertNotResponseStatusCode()
$this->dispatch('--console');
$this->assertNotResponseStatusCode(1);

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotResponseStatusCode(0);
}

public function testAssertResponseStatusCodeWithBadCode()
{
$this->dispatch('--console');
$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'Console status code assert value must be O (valid) or 1 (error)'
);
$this->assertResponseStatusCode(2);
Expand All @@ -64,7 +69,7 @@ public function testAssertNotResponseStatusCodeWithBadCode()
{
$this->dispatch('--console');
$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'Console status code assert value must be O (valid) or 1 (error)'
);
$this->assertNotResponseStatusCode(2);
Expand All @@ -77,7 +82,7 @@ public function testAssertConsoleOutputContains()
$this->assertConsoleOutputContains('foo, bar');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual content is "foo, bar"' // check actual content is display
);
$this->assertConsoleOutputContains('baz');
Expand All @@ -88,7 +93,7 @@ public function testNotAssertConsoleOutputContains()
$this->dispatch('--console');
$this->assertNotConsoleOutputContains('baz');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotConsoleOutputContains('foo');
}

Expand Down
46 changes: 25 additions & 21 deletions test/PHPUnit/Controller/AbstractControllerTestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use org\bovigo\vfs\vfsStream;
use org\bovigo\vfs\vfsStreamWrapper;
use PHPUnit_Framework_ExpectationFailedException;
use PHPUnit\Framework\ExpectationFailedException;
use RuntimeException;
use Zend\Console\Console;
use Zend\Mvc\Application;
Expand All @@ -19,6 +19,10 @@
use Zend\Stdlib\ResponseInterface;
use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

if (! class_exists(ExpectationFailedException::class)) {
class_alias(\PHPUnit_Framework_ExpectationFailedException::class, ExpectationFailedException::class);
}

/**
* @group Zend_Test
*/
Expand Down Expand Up @@ -140,7 +144,7 @@ public function testAssertModuleName()
$this->assertModuleName('BAz');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual module name is "baz"' // check actual module is display
);
$this->assertModuleName('Application');
Expand All @@ -158,7 +162,7 @@ public function testAssertExceptionDetailsPresentWhenTraceErrorIsEnabled()
$caught = false;
try {
$this->assertModuleName('Application');
} catch (PHPUnit_Framework_ExpectationFailedException $ex) {
} catch (ExpectationFailedException $ex) {
$caught = true;
$message = $ex->getMessage();
}
Expand All @@ -182,7 +186,7 @@ public function testAssertExceptionDetailsNotPresentWhenTraceErrorIsDisabled()
$caught = false;
try {
$this->assertModuleName('Application');
} catch (PHPUnit_Framework_ExpectationFailedException $ex) {
} catch (ExpectationFailedException $ex) {
$caught = true;
$message = $ex->getMessage();
}
Expand All @@ -199,7 +203,7 @@ public function testAssertNotModuleName()
$this->dispatch('/tests');
$this->assertNotModuleName('Application');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotModuleName('baz');
}

Expand All @@ -213,7 +217,7 @@ public function testAssertControllerClass()
$this->assertControllerClass('indexcontroller');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual controller class is "indexcontroller"' // check actual controller class is display
);
$this->assertControllerClass('Index');
Expand All @@ -224,7 +228,7 @@ public function testAssertNotControllerClass()
$this->dispatch('/tests');
$this->assertNotControllerClass('Index');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotControllerClass('IndexController');
}

Expand All @@ -238,7 +242,7 @@ public function testAssertControllerName()
$this->assertControllerName('BAz_index');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual controller name is "baz_index"' // check actual controller name is display
);
$this->assertControllerName('baz');
Expand All @@ -249,7 +253,7 @@ public function testAssertNotControllerName()
$this->dispatch('/tests');
$this->assertNotControllerName('baz');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotControllerName('baz_index');
}

Expand All @@ -263,7 +267,7 @@ public function testAssertActionName()
$this->assertActionName('UnitTests');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual action name is "unittests"' // check actual action name is display
);
$this->assertActionName('unit');
Expand All @@ -274,7 +278,7 @@ public function testAssertNotActionName()
$this->dispatch('/tests');
$this->assertNotActionName('unit');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotActionName('unittests');
}

Expand All @@ -288,7 +292,7 @@ public function testAssertMatchedRouteName()
$this->assertMatchedRouteName('MyRoute');

$this->setExpectedException(
'PHPUnit_Framework_ExpectationFailedException',
ExpectationFailedException::class,
'actual matched route name is "myroute"' // check actual matched route name is display
);
$this->assertMatchedRouteName('route');
Expand All @@ -299,7 +303,7 @@ public function testAssertNotMatchedRouteName()
$this->dispatch('/tests');
$this->assertNotMatchedRouteName('route');

$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException');
$this->setExpectedException(ExpectationFailedException::class);
$this->assertNotMatchedRouteName('myroute');
}

Expand All @@ -312,56 +316,56 @@ public function testAssertNoMatchedRoute()
public function testAssertNoMatchedRouteWithMatchedRoute()
{
$this->dispatch('/tests');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'no route matched');
$this->setExpectedException(ExpectationFailedException::class, 'no route matched');
$this->assertNoMatchedRoute();
}

public function testControllerNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertControllerName('something');
}

public function testNotControllerNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertNotControllerName('something');
}

public function testActionNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertActionName('something');
}

public function testNotActionNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertNotActionName('something');
}

public function testMatchedRouteNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertMatchedRouteName('something');
}

public function testNotMatchedRouteNameWithNoRouteMatch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertNotMatchedRouteName('something');
}

public function testControllerClassWithNoRoutematch()
{
$this->dispatch('/invalid');
$this->setExpectedException('PHPUnit_Framework_ExpectationFailedException', 'No route matched');
$this->setExpectedException(ExpectationFailedException::class, 'No route matched');
$this->assertControllerClass('something');
}

Expand Down
Loading