From b19b1d69ba6efaf82ff14ec44dc5774b986256e6 Mon Sep 17 00:00:00 2001 From: Ahmed Fathy Date: Wed, 31 Mar 2021 23:03:55 +0200 Subject: [PATCH] testing --- .../Factories/Models/ModelWithoutFactory.php | 13 +++++ .../Console/ModelsCommand/Factories/Test.php | 19 +++++++ ...hpdoc_for_model_doesnt_have_factory__1.php | 56 +++++++++++++++++++ .../Factories/__snapshots__/Test__test__1.php | 21 +++++++ 4 files changed, 109 insertions(+) create mode 100644 tests/Console/ModelsCommand/Factories/Models/ModelWithoutFactory.php create mode 100644 tests/Console/ModelsCommand/Factories/__snapshots__/Test__it_doesnt_generate_phpdoc_for_model_doesnt_have_factory__1.php diff --git a/tests/Console/ModelsCommand/Factories/Models/ModelWithoutFactory.php b/tests/Console/ModelsCommand/Factories/Models/ModelWithoutFactory.php new file mode 100644 index 0000000..d88ca6b --- /dev/null +++ b/tests/Console/ModelsCommand/Factories/Models/ModelWithoutFactory.php @@ -0,0 +1,13 @@ +assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay()); $this->assertMatchesMockedSnapshot(); } + + /** @test */ + public function it_doesnt_generate_phpdoc_for_model_doesnt_have_factory() + { + if (!version_compare(Application::VERSION, '8.2', '>=')) { + $this->markTestSkipped( + 'This test only works in Laravel >= 8.2' + ); + } + + $command = $this->app->make(ModelsCommand::class); + + $tester = $this->runCommand($command, [ + '--write' => true, + ]); + + $this->assertStringNotContainsString('not found', $tester->getDisplay()); + $this->assertMatchesMockedSnapshot(); + } } diff --git a/tests/Console/ModelsCommand/Factories/__snapshots__/Test__it_doesnt_generate_phpdoc_for_model_doesnt_have_factory__1.php b/tests/Console/ModelsCommand/Factories/__snapshots__/Test__it_doesnt_generate_phpdoc_for_model_doesnt_have_factory__1.php new file mode 100644 index 0000000..4d8b0f8 --- /dev/null +++ b/tests/Console/ModelsCommand/Factories/__snapshots__/Test__it_doesnt_generate_phpdoc_for_model_doesnt_have_factory__1.php @@ -0,0 +1,56 @@ +