Skip to content

Commit

Permalink
Merge 7dc596d into fb543d8
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Nov 30, 2020
2 parents fb543d8 + 7dc596d commit cb92a64
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 64 deletions.
4 changes: 4 additions & 0 deletions easy-coding-standard.yaml
Expand Up @@ -19,3 +19,7 @@ parameters:
- 'src-tests/coverage/*'
- 'src-tests/FunctionalTests/logs/coverage/*'
- 'src-tests/Utils/Annotations/Fixtures/*'

services:
PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff:
absoluteLineLimit: 120 # To enforce line length limit
4 changes: 3 additions & 1 deletion src-tests/Component/LegacyTest.php
Expand Up @@ -229,6 +229,8 @@ public function testShouldAutomaticallySaveAndLoadLegacyForMethodsWithSameNameIn

return;
}
$this->fail('Expected exception LegacyComponentException not thrown when loading Legacy that should not exists');
$this->fail(
'Expected exception LegacyComponentException not thrown when loading Legacy that should not exists'
);
}
}
2 changes: 1 addition & 1 deletion src-tests/Console/Command/GenerateTimelineCommandTest.php
Expand Up @@ -76,6 +76,6 @@ public function testShouldOutputHtmlFileWithJsonData(): void
$output = $this->tester->getDisplay();

$this->assertSame(0, $this->tester->getStatusCode());
$this->assertContains('[OK] Timeline generated to file "/foo/bar.html"', $output);
$this->assertStringContainsString('[OK] Timeline generated to file "/foo/bar.html"', $output);
}
}
31 changes: 17 additions & 14 deletions src-tests/Console/Command/InstallCommandTest.php
Expand Up @@ -52,12 +52,12 @@ public function testShouldDownloadWithoutAskingForInputWhenVersionIsDefinedAsOpt
);

$output = $this->tester->getDisplay();
$this->assertContains('Downloading Selenium standalone server version 6.3.6...', $output);
$this->assertContains(
$this->assertStringContainsString('Downloading Selenium standalone server version 6.3.6...', $output);
$this->assertStringContainsString(
'Download URL: https://selenium-release.storage.googleapis.com/6.3/selenium-server-standalone-6.3.6.jar',
$output
);
$this->assertContains('Downloaded 2 MB, file saved successfully.', $this->tester->getDisplay());
$this->assertStringContainsString('Downloaded 2 MB, file saved successfully.', $this->tester->getDisplay());

$this->assertSame(0, $this->tester->getStatusCode());
}
Expand All @@ -79,11 +79,11 @@ public function testShouldDownloadLatestVersionIfUserDoesNotEnterItsOwn(): void

$output = $this->tester->getDisplay();

$this->assertContains('Enter Selenium server version to install [2.34.5]:', $output);
$this->assertStringContainsString('Enter Selenium server version to install [2.34.5]:', $output);

// Check latest version was downloaded
$this->assertContains('Downloading Selenium standalone server version 2.34.5...', $output);
$this->assertContains(
$this->assertStringContainsString('Downloading Selenium standalone server version 2.34.5...', $output);
$this->assertStringContainsString(
'Download URL: https://selenium-release.storage.googleapis.com/2.34/selenium-server-standalone-2.34.5.jar',
$output
);
Expand All @@ -107,8 +107,8 @@ public function testShouldDownloadVersionEnteredByUser(): void

// Check custom version was downloaded
$output = $this->tester->getDisplay();
$this->assertContains('Downloading Selenium standalone server version 1.33.7...', $output);
$this->assertContains(
$this->assertStringContainsString('Downloading Selenium standalone server version 1.33.7...', $output);
$this->assertStringContainsString(
'Download URL: https://selenium-release.storage.googleapis.com/1.33/selenium-server-standalone-1.33.7.jar',
$output
);
Expand All @@ -133,9 +133,12 @@ public function testShouldRequireVersionToBeEnteredIfLastVersionCheckFails(): vo
);

$output = $this->tester->getDisplay();
$this->assertContains('Enter Selenium server version to install:', $output);
$this->assertContains('Please provide version to download (latest version auto-detect failed)', $output);
$this->assertContains('Downloading Selenium standalone server version 6.6.6...', $output);
$this->assertStringContainsString('Enter Selenium server version to install:', $output);
$this->assertStringContainsString(
'Please provide version to download (latest version auto-detect failed)',
$output
);
$this->assertStringContainsString('Downloading Selenium standalone server version 6.6.6...', $output);
}

public function testShouldThrowAnExceptionInNonInteractiveModeIfLastVersionCheckFailsAndNoVersionWasProvided(): void
Expand Down Expand Up @@ -173,7 +176,7 @@ public function testShouldOutputOnlyFilePathInNonInteractiveModeAndDownloadVersi

$output = $this->tester->getDisplay();
$this->assertEquals(realpath($filePath) . PHP_EOL, $output);
$this->assertContains('6.33.6', $output);
$this->assertStringContainsString('6.33.6', $output);
$this->assertSame(0, $this->tester->getStatusCode());
}

Expand All @@ -191,7 +194,7 @@ public function testShouldOutputOnlyFilePathInNonInteractiveModeAndDownloadLates
);

$this->assertEquals(realpath($filePath) . PHP_EOL, $this->tester->getDisplay());
$this->assertContains('2.34.5', $this->tester->getDisplay());
$this->assertStringContainsString('2.34.5', $this->tester->getDisplay());
$this->assertSame(0, $this->tester->getStatusCode());
}

Expand All @@ -206,7 +209,7 @@ public function testShouldNotDownloadTheFileAgainIfAlreadyExists(): void

$this->tester->execute(['command' => $this->command->getName(), 'version' => '2.34.5']);

$this->assertContains(
$this->assertStringContainsString(
'File "selenium-server-standalone-2.34.5.jar" already exists',
$this->tester->getDisplay()
);
Expand Down
9 changes: 6 additions & 3 deletions src-tests/Console/Command/ResultsCommandTest.php
Expand Up @@ -92,14 +92,17 @@ public function testShouldOutputRunningTimeOfStartedTest(): void
$output = $this->tester->getDisplay();

$this->assertSame(0, $this->tester->getStatusCode());
$this->assertContains('| - testBanStarted | started | | 2016-04-29 12:33:33 | |', $output);
$this->assertStringContainsString(
'| - testBanStarted | started | | 2016-04-29 12:33:33 | |',
$output
);
$this->assertRegExp('/| \d+ sec/', $output);

$this->assertContains(
$this->assertStringContainsString(
'Testcases (1 total): prepared: 1, running: 0, done: 0 (passed: 0, failed: 0, fatal: 0',
$output
);
$this->assertContains(
$this->assertStringContainsString(
'Tests (1 so far): started: 1, done: 0 (passed: 0, failed or broken: 0, skipped or incomplete: 0)',
$output
);
Expand Down
30 changes: 18 additions & 12 deletions src-tests/Console/Command/RunCommandTest.php
Expand Up @@ -130,8 +130,8 @@ public function testShouldOutputAssembledPathsToDirectoriesInDebugMode(): void
);

$output = $this->tester->getDisplay();
$this->assertContains('Path to logs: ' . realpath(__DIR__) . '/Fixtures/logs', $output);
$this->assertContains(' - in directory "' . realpath(__DIR__) . '/Fixtures/DummyTests"', $output);
$this->assertStringContainsString('Path to logs: ' . realpath(__DIR__) . '/Fixtures/logs', $output);
$this->assertStringContainsString(' - in directory "' . realpath(__DIR__) . '/Fixtures/DummyTests"', $output);
$this->assertSame(1, $this->tester->getStatusCode());
}

Expand Down Expand Up @@ -163,8 +163,8 @@ public function testShouldThrowExceptionOnlyIfUnsupportedBrowserSelected(

if (!$shouldThrowException) {
$output = $this->tester->getDisplay();
$this->assertContains('Browser: ' . $expectedNameInOutput, $output);
$this->assertContains('No testcases found, exiting.', $output);
$this->assertStringContainsString('Browser: ' . $expectedNameInOutput, $output);
$this->assertStringContainsString('No testcases found, exiting.', $output);
}
}

Expand Down Expand Up @@ -210,8 +210,11 @@ public function testShouldStopIfServerIsNotResponding(): void
]
);

$this->assertContains('Error connecting to Selenium server ("Foo Bar Error")', $this->tester->getDisplay());
$this->assertContains(
$this->assertStringContainsString(
'Error connecting to Selenium server ("Foo Bar Error")',
$this->tester->getDisplay()
);
$this->assertStringContainsString(
'Make sure your Selenium server is really accessible on url "http://foo.bar:1337"',
$this->tester->getDisplay()
);
Expand Down Expand Up @@ -248,8 +251,11 @@ public function testShouldStopIfServerIsRespondingButIsNotSelenium(): void
]
);

$this->assertContains('Unexpected response from Selenium server (This is teapot)', $this->tester->getDisplay());
$this->assertContains(
$this->assertStringContainsString(
'Unexpected response from Selenium server (This is teapot)',
$this->tester->getDisplay()
);
$this->assertStringContainsString(
'URL "http://foo.bar:1337" is occupied by something else than Selenium server.',
$this->tester->getDisplay()
);
Expand All @@ -272,8 +278,8 @@ public function testShouldStopIfNoTestcasesFoundByGivenFilePattern(): void
['verbosity' => OutputInterface::VERBOSITY_DEBUG]
);

$this->assertContains('by pattern "NotExisting.foo"', $this->tester->getDisplay());
$this->assertContains('No testcases found, exiting.', $this->tester->getDisplay());
$this->assertStringContainsString('by pattern "NotExisting.foo"', $this->tester->getDisplay());
$this->assertStringContainsString('No testcases found, exiting.', $this->tester->getDisplay());
$this->assertSame(1, $this->tester->getStatusCode());
}

Expand Down Expand Up @@ -343,7 +349,7 @@ public function testShouldStopIfNoTestcasesWereFoundInTheFiles(): void
]
);

$this->assertContains('No testcases matched given groups, exiting.', $this->tester->getDisplay());
$this->assertStringContainsString('No testcases matched given groups, exiting.', $this->tester->getDisplay());
$this->assertSame(1, $this->tester->getStatusCode());
}

Expand Down Expand Up @@ -383,7 +389,7 @@ public function testShouldExitSuccessfullyIfNoProcessArePreparedOrQueued(): void
]
);

$this->assertContains('Testcases executed: 0', $this->tester->getDisplay());
$this->assertStringContainsString('Testcases executed: 0', $this->tester->getDisplay());
$this->assertSame(0, $this->tester->getStatusCode());
}

Expand Down
2 changes: 1 addition & 1 deletion src-tests/Console/EventListener/XdebugListenerTest.php
Expand Up @@ -96,7 +96,7 @@ public function testShouldGetIdeKeyFromCommandOptionOnCommandInitialization(
$this->listener->onCommandRunTestsInit($event);

if ($expectedIdeKey !== null) {
$this->assertContains(
$this->assertStringContainsString(
'Xdebug remote debugging initialized with IDE key: ' . $expectedIdeKey,
$output->fetch()
);
Expand Down
2 changes: 1 addition & 1 deletion src-tests/Console/Style/StewardStyleTest.php
Expand Up @@ -42,7 +42,7 @@ public function testShouldFormatRunStatusWithTimestamp(string $method): void

$output = $this->outputBuffer->fetch();
$this->assertRegExp('/\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\]/', $output);
$this->assertContains('Foo bar', $output);
$this->assertStringContainsString('Foo bar', $output);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions src-tests/Listener/SnapshotListenerTest.php
Expand Up @@ -146,7 +146,10 @@ public function testShouldAppendErrorOutputIfWebDriverIsNotAvailable(): void
$listener = new SnapshotListener();
$listener->addError($test, new \Exception('Error', 333), 3.3);

$this->assertContains('[WARN] WebDriver instance not found, cannot take snapshot.', $test->getActualOutput());
$this->assertStringContainsString(
'[WARN] WebDriver instance not found, cannot take snapshot.',
$test->getActualOutput()
);
}

public function testShouldAppendErrorOutputIfWebDriverThrowsException(): void
Expand All @@ -165,7 +168,7 @@ public function testShouldAppendErrorOutputIfWebDriverThrowsException(): void
$listener = new SnapshotListener();
$listener->addError($test, new \Exception('Error', 333), 3.3);

$this->assertContains(
$this->assertStringContainsString(
'[WARN] Error taking page snapshot, perhaps browser is not accessible?',
$test->getActualOutput()
);
Expand Down
2 changes: 1 addition & 1 deletion src-tests/Listener/TestStatusListenerTest.php
Expand Up @@ -71,7 +71,7 @@ public function testShouldRegisterExtraPublishers(
);

foreach ($expectedExtraPublishers as $expectedExtraPublisher) {
$this->assertContains(
$this->assertStringContainsString(
'Registering test results publisher "' . $expectedExtraPublisher . '"',
$output
);
Expand Down
8 changes: 4 additions & 4 deletions src-tests/Process/ExecutionLoopTest.php
Expand Up @@ -30,7 +30,7 @@ public function shouldExecuteEmptyProcessSet(): void
$output = $outputBuffer->fetch();

$this->assertTrue($result, 'Exception loop did not finish successfully, output was: ' . "\n" . $output);
$this->assertContains('[OK] Testcases executed: 0', $output);
$this->assertStringContainsString('[OK] Testcases executed: 0', $output);
}

/** @test */
Expand Down Expand Up @@ -60,12 +60,12 @@ public function shouldDequeueProcessesWithoutDelayOnStartup(): void

$this->assertTrue($result, 'Exception loop did not finish successfully, output was: ' . "\n" . $output);

$this->assertContains('Testcase "NoDelay" is prepared to be run', $output);
$this->assertContains(
$this->assertStringContainsString('Testcase "NoDelay" is prepared to be run', $output);
$this->assertStringContainsString(
'Testcase "Delayed" is queued to be run 0.0 minutes after testcase "NoDelay" is finished',
$output
);

$this->assertContains('Dequeing testcase "Delayed"', $output);
$this->assertStringContainsString('Dequeing testcase "Delayed"', $output);
}
}

0 comments on commit cb92a64

Please sign in to comment.