Skip to content

Commit

Permalink
silex2 (#5)
Browse files Browse the repository at this point in the history
silex2
fix some unit tests for phpunit 6
  • Loading branch information
jygaulier authored Apr 11, 2018
1 parent 6185ab4 commit d1c3f2f
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 24 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": ">=5.3.3",
"php": "~7.0",
"ext-zmq": "*",

"neutron/process-manager": "2.0.x-dev@dev",
Expand All @@ -33,7 +33,7 @@
],
"require-dev": {
"monolog/monolog": "~1.0",
"phpunit/phpunit": "~3.7|^4.0|^5.0",
"phpunit/phpunit": "~6.0",
"symfony/console": "~2.3",
"symfony/finder": "~2.1"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Alchemy/TaskManager/Test/TaskTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Alchemy\TaskManager\TaskInterface;

abstract class TaskTestCase extends \PHPUnit_Framework_TestCase
abstract class TaskTestCase extends \PHPUnit\Framework\TestCase
{
public function testThatCreateProcessReturnsAProcessableInterface()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function testWithLogger()
$job->expects($this->once())->method('stop');
$job->expects($this->any())->method('isStarted')->will($this->returnValue(true));

$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->createMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())->method('notice')->with('Max duration reached for romain (0.1 s.), stopping.');

$subscriber = new DurationLimitSubscriber(0.1, $logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class LockFileSubscriberTest extends SubscriberTestCase
*/
public function testWithInvalidParams($id, $directory, $message)
{
$this->setExpectedException('Alchemy\TaskManager\Exception\InvalidArgumentException', $message);
$this->expectException('Alchemy\TaskManager\Exception\InvalidArgumentException');
$this->expectExceptionMessage($message);
new LockFileSubscriber($id, null, $directory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testOnJobTickWithLogger()
$job->expects($this->once())->method('stop');
$job->expects($this->any())->method('isStarted')->will($this->returnValue(true));

$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->createMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())->method('notice')->with('Max memory reached for romain (1 o.), stopping.');

$subscriber = new MemoryLimitSubscriber(1, $logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function testWithLogger()
$job->expects($this->once())->method('stop');
$job->expects($this->any())->method('isStarted')->will($this->returnValue(true));

$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->createMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())->method('notice')->with('No signal received for romain since start-time (max period is 0.15 s.), stopping.');

$subscriber = new SignalControlledSubscriber(SignalHandler::getInstance(), 0.15, $logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testSignalWithLogger($signal)
$job->expects($this->once())->method('stop');
$job->expects($this->any())->method('isStarted')->will($this->returnValue(true));

$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->createMock('Psr\Log\LoggerInterface');
$logger->expects($this->once())->method('notice');

$subscriber = new StopSignalSubscriber(SignalHandler::getInstance(), $logger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class LockFileSubscriberTest extends SubscriberTestCase
*/
public function testWithInvalidParams($directory, $message)
{
$this->setExpectedException('Alchemy\TaskManager\Exception\InvalidArgumentException', $message);
$this->expectException('Alchemy\TaskManager\Exception\InvalidArgumentException');
$this->expectExceptionMessage($message);
new LockFileSubscriber(null, $directory);
}

Expand Down
11 changes: 6 additions & 5 deletions tests/Alchemy/Test/TaskManager/Job/AbstractJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public function testEventsWithException()

public function testLoggerGettersAndSetters()
{
$logger = $this->getMock('Psr\Log\LoggerInterface');
$logger = $this->createMock('Psr\Log\LoggerInterface');

$job = new JobTest();
$this->assertSame(null, $job->getLogger());
Expand Down Expand Up @@ -176,7 +176,7 @@ public function testSingleRunRunsAndStop()

public function testAddAListener()
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$listener = array($this, 'testAddAListener');
$name = 'event-name';

Expand All @@ -190,8 +190,8 @@ public function testAddAListener()

public function testAddASubscriber()
{
$dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');
$dispatcher = $this->createMock('Symfony\Component\EventDispatcher\EventDispatcherInterface');
$subscriber = $this->createMock('Symfony\Component\EventDispatcher\EventSubscriberInterface');

$dispatcher->expects($this->once())
->method('addSubscriber')
Expand Down Expand Up @@ -270,7 +270,8 @@ public function testJobCanBeRestartedAfterAFailure()

}
$job = new JobFailureTest();
$this->setExpectedException('Alchemy\Test\TaskManager\Job\JobFailureException', 'Total failure.');
$this->expectException('Alchemy\Test\TaskManager\Job\JobFailureException');
$this->expectExceptionMessage('Total failure.');
$job->run();
}

Expand Down
5 changes: 4 additions & 1 deletion tests/Alchemy/Test/TaskManager/LockFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function testLockALockedFileShouldThrowAnException()
$this->assertFileExists($this->lockfile);

$lock2 = new LockFile($this->lockfile);
$this->setExpectedException('Alchemy\TaskManager\Exception\LockFailureException', sprintf('Unable to lock %s.', $this->lockfile));

$this->expectException('Alchemy\TaskManager\Exception\LockFailureException');
$this->expectExceptionMessage(sprintf('Unable to lock %s.', $this->lockfile));

$lock2->lock();
}

Expand Down
13 changes: 7 additions & 6 deletions tests/Alchemy/Test/TaskManager/TaskManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class TaskManagerTest extends TestCase
{
public function testThatItRunsWithoutAnyProcesses()
{
$taskList = $this->getMock('Alchemy\TaskManager\TaskListInterface');
$taskList = $this->createMock('Alchemy\TaskManager\TaskListInterface');
$taskList->expects($this->once())
->method('refresh')
->will($this->returnValue(array()));
Expand Down Expand Up @@ -166,9 +166,10 @@ public function testThatTwoTaskManagerCanNotRunOnSamePortAndHostAtTheSameTime()
$socket = new ZMQSocket(new \ZMQContext(), \ZMQ::SOCKET_REP, 'tcp', '127.0.0.1', 6660);
$socket->bind();

$taskList = $this->getMock('Alchemy\TaskManager\TaskListInterface');
$taskList = $this->createMock('Alchemy\TaskManager\TaskListInterface');
$manager = TaskManager::create(new EventDispatcher(), $this->createLoggerMock(), $taskList);
$this->setExpectedException('Alchemy\TaskManager\Exception\RuntimeException', 'Unable to bind socket to tcp://127.0.0.1:6660. Is another one already bound ?');
$this->expectException('Alchemy\TaskManager\Exception\RuntimeException');
$this->expectExceptionMessage('Unable to bind socket to tcp://127.0.0.1:6660. Is another one already bound ?');
$manager->start();
}

Expand Down Expand Up @@ -207,7 +208,7 @@ public function testASIGCONTIsRegularlyReceivedByPrograms()

public function testThatCallingStopTriggersAStopRequestEvent()
{
$taskList = $this->getMock('Alchemy\TaskManager\TaskListInterface');
$taskList = $this->createMock('Alchemy\TaskManager\TaskListInterface');
$taskList->expects($this->any())
->method('refresh')
->will($this->returnValue(array()));
Expand All @@ -228,7 +229,7 @@ public function testThatCallingStopTriggersAStopRequestEvent()

public function testThatRefreshIsCalledAsManyTimestheUpdateIsRequested()
{
$taskList = $this->getMock('Alchemy\TaskManager\TaskListInterface');
$taskList = $this->createMock('Alchemy\TaskManager\TaskListInterface');
$taskList->expects($this->exactly(7))
->method('refresh')
->will($this->returnValue(array()));
Expand Down Expand Up @@ -265,7 +266,7 @@ public function testThatRefreshIsCalledAsManyTimestheUpdateIsRequested()

private function createLoggerMock()
{
return $this->getMock('Psr\Log\LoggerInterface');
return $this->createMock('Psr\Log\LoggerInterface');
}

private function getTaskListImplementation()
Expand Down
6 changes: 3 additions & 3 deletions tests/Alchemy/Test/TaskManager/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

namespace Alchemy\Test\TaskManager;

abstract class TestCase extends \PHPUnit_Framework_TestCase
abstract class TestCase extends \PHPUnit\Framework\TestCase
{
public function createJobMock()
{
return $this->getMock('Alchemy\TaskManager\Job\JobInterface');
return $this->createMock('Alchemy\TaskManager\Job\JobInterface');
}

public function createDataMock()
{
return $this->getMock('Alchemy\TaskManager\Job\JobDataInterface');
return $this->createMock('Alchemy\TaskManager\Job\JobDataInterface');
}
}

0 comments on commit d1c3f2f

Please sign in to comment.