Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and TomasVotruba committed Jul 19, 2021
1 parent 4c495cb commit 8b0adb8
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 33 deletions.
16 changes: 8 additions & 8 deletions packages/Testing/PHPUnit/PlatformAgnosticAssertions.php
Expand Up @@ -4,6 +4,7 @@

namespace Rector\Testing\PHPUnit;

use Nette\Utils\FileSystem;
use PHPUnit\Framework\Constraint\IsEqual;

/**
Expand Down Expand Up @@ -45,11 +46,11 @@ public static function assertStringEqualsFile(
parent::assertFileExists($expectedFile, $message);

$expectedString = self::getNormalizedFileContents($expectedFile);
$constraint = new IsEqual($expectedString);
$isEqual = new IsEqual($expectedString);

$actualString = self::normalize($actualString);

parent::assertThat($actualString, $constraint, $message);
parent::assertThat($actualString, $isEqual, $message);
}

/**
Expand All @@ -61,22 +62,21 @@ public static function assertFileEquals(string $expected, string $actual, string
static::assertFileExists($expected, $message);
static::assertFileExists($actual, $message);

$constraint = new IsEqual(self::getNormalizedFileContents($expected));
$isEqual = new IsEqual(self::getNormalizedFileContents($expected));

static::assertThat(self::getNormalizedFileContents($actual), $constraint, $message);
static::assertThat(self::getNormalizedFileContents($actual), $isEqual, $message);
}

private static function normalize(string $string)
private static function normalize(string $string): array | string
{
$string = str_replace("\r\n", "\n", $string);
$string = str_replace(DIRECTORY_SEPARATOR, '/', $string);

return $string;
return str_replace(DIRECTORY_SEPARATOR, '/', $string);
}

private static function getNormalizedFileContents(string $filePath): string
{
$expectedString = file_get_contents($filePath);
$expectedString = FileSystem::read($filePath);
return self::normalize($expectedString);
}
}
Expand Up @@ -15,7 +15,7 @@ final class NewlineBeforeNewAssignSetRectorTest extends AbstractRectorTestCase
*/
public function test(SmartFileInfo $fileInfo): void
{
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
if ($this->isWindows()) {
$this->markTestSkipped('doesnt work on windows, see https://github.com/rectorphp/rector/issues/6572');
}

Expand Down
Expand Up @@ -15,11 +15,7 @@ final class ReturnThisRemoveRectorTest extends AbstractRectorTestCase
*/
public function test(SmartFileInfo $fileInfo): void
{
<<<<<<< HEAD
if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
=======
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
>>>>>>> 5b6ac363a (skip ReturnThisRemoveRectorTest on windows)
if ($this->isWindows()) {
$this->markTestSkipped('minor differences on windows, see https://github.com/rectorphp/rector/issues/6571');
}

Expand Down
Expand Up @@ -15,7 +15,7 @@ final class DowngradeGeneratedScalarTypesRectorTest extends AbstractRectorTestCa
*/
public function test(SmartFileInfo $fileInfo): void
{
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
if ($this->isWindows()) {
$this->markTestSkipped('minor differences on windows, see https://github.com/rectorphp/rector/issues/6571');
}

Expand Down
Expand Up @@ -18,7 +18,7 @@ final class DowngradeFlexibleHeredocSyntaxRectorTest extends AbstractRectorTestC
*/
public function test(SmartFileInfo $fileInfo): void
{
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
if ($this->isWindows()) {
$this->markTestSkipped('doesnt work on windows, see https://github.com/rectorphp/rector/issues/6571');
}

Expand Down
Expand Up @@ -9,7 +9,6 @@
use Symplify\SmartFileSystem\SmartFileInfo;

/**
* @requires OSFAMILY != Windows
* Minor differences on windows, see https://github.com/rectorphp/rector/issues/6571
*/
final class SensitiveHereNowDocRectorTest extends AbstractRectorTestCase
Expand All @@ -19,25 +18,10 @@ final class SensitiveHereNowDocRectorTest extends AbstractRectorTestCase
*/
public function test(SmartFileInfo $fileInfo): void
{
<<<<<<< HEAD
<<<<<<< HEAD
<<<<<<< HEAD
if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
=======
<<<<<<< HEAD
if (strncasecmp(PHP_OS, 'WIN', 3) == 0) {
=======
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
>>>>>>> 387759e1c (skip SensitiveHereNowDocRectorTest on windows)
>>>>>>> 5b6ac363a (skip ReturnThisRemoveRectorTest on windows)
=======
if (strncasecmp(PHP_OS, 'WIN', 3) === 0) {
>>>>>>> 2a06c833a (extract VendorLocationDetector and make it Windows compatible)
if ($this->isWindows()) {
$this->markTestSkipped('minor differences on windows, see https://github.com/rectorphp/rector/issues/6571');
}

=======
>>>>>>> 295e66d05 (try requires from PHPUnit)
$this->doTestFileInfo($fileInfo);
}

Expand Down

0 comments on commit 8b0adb8

Please sign in to comment.