@@ -47,16 +47,22 @@ class QueueTestCaseAbstract extends \PHPUnit\Framework\TestCase
47
47
*/
48
48
protected $ publisherConsumerController ;
49
49
50
+ /**
51
+ * @inheritdoc
52
+ */
50
53
protected function setUp ()
51
54
{
52
55
$ this ->objectManager = Bootstrap::getObjectManager ();
53
56
$ this ->logFilePath = TESTS_TEMP_DIR . "/MessageQueueTestLog.txt " ;
54
- $ this ->publisherConsumerController = $ this ->objectManager ->create (PublisherConsumerController::class, [
55
- 'consumers ' => $ this ->consumers ,
56
- 'logFilePath ' => $ this ->logFilePath ,
57
- 'maxMessages ' => $ this ->maxMessages ,
58
- 'appInitParams ' => \Magento \TestFramework \Helper \Bootstrap::getInstance ()->getAppInitParams ()
59
- ]);
57
+ $ this ->publisherConsumerController = $ this ->objectManager ->create (
58
+ PublisherConsumerController::class,
59
+ [
60
+ 'consumers ' => $ this ->consumers ,
61
+ 'logFilePath ' => $ this ->logFilePath ,
62
+ 'maxMessages ' => $ this ->maxMessages ,
63
+ 'appInitParams ' => \Magento \TestFramework \Helper \Bootstrap::getInstance ()->getAppInitParams ()
64
+ ]
65
+ );
60
66
61
67
try {
62
68
$ this ->publisherConsumerController ->initialize ();
@@ -70,6 +76,9 @@ protected function setUp()
70
76
$ this ->publisher = $ this ->publisherConsumerController ->getPublisher ();
71
77
}
72
78
79
+ /**
80
+ * @inheritdoc
81
+ */
73
82
protected function tearDown ()
74
83
{
75
84
$ this ->publisherConsumerController ->stopConsumers ();
@@ -85,24 +94,32 @@ protected function waitForAsynchronousResult($expectedLinesCount, $logFilePath)
85
94
{
86
95
try {
87
96
//$expectedLinesCount, $logFilePath
88
- $ this ->publisherConsumerController ->waitForAsynchronousResult ([$ this , 'checkLogsExists ' ], [
89
- $ expectedLinesCount , $ logFilePath
90
- ]);
97
+ $ this ->publisherConsumerController ->waitForAsynchronousResult (
98
+ [$ this , 'checkLogsExists ' ],
99
+ [$ expectedLinesCount , $ logFilePath ]
100
+ );
91
101
} catch (PreconditionFailedException $ e ) {
92
102
$ this ->fail ($ e ->getMessage ());
93
103
}
94
104
}
95
105
106
+ /**
107
+ * Checks that logs exist
108
+ *
109
+ * @param int $expectedLinesCount
110
+ * @return bool
111
+ */
96
112
public function checkLogsExists ($ expectedLinesCount )
97
113
{
114
+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
98
115
$ actualCount = file_exists ($ this ->logFilePath ) ? count (file ($ this ->logFilePath )) : 0 ;
99
116
return $ expectedLinesCount === $ actualCount ;
100
117
}
101
118
102
119
/**
103
120
* Workaround for https://bugs.php.net/bug.php?id=72286
104
121
*/
105
- public static function tearDownAfterClass ()
122
+ public function tearDownAfterClass ()
106
123
{
107
124
if (version_compare (phpversion (), '7 ' ) == -1 ) {
108
125
$ closeConnection = new \ReflectionMethod (\Magento \Amqp \Model \Config::class, 'closeConnection ' );
0 commit comments