From 3cbe7f5be7f51af1ee683f26cf8830c45a68b96c Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Thu, 2 Jan 2020 13:22:35 +0100 Subject: [PATCH] tests: skip test if mixin markers are already present in model We're also testing Laravel 5.5 which contains them (they were removed later) --- tests/Console/EloquentCommandTest.php | 9 ++++----- tests/TestCase.php | 18 ------------------ 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/tests/Console/EloquentCommandTest.php b/tests/Console/EloquentCommandTest.php index 1ca3ef6b1..0446118bb 100644 --- a/tests/Console/EloquentCommandTest.php +++ b/tests/Console/EloquentCommandTest.php @@ -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 \\Eloquent')) { + $msg = sprintf('Class %s already contains the @mixin markers', Model::class); + $this->markTestSkipped($msg); + } $actualContent = null; $mockFilesystem = Mockery::mock(Filesystem::class); diff --git a/tests/TestCase.php b/tests/TestCase.php index 36da2bff1..ae07f5e0d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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 @@ -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); - } }