2
2
3
3
namespace Markup \JobQueueBundle \Tests \Publisher ;
4
4
5
+ use Markup \JobQueueBundle \Exception \UndefinedProducerException ;
5
6
use Markup \JobQueueBundle \Job \BadJob ;
6
7
use Markup \JobQueueBundle \Publisher \JobPublisher ;
7
8
use Markup \JobQueueBundle \Repository \JobLogRepository ;
8
9
use Mockery as m ;
10
+ use Mockery \Adapter \Phpunit \MockeryTestCase ;
9
11
use OldSound \RabbitMqBundle \RabbitMq \ProducerInterface ;
10
12
use Psr \Log \NullLogger ;
11
- use Symfony \Component \DependencyInjection \Container ;
13
+ use Symfony \Component \DependencyInjection \ContainerInterface ;
12
14
13
- class JobPublisherTest extends \PHPUnit_Framework_TestCase
15
+ class JobPublisherTest extends MockeryTestCase
14
16
{
15
-
16
17
/**
17
- * @var Container
18
+ * @var ContainerInterface
18
19
*/
19
20
private $ container ;
20
21
@@ -28,12 +29,12 @@ class JobPublisherTest extends \PHPUnit_Framework_TestCase
28
29
*/
29
30
private $ producer ;
30
31
31
- public function setUp ()
32
+ protected function setUp ()
32
33
{
33
34
$ this ->producer = m::mock ('SimpleBus\RabbitMQBundle\RabbitMQPublisher ' );
34
35
$ this ->jobLogRepository = m::mock (JobLogRepository::class);
35
36
$ this ->producer ->shouldReceive ('setContentType ' )->andReturn (null );
36
- $ this ->container = m::mock (' Symfony\Component\DependencyInjection\ ContainerInterface' );
37
+ $ this ->container = m::mock (ContainerInterface::class );
37
38
$ this ->container ->shouldReceive ('has ' )->with ('old_sound_rabbit_mq.test_producer ' )->andReturn (true );
38
39
$ this ->container ->shouldReceive ('get ' )->with ('old_sound_rabbit_mq.test_producer ' )->andReturn ($ this ->producer );
39
40
$ this ->container ->shouldReceive ('has ' )->with ('old_sound_rabbit_mq.nonsense_producer ' )->andReturn (false );
@@ -42,7 +43,7 @@ public function setUp()
42
43
43
44
public function testPublishingJobWithInvalidTopicThrowsException ()
44
45
{
45
- $ this ->setExpectedException ( ' Markup\JobQueueBundle\Exception\ UndefinedProducerException' );
46
+ $ this ->expectException ( UndefinedProducerException::class );
46
47
$ job = new BadJob ([], 'nonsense ' );
47
48
$ publisher = new JobPublisher ($ this ->jobLogRepository , new NullLogger ());
48
49
$ publisher ->setContainer ($ this ->container );
@@ -57,9 +58,4 @@ public function testCanPublish()
57
58
$ this ->producer ->shouldReceive ('publish ' )->once ()->andReturn (null );
58
59
$ publisher ->publish ($ job );
59
60
}
60
-
61
- public function tearDown ()
62
- {
63
- m::close ();
64
- }
65
61
}
0 commit comments