Skip to content

Commit 985bcac

Browse files
authored
Use latest phpunit (#44)
* Use latest phpunit * Updated tests not to use final class
1 parent a17b4be commit 985bcac

15 files changed

+44
-40
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"symfony/console": "^3.4 || ^4.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^5.7.27",
19+
"phpunit/phpunit": "^7.2.7",
2020
"symfony/http-foundation": "^3.4 || ^4.0",
2121
"zendframework/zend-diactoros": "^1.8",
2222
"satooshi/php-coveralls": "^1.1"

phpunit.xml.dist

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
</testsuite>
77
</testsuites>
88
<filter>
9-
<blacklist>
10-
<directory>vendor</directory>
11-
<directory>test</directory>
12-
</blacklist>
9+
<whitelist>
10+
<directory>src</directory>
11+
</whitelist>
1312
</filter>
1413
</phpunit>
1514

test/ApplicationFactoryTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
use PHPFastCGI\FastCGIDaemon\ApplicationFactory;
66
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockKernel;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* Tests the application factory.
1011
*/
11-
class ApplicationFactoryTest extends \PHPUnit_Framework_TestCase
12+
class ApplicationFactoryTest extends TestCase
1213
{
1314
/**
1415
* Tests that the factory can create a Symfony console application with a
@@ -43,11 +44,10 @@ public function testCreateApplication()
4344

4445
/**
4546
* Tests that an invalid kernel throws an InvalidArgumentException.
46-
*
47-
* @expectedException \InvalidArgumentException
4847
*/
4948
public function testInvalidKernel()
5049
{
50+
$this->expectException(\InvalidArgumentException::class);
5151
(new ApplicationFactory())->createApplication('foo');
5252
}
5353
}

test/CallbackKernelTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

55
use PHPFastCGI\FastCGIDaemon\CallbackKernel;
66
use PHPFastCGI\FastCGIDaemon\Http\Request;
7+
use PHPUnit\Framework\TestCase;
78
use Zend\Diactoros\Response;
89

910
/**
1011
* Tests the callback wrapper.
1112
*/
12-
class CallbackKernelTest extends \PHPUnit_Framework_TestCase
13+
class CallbackKernelTest extends TestCase
1314
{
1415
/**
1516
* Tests an \InvalidArgumentException is thrown when it isn't constructed
1617
* with a callable.
17-
*
18-
* @expectedException \InvalidArgumentException
1918
*/
2019
public function testInvalidArgumentException()
2120
{
21+
$this->expectException(\InvalidArgumentException::class);
2222
new CallbackKernel('not a callable function');
2323
}
2424

test/Command/DaemonRunCommandTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockDaemon;
99
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockDaemonFactory;
1010
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockKernel;
11+
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Console\Input\ArrayInput;
1213
use Symfony\Component\Console\Logger\ConsoleLogger;
1314
use Symfony\Component\Console\Output\NullOutput;
1415

1516
/**
1617
* Tests the daemon run command.
1718
*/
18-
class DaemonRunCommandTest extends \PHPUnit_Framework_TestCase
19+
class DaemonRunCommandTest extends TestCase
1920
{
2021
/**
2122
* Tests that the command options are configured properly.
@@ -95,15 +96,14 @@ public function testDaemonOptions()
9596
/**
9697
* Test with only the host option set. An Invalid argument exception should
9798
* be thrown if the host option is supplied without the port optional also.
98-
*
99-
* @expectedException \InvalidArgumentException
10099
*/
101100
public function testHostOptionOnly()
102101
{
103102
$context = $this->createTestingContext([]);
104103

105104
$input = new ArrayInput(['--host' => 'foo']);
106105

106+
$this->expectException(\InvalidArgumentException::class);
107107
$context['command']->run($input, new NullOutput());
108108
}
109109

@@ -149,12 +149,11 @@ public function testShutdown()
149149

150150
/**
151151
* Test flag shutdown with no daemon.
152-
*
153-
* @expectedException \RuntimeException
154152
*/
155153
public function testShutdownNoDaemon()
156154
{
157155
$command = new DaemonRunCommand(new MockKernel(), new MockDriverContainer());
156+
$this->expectException(\RuntimeException::class);
158157
$command->flagShutdown();
159158
}
160159

test/DaemonOptionsTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
namespace PHPFastCGI\Test\FastCGIDaemon;
44

55
use PHPFastCGI\FastCGIDaemon\DaemonOptions;
6+
use PHPUnit\Framework\TestCase;
67
use Psr\Log\NullLogger;
78

89
/**
910
* Tests the daemon options.
1011
*/
11-
class DaemonOptionsTest extends \PHPUnit_Framework_TestCase
12+
class DaemonOptionsTest extends TestCase
1213
{
1314
/**
1415
* Tests that the daemon options object works properly.
@@ -35,33 +36,30 @@ public function testDaemonOptions()
3536
/**
3637
* Test that an InvalidArgumentException is thrown when an invalid logger
3738
* is provided.
38-
*
39-
* @expectedException \InvalidArgumentException
4039
*/
4140
public function testInvalidLogger()
4241
{
42+
$this->expectException(\InvalidArgumentException::class);
4343
new DaemonOptions([DaemonOptions::LOGGER => 'foo']);
4444
}
4545

4646
/**
4747
* Test that an InvalidArgumentException is thrown when the object is
4848
* constructed with an unknown option.
49-
*
50-
* @expectedException \InvalidArgumentException
5149
*/
5250
public function testUnknownOptionInConstructor()
5351
{
52+
$this->expectException(\InvalidArgumentException::class);
5453
new DaemonOptions(['hello' => 'world']);
5554
}
5655

5756
/**
5857
* Test that an InvalidArgumentException is thrown when ::getOption is
5958
* called with an unknown option.
60-
*
61-
* @expectedException \InvalidArgumentException
6259
*/
6360
public function testGetUnknownOption()
6461
{
62+
$this->expectException(\InvalidArgumentException::class);
6563
(new DaemonOptions())->getOption('hello');
6664
}
6765
}

test/Driver/DriverContainerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
namespace PHPFastCGI\Test\FastCGIDaemon\Driver;
44

55
use PHPFastCGI\FastCGIDaemon\Driver\DriverContainer;
6+
use PHPUnit\Framework\TestCase;
67

78
/**
89
* Tests the driver container.
910
*/
10-
class DriverContainerTest extends \PHPUnit_Framework_TestCase
11+
class DriverContainerTest extends TestCase
1112
{
1213
/**
1314
* Tests that the driver container throws an InvalidArgumentException with
1415
* an unknown driver.
15-
*
16-
* @expectedException InvalidArgumentException
1716
*/
1817
public function testInvalidDriver()
1918
{
2019
$driverContainer = new DriverContainer();
2120

21+
$this->expectException(\InvalidArgumentException::class);
2222
$driverContainer->getFactory('foo');
2323
}
2424

test/Driver/Userland/Connection/StreamSocketConnectionPoolTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Connection\StreamSocketConnection;
66
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Connection\StreamSocketConnectionPool;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* Test to ensure that the StreamSocketConnectionPool class can accept new
1011
* connections and trigger updates when data is sent.
1112
*/
12-
class StreamSocketConnectionPoolTest extends \PHPUnit_Framework_TestCase
13+
class StreamSocketConnectionPoolTest extends TestCase
1314
{
1415
/**
1516
* Test basic connection pool.
@@ -54,8 +55,6 @@ public function testConnectionPool()
5455

5556
/**
5657
* Test basic stream_select fail.
57-
*
58-
* @expectedException \RuntimeException
5958
*/
6059
public function testStreamSelectFail()
6160
{
@@ -65,6 +64,7 @@ public function testStreamSelectFail()
6564

6665
fclose($serverSocket);
6766

67+
$this->expectException(\RuntimeException::class);
6868
$connectionPool->getReadableConnections(0);
6969
}
7070

test/Driver/Userland/Connection/StreamSocketConnectionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Connection\StreamSocketConnection;
66
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Exception\ConnectionException;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* Test to ensure that the StreamSocketConnection class can read, write and
1011
* close.
1112
*/
12-
class StreamSocketConnectionTest extends \PHPUnit_Framework_TestCase
13+
class StreamSocketConnectionTest extends TestCase
1314
{
1415
/**
1516
* Tests that the StreamSocketConnection class can read, write and close.

test/Driver/Userland/ConnectionHandler/ConnectionHandlerFactoryTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22

33
namespace PHPFastCGI\Test\FastCGIDaemon\Driver\Userland\ConnectionHandler;
44

5+
use PHPFastCGI\FastCGIDaemon\Driver\Userland\Connection\ConnectionInterface;
56
use PHPFastCGI\FastCGIDaemon\Driver\Userland\ConnectionHandler\ConnectionHandlerFactory;
67
use PHPFastCGI\Test\FastCGIDaemon\Helper\Mocker\MockKernel;
8+
use PHPUnit\Framework\TestCase;
79

810
/**
911
* Tests the daemon.
1012
*/
11-
class ConnectionHandlerFactoryTest extends \PHPUnit_Framework_TestCase
13+
class ConnectionHandlerFactoryTest extends TestCase
1214
{
1315
/**
1416
* Tests that the factory creates a connection handler from a kernel.
@@ -18,7 +20,7 @@ public function testCreatesConnectionHandlerFromKernel()
1820
$kernel = new MockKernel();
1921

2022
$connection = $this
21-
->getMockBuilder('PHPFastCGI\\FastCGIDaemon\\Driver\\Userland\\Connection\\StreamSocketConnection')
23+
->getMockBuilder(ConnectionInterface::class)
2224
->disableOriginalConstructor()
2325
->getMock();
2426

0 commit comments

Comments
 (0)