Skip to content

Commit

Permalink
tests: skip test if mixin markers are already present in model
Browse files Browse the repository at this point in the history
We're also testing Laravel 5.5 which contains them (they were removed later)
  • Loading branch information
mfn committed Jan 2, 2020
1 parent d354a5c commit 07c5484
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 23 deletions.
9 changes: 4 additions & 5 deletions tests/Console/EloquentCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ class EloquentCommandTest extends TestCase
public function testCommand()
{
$modelFilename = $this->getVendorModelFilename();

// Ensure the mixins are not present
$modelSource = file_get_contents($modelFilename);
$this->assertStringNotContainsString('* @mixin \\Eloquent', $modelSource);
$this->assertStringNotContainsString('* @mixin \\Illuminate\\Database\\Eloquent\\Builder', $modelSource);
$this->assertStringNotContainsString('* @mixin \\Illuminate\\Database\\Query\\Builder', $modelSource);
if (false !== strpos($modelSource, '* @mixin')) {
$msg = sprintf('Class %s already contains the @mixin markers', Model::class);
$this->markTestSkipped($msg);
}

$actualContent = null;
$mockFilesystem = Mockery::mock(Filesystem::class);
Expand Down
18 changes: 0 additions & 18 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Orchestra\Testbench\TestCase as BaseTestCase;
use PHPUnit\Framework\Assert;
use Symfony\Component\Console\Tester\CommandTester;

abstract class TestCase extends BaseTestCase
Expand Down Expand Up @@ -34,21 +33,4 @@ protected function runCommand(Command $command, array $arguments = [], array $in

return $tester;
}

/**
* @todo if support for Laravel 5.5 is dropped, this shim can be replaced with actual parent call
*
* @param string $needle
* @param string $haystack
* @param string $message
*/
public static function assertStringNotContainsString(string $needle, string $haystack, string $message = ''): void
{
if (!method_exists(Assert::class, 'assertStringContainsString')) {
parent::assertNotContains($needle, $haystack, $message);
return;
}

parent::assertStringNotContainsString($needle, $haystack, $message);
}
}

0 comments on commit 07c5484

Please sign in to comment.