Skip to content

Commit 33f9ba1

Browse files
Douglas Greenshieldsshieldo
authored andcommitted
chore: use phpunit 7
1 parent 37514f3 commit 33f9ba1

7 files changed

+29
-63
lines changed

Tests/Model/RecurringConsoleCommandConfigurationTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
namespace Markup\Bundle\JobQueueBundle\Tests\Service;
44

55
use Markup\JobQueueBundle\Model\RecurringConsoleCommandConfiguration;
6-
use Mockery as m;
6+
use PHPUnit\Framework\TestCase;
77

8-
class RecurringConsoleCommandConfigurationTest extends \PHPUnit_Framework_TestCase
8+
class RecurringConsoleCommandConfigurationTest extends TestCase
99
{
10-
public function setUp()
11-
{
12-
}
13-
1410
public function testCanBeConstructed()
1511
{
1612
$config = new RecurringConsoleCommandConfiguration('foo:bar', 'test', '30 1 * * *', 'a short description');
@@ -19,9 +15,4 @@ public function testCanBeConstructed()
1915
$this->assertEquals($config->getSchedule(), '30 1 * * *');
2016
$this->assertEquals($config->getDescription(), 'a short description');
2117
}
22-
23-
public function tearDown()
24-
{
25-
m::close();
26-
}
2718
}

Tests/Publisher/JobPublisherTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
namespace Markup\JobQueueBundle\Tests\Publisher;
44

5+
use Markup\JobQueueBundle\Exception\UndefinedProducerException;
56
use Markup\JobQueueBundle\Job\BadJob;
67
use Markup\JobQueueBundle\Publisher\JobPublisher;
78
use Markup\JobQueueBundle\Repository\JobLogRepository;
89
use Mockery as m;
10+
use Mockery\Adapter\Phpunit\MockeryTestCase;
911
use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
1012
use Psr\Log\NullLogger;
11-
use Symfony\Component\DependencyInjection\Container;
13+
use Symfony\Component\DependencyInjection\ContainerInterface;
1214

13-
class JobPublisherTest extends \PHPUnit_Framework_TestCase
15+
class JobPublisherTest extends MockeryTestCase
1416
{
15-
1617
/**
17-
* @var Container
18+
* @var ContainerInterface
1819
*/
1920
private $container;
2021

@@ -28,12 +29,12 @@ class JobPublisherTest extends \PHPUnit_Framework_TestCase
2829
*/
2930
private $producer;
3031

31-
public function setUp()
32+
protected function setUp()
3233
{
3334
$this->producer = m::mock('SimpleBus\RabbitMQBundle\RabbitMQPublisher');
3435
$this->jobLogRepository = m::mock(JobLogRepository::class);
3536
$this->producer->shouldReceive('setContentType')->andReturn(null);
36-
$this->container = m::mock('Symfony\Component\DependencyInjection\ContainerInterface');
37+
$this->container = m::mock(ContainerInterface::class);
3738
$this->container->shouldReceive('has')->with('old_sound_rabbit_mq.test_producer')->andReturn(true);
3839
$this->container->shouldReceive('get')->with('old_sound_rabbit_mq.test_producer')->andReturn($this->producer);
3940
$this->container->shouldReceive('has')->with('old_sound_rabbit_mq.nonsense_producer')->andReturn(false);
@@ -42,7 +43,7 @@ public function setUp()
4243

4344
public function testPublishingJobWithInvalidTopicThrowsException()
4445
{
45-
$this->setExpectedException('Markup\JobQueueBundle\Exception\UndefinedProducerException');
46+
$this->expectException(UndefinedProducerException::class);
4647
$job = new BadJob([], 'nonsense');
4748
$publisher = new JobPublisher($this->jobLogRepository, new NullLogger());
4849
$publisher->setContainer($this->container);
@@ -57,9 +58,4 @@ public function testCanPublish()
5758
$this->producer->shouldReceive('publish')->once()->andReturn(null);
5859
$publisher->publish($job);
5960
}
60-
61-
public function tearDown()
62-
{
63-
m::close();
64-
}
6561
}

Tests/Service/CliConsumerConfigFileWriterTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
namespace Markup\Bundle\JobQueueBundle\Tests\Service;
44

55
use Markup\JobQueueBundle\Service\CliConsumerConfigFileWriter;
6-
use Mockery as m;
6+
use PHPUnit\Framework\TestCase;
77

8-
class CliConsumerConfigFileWriterTest extends \PHPUnit_Framework_TestCase
8+
class CliConsumerConfigFileWriterTest extends TestCase
99
{
10-
public function setUp()
11-
{
12-
13-
}
14-
1510
public function testCreatesCorrectConfigString()
1611
{
1712
$writer = new CliConsumerConfigFileWriter(
@@ -30,9 +25,4 @@ public function testCreatesCorrectConfigString()
3025

3126
$this->assertEquals($fixture, $config);
3227
}
33-
34-
public function tearDown()
35-
{
36-
m::close();
37-
}
3828
}

Tests/Service/JobManagerTest.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,19 @@
33
namespace Markup\Bundle\JobQueueBundle\Tests\Service;
44

55
use Markup\JobQueueBundle\Job\SleepJob;
6+
use Markup\JobQueueBundle\Publisher\JobPublisher;
67
use Markup\JobQueueBundle\Service\JobManager;
8+
use Markup\JobQueueBundle\Service\ScheduledJobService;
79
use Mockery as m;
10+
use Mockery\Adapter\Phpunit\MockeryTestCase;
11+
use PHPUnit\Framework\Error\Error;
812

9-
class JobManagerTest extends \PHPUnit_Framework_TestCase
13+
class JobManagerTest extends MockeryTestCase
1014
{
11-
public function setUp()
15+
protected function setUp()
1216
{
13-
$jobPublisher = m::mock('Markup\JobQueueBundle\Publisher\JobPublisher');
14-
$scheduledJob = m::mock('Markup\JobQueueBundle\Service\ScheduledJobService');
17+
$jobPublisher = m::mock(JobPublisher::class);
18+
$scheduledJob = m::mock(ScheduledJobService::class);
1519
$jobPublisher->shouldReceive('publish')->andReturn(null);
1620
$scheduledJob->shouldReceive('addScheduledJob')->andReturn(null);
1721
$this->jobManager = new JobManager($jobPublisher, $scheduledJob);
@@ -31,7 +35,7 @@ public function testDoesNotAcceptBadJobs()
3135
$exceptionThrown = false;
3236
try {
3337
$this->jobManager->addJob($badjob);
34-
} catch (\PHPUnit_Framework_Error $e) {
38+
} catch (Error $e) {
3539
$exceptionThrown = true;
3640
} catch (\TypeError $e) {
3741
$exceptionThrown = true;
@@ -45,9 +49,4 @@ public function testCanAddCommandJob()
4549
{
4650
$this->assertNull($this->jobManager->addCommandJob('console:herp:derp', 'system', 60, 60));
4751
}
48-
49-
public function tearDown()
50-
{
51-
m::close();
52-
}
5352
}

Tests/Service/ScheduledJobServiceTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
use Markup\JobQueueBundle\Service\ScheduledJobService;
1111
use Mockery as m;
1212
use Markup\JobQueueBundle\Model\ScheduledJobRepositoryInterface;
13+
use Mockery\Adapter\Phpunit\MockeryTestCase;
1314

14-
class ScheduledJobServiceTest extends \PHPUnit_Framework_TestCase
15+
class ScheduledJobServiceTest extends MockeryTestCase
1516
{
1617
private $doctrine;
1718

18-
public function setUp()
19+
protected function setUp()
1920
{
20-
2121
$scheduledJobRepository = m::mock(ScheduledJobRepositoryInterface::class);
2222
$scheduledJobRepository->shouldReceive('save');
2323

@@ -43,9 +43,4 @@ public function testCanAddScheduledJob()
4343

4444
$this->assertEquals($this->scheduledJobService->addScheduledJob($job, $scheduledTime), $scheduledJob);
4545
}
46-
47-
public function tearDown()
48-
{
49-
m::close();
50-
}
5146
}

Tests/Service/SupervisordConfigFileWriterTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace Markup\Bundle\JobQueueBundle\Tests\Service;
44

55
use Markup\JobQueueBundle\Service\SupervisordConfigFileWriter;
6-
use Mockery as m;
6+
use PHPUnit\Framework\TestCase;
77

8-
class SupervisordConfigFileWriterTest extends \PHPUnit_Framework_TestCase
8+
class SupervisordConfigFileWriterTest extends TestCase
99
{
10-
public function setUp()
10+
protected function setUp()
1111
{
1212
$this->writer = new SupervisordConfigFileWriter(
1313
'/vagrant/app',
@@ -40,9 +40,4 @@ public function testWritesPhpConfiguration()
4040

4141
$this->assertEquals($fixture, $config);
4242
}
43-
44-
public function tearDown()
45-
{
46-
m::close();
47-
}
4843
}

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
"markup/rabbitmq-management-api": ">=2.1.1"
3131
},
3232
"require-dev": {
33-
"phpunit/phpunit": "~4.5",
34-
"mockery/mockery": "~0.9",
33+
"phpunit/phpunit": "^7.2",
34+
"mockery/mockery": "^1.2",
3535
"symfony/form": "~2.3|^3",
3636
"predis/predis": "^1.0"
3737
},

0 commit comments

Comments
 (0)