Skip to content

Commit 1d1d12a

Browse files
drpayyneandrewbess
authored andcommitted
Fixed tests
1 parent 3b76992 commit 1d1d12a

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

tests/Unit/Console/Command/CompareSourceCommandTest/AbstractHtmlTestCaseForHtml.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77

8+
declare(strict_types=1);
9+
810
namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest;
911

1012
use DOMDocument;
@@ -33,13 +35,13 @@ abstract class AbstractHtmlTestCaseForHtml extends TestCase
3335
*/
3436
protected $svcLogPath;
3537

36-
protected function setUp()
38+
protected function setUp(): void
3739
{
3840
$this->command = new CompareSourceCommand();
3941
$this->svcLogPath = TESTS_TEMP_DIR . '/svc-' . time() . '.html';
4042
}
4143

42-
protected function tearDown()
44+
protected function tearDown(): void
4345
{
4446
parent::tearDown();
4547
unlink($this->svcLogPath);
@@ -82,7 +84,7 @@ protected function doTestExecute(
8284
foreach ($expectedHtmlEntries as $expectedHtmlEntry) {
8385
$this->assertHtml($expectedHtmlEntry->xpath, $expectedHtmlEntry->pattern, $svcDom);
8486
}
85-
$this->assertContains($expectedOutput, $commandTester->getDisplay());
87+
$this->assertStringContainsString($expectedOutput, $commandTester->getDisplay());
8688
$this->assertEquals($expectedStatusCode, $commandTester->getStatusCode());
8789
} catch (Exception $e) {
8890
if ($shouldSkipTest) {
@@ -137,11 +139,11 @@ public static function assertHtml($xpathQuery, $regex, DOMDocument $docDom)
137139
}
138140
if ($regex) {
139141
$body = $docDom->saveHTML($nodeList->item(0));
140-
static::assertRegExp($regex, $body);
142+
static::assertMatchesRegularExpression($regex, $body);
141143
}
142144
} else {
143145
$body = $docXpath->document->saveHTML();
144-
static::assertRegExp($regex, $body);
146+
static::assertMatchesRegularExpression($regex, $body);
145147
}
146148
}
147149

tests/Unit/Console/Command/CompareSourceCommandTest/AbstractTestCase.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77

8+
declare(strict_types=1);
9+
810
namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest;
911

1012
use Magento\SemanticVersionChecker\Console\Command\CompareSourceCommand;
@@ -27,13 +29,13 @@ abstract class AbstractTestCase extends TestCase
2729
*/
2830
protected $svcLogPath;
2931

30-
protected function setUp()
32+
protected function setUp(): void
3133
{
3234
$this->command = new CompareSourceCommand();
3335
$this->svcLogPath = TESTS_TEMP_DIR . '/svc-' . time() . '.log';
3436
}
3537

36-
protected function tearDown()
38+
protected function tearDown(): void
3739
{
3840
parent::tearDown();
3941
unlink($this->svcLogPath);
@@ -66,20 +68,20 @@ protected function doTestExecute(
6668
$preparedSvcLogContents = preg_replace('/\s+/', '', $actualSvcLogContents);
6769

6870
foreach ($expectedLogEntries as $expectedLogEntry) {
69-
$this->assertContains(
71+
$this->assertStringContainsString(
7072
preg_replace('/\s+/', '', $expectedLogEntry),
7173
$preparedSvcLogContents,
7274
'Failed asserting that "' . $actualSvcLogContents . '" contains "' . $expectedLogEntry . '"'
7375
);
7476
}
7577
foreach ($unexpectedLogEntries as $unexpectedLogEntry) {
76-
$this->assertNotContains(
78+
$this->assertStringNotContainsString(
7779
preg_replace('/\s+/', '', $unexpectedLogEntry),
7880
$preparedSvcLogContents,
7981
'Failed asserting that "' . $actualSvcLogContents . '" doesn\'t contain "' . $unexpectedLogEntry . '"'
8082
);
8183
}
82-
$this->assertContains($expectedOutput, $commandTester->getDisplay());
84+
$this->assertStringContainsString($expectedOutput, $commandTester->getDisplay());
8385
$this->assertEquals(0, $commandTester->getStatusCode());
8486
}
8587

tests/Unit/Console/Command/CompareSourceCommandTest/AbstractTestCaseWithRegExp.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
* See COPYING.txt for license details.
66
*/
77

8+
declare(strict_types=1);
9+
810
namespace Magento\SemanticVersionChecker\Test\Unit\Console\Command\CompareSourceCommandTest;
911

1012
use Exception;
@@ -28,13 +30,13 @@ abstract class AbstractTestCaseWithRegExp extends TestCase
2830
*/
2931
protected $svcLogPath;
3032

31-
protected function setUp()
33+
protected function setUp(): void
3234
{
3335
$this->command = new CompareSourceCommand();
3436
$this->svcLogPath = TESTS_TEMP_DIR . '/svc-' . time() . '.log';
3537
}
3638

37-
protected function tearDown()
39+
protected function tearDown(): void
3840
{
3941
parent::tearDown();
4042
unlink($this->svcLogPath);
@@ -67,9 +69,9 @@ protected function doTestExecute(
6769
$actualSvcLogContents = $this->getActualSvcLogContents();
6870

6971
foreach ($expectedLogEntries as $expectedLogEntry) {
70-
$this->assertRegExp($expectedLogEntry, $actualSvcLogContents);
72+
$this->assertMatchesRegularExpression($expectedLogEntry, $actualSvcLogContents);
7173
}
72-
$this->assertContains($expectedOutput, $commandTester->getDisplay());
74+
$this->assertStringContainsString($expectedOutput, $commandTester->getDisplay());
7375
$this->assertEquals(0, $commandTester->getStatusCode());
7476
} catch (Exception $e) {
7577
if ($shouldSkipTest) {

tests/Unit/Helper/ClassParserTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testImplementsAlias()
3232
$parser = new ClassParser($path);
3333
$result = $parser->getImplementedInterfacesNames();
3434
$this->assertCount(1, $result);
35-
$this->assertArraySubset(['Test\VcsA\A\InterfaceA'], $parser->getImplementedInterfacesNames());
35+
$this->assertContains('Test\VcsA\A\InterfaceA', $parser->getImplementedInterfacesNames());
3636
}
3737

3838
public function testImplementsFull()
@@ -41,6 +41,6 @@ public function testImplementsFull()
4141
$parser = new ClassParser($path);
4242
$result = $parser->getImplementedInterfacesNames();
4343
$this->assertCount(1, $result);
44-
$this->assertArraySubset(['Test\VcsA\A\InterfaceA'], $parser->getImplementedInterfacesNames());
44+
$this->assertContains('Test\VcsA\A\InterfaceA', $parser->getImplementedInterfacesNames());
4545
}
4646
}

0 commit comments

Comments
 (0)