@@ -47,16 +47,22 @@ class QueueTestCaseAbstract extends \PHPUnit\Framework\TestCase
4747 */
4848 protected $ publisherConsumerController ;
4949
50+ /**
51+ * @inheritdoc
52+ */
5053 protected function setUp ()
5154 {
5255 $ this ->objectManager = Bootstrap::getObjectManager ();
5356 $ 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+ );
6066
6167 try {
6268 $ this ->publisherConsumerController ->initialize ();
@@ -70,6 +76,9 @@ protected function setUp()
7076 $ this ->publisher = $ this ->publisherConsumerController ->getPublisher ();
7177 }
7278
79+ /**
80+ * @inheritdoc
81+ */
7382 protected function tearDown ()
7483 {
7584 $ this ->publisherConsumerController ->stopConsumers ();
@@ -85,24 +94,32 @@ protected function waitForAsynchronousResult($expectedLinesCount, $logFilePath)
8594 {
8695 try {
8796 //$expectedLinesCount, $logFilePath
88- $ this ->publisherConsumerController ->waitForAsynchronousResult ([$ this , 'checkLogsExists ' ], [
89- $ expectedLinesCount , $ logFilePath
90- ]);
97+ $ this ->publisherConsumerController ->waitForAsynchronousResult (
98+ [$ this , 'checkLogsExists ' ],
99+ [$ expectedLinesCount , $ logFilePath ]
100+ );
91101 } catch (PreconditionFailedException $ e ) {
92102 $ this ->fail ($ e ->getMessage ());
93103 }
94104 }
95105
106+ /**
107+ * Checks that logs exist
108+ *
109+ * @param int $expectedLinesCount
110+ * @return bool
111+ */
96112 public function checkLogsExists ($ expectedLinesCount )
97113 {
114+ //phpcs:ignore Magento2.Functions.DiscouragedFunction
98115 $ actualCount = file_exists ($ this ->logFilePath ) ? count (file ($ this ->logFilePath )) : 0 ;
99116 return $ expectedLinesCount === $ actualCount ;
100117 }
101118
102119 /**
103120 * Workaround for https://bugs.php.net/bug.php?id=72286
104121 */
105- public static function tearDownAfterClass ()
122+ public function tearDownAfterClass ()
106123 {
107124 if (version_compare (phpversion (), '7 ' ) == -1 ) {
108125 $ closeConnection = new \ReflectionMethod (\Magento \Amqp \Model \Config::class, 'closeConnection ' );
0 commit comments