Skip to content

Commit 9b8ae69

Browse files
authored
adding phpstan-phpunit and make Tests folder to respect phpstan level 2 (#21)
1 parent fdde8f2 commit 9b8ae69

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

Tests/RabbitMq/AMQPConnectionFactoryTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use OldSound\RabbitMqBundle\RabbitMq\AMQPConnectionFactory;
77
use OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPConnection;
88
use OldSound\RabbitMqBundle\Tests\RabbitMq\Fixtures\AMQPSocketConnection;
9+
use PHPUnit\Framework\MockObject\MockObject;
910
use PHPUnit\Framework\TestCase;
1011

1112
class AMQPConnectionFactoryTest extends TestCase
@@ -335,7 +336,7 @@ public function testConnectionsParametersProvider()
335336
/**
336337
* Preparing ConnectionParametersProviderInterface instance
337338
*
338-
* @return \PHPUnit_Framework_MockObject_MockObject|ConnectionParametersProviderInterface
339+
* @return MockObject
339340
*/
340341
private function prepareConnectionParametersProvider()
341342
{

Tests/RabbitMq/BaseAmqpTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace OldSound\RabbitMqBundle\Tests\RabbitMq;
44

5+
use PHPUnit\Framework\MockObject\MockObject;
56
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
67
use OldSound\RabbitMqBundle\Event\AMQPEvent;
78
use OldSound\RabbitMqBundle\RabbitMq\BaseAmqp;
@@ -45,7 +46,7 @@ public function testNotLazyConnection()
4546

4647
public function testDispatchEvent()
4748
{
48-
/** @var BaseAmqp|\PHPUnit_Framework_MockObject_MockObject $baseAmqpConsumer */
49+
/** @var BaseAmqp|MockObject $baseAmqpConsumer */
4950
$baseAmqpConsumer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\BaseAmqp')
5051
->disableOriginalConstructor()
5152
->getMock();
@@ -76,9 +77,9 @@ public function testDispatchEvent()
7677
}
7778

7879
/**
79-
* @param $name
80-
* @param $obj
81-
* @param $params
80+
* @param string $name
81+
* @param MockObject $obj
82+
* @param array $params
8283
*
8384
* @return mixed
8485
*/

Tests/RabbitMq/BindingTest.php

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

55
use OldSound\RabbitMqBundle\RabbitMq\Binding;
66
use PHPUnit\Framework\Assert;
7+
use PHPUnit\Framework\MockObject\MockObject;
78
use PHPUnit\Framework\TestCase;
89

910
class BindingTest extends TestCase
@@ -15,7 +16,7 @@ protected function getBinding($amqpConnection, $amqpChannel)
1516
}
1617

1718
/**
18-
* @return \PHPUnit_Framework_MockObject_MockObject
19+
* @return MockObject
1920
*/
2021
protected function prepareAMQPConnection()
2122
{

Tests/RabbitMq/DynamicConsumerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
namespace OldSound\RabbitMqBundle\Tests\RabbitMq;
44

5+
use OldSound\RabbitMqBundle\Provider\QueueOptionsProviderInterface;
56
use OldSound\RabbitMqBundle\RabbitMq\DynamicConsumer;
7+
use PHPUnit\Framework\MockObject\MockObject;
68

79
class DynamicConsumerTest extends ConsumerTest
810
{
@@ -14,7 +16,7 @@ public function getConsumer($amqpConnection, $amqpChannel)
1416
/**
1517
* Preparing QueueOptionsProviderInterface instance
1618
*
17-
* @return \PHPUnit_Framework_MockObject_MockObject|QueueOptionsProviderInterface
19+
* @return MockObject|QueueOptionsProviderInterface
1820
*/
1921
private function prepareQueueOptionsProvider()
2022
{

Tests/RabbitMq/MultipleConsumerTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use PhpAmqpLib\Connection\AMQPConnection;
1010
use PhpAmqpLib\Message\AMQPMessage;
1111
use PHPUnit\Framework\Assert;
12+
use PHPUnit\Framework\MockObject\MockObject;
1213
use PHPUnit\Framework\TestCase;
1314

1415
class MultipleConsumerTest extends TestCase
@@ -23,14 +24,14 @@ class MultipleConsumerTest extends TestCase
2324
/**
2425
* AMQP channel
2526
*
26-
* @var \PHPUnit_Framework_MockObject_MockObject|AMQPChannel
27+
* @var MockObject|AMQPChannel
2728
*/
2829
private $amqpChannel;
2930

3031
/**
3132
* AMQP connection
3233
*
33-
* @var \PHPUnit_Framework_MockObject_MockObject|AMQPConnection
34+
* @var MockObject|AMQPConnection
3435
*/
3536
private $amqpConnection;
3637

@@ -202,7 +203,7 @@ public function processMessageProvider()
202203
/**
203204
* Preparing AMQP Connection
204205
*
205-
* @return \PHPUnit_Framework_MockObject_MockObject|AMQPConnection
206+
* @return MockObject|AMQPConnection
206207
*/
207208
private function prepareAMQPConnection()
208209
{
@@ -214,7 +215,7 @@ private function prepareAMQPConnection()
214215
/**
215216
* Preparing AMQP Connection
216217
*
217-
* @return \PHPUnit_Framework_MockObject_MockObject|AMQPChannel
218+
* @return MockObject|AMQPChannel
218219
*/
219220
private function prepareAMQPChannel()
220221
{
@@ -226,7 +227,7 @@ private function prepareAMQPChannel()
226227
/**
227228
* Preparing QueuesProviderInterface instance
228229
*
229-
* @return \PHPUnit_Framework_MockObject_MockObject|QueuesProviderInterface
230+
* @return MockObject|QueuesProviderInterface
230231
*/
231232
private function prepareQueuesProvider()
232233
{
@@ -237,8 +238,8 @@ private function prepareQueuesProvider()
237238
/**
238239
* Preparing AMQP Channel Expectations
239240
*
240-
* @param $expectedMethod
241-
* @param $expectedRequeue
241+
* @param mixed $expectedMethod
242+
* @param string $expectedRequeue
242243
*
243244
* @return void
244245
*/
@@ -261,7 +262,7 @@ private function prepareAMQPChannelExpectations($expectedMethod, $expectedRequeu
261262
/**
262263
* Prepare callback
263264
*
264-
* @param $processFlag
265+
* @param bool $processFlag
265266
* @return callable
266267
*/
267268
private function prepareCallback($processFlag)

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"symfony/yaml": "^4.3|^5.0",
1717
"symfony/console": "^4.3|^5.0",
1818
"php-amqplib/php-amqplib": "^2.6",
19-
"psr/log": "^1.0"
19+
"psr/log": "^1.0",
20+
"phpstan/phpstan-phpunit": "^0.12.6"
2021
},
2122
"require-dev": {
2223
"symfony/serializer": "^4.3|^5.0",

phpstan.neon.dist

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
includes:
2+
- vendor/phpstan/phpstan-phpunit/extension.neon
3+
- vendor/phpstan/phpstan-phpunit/rules.neon
14
parameters:
25
level: 1
36
paths:

0 commit comments

Comments
 (0)