From 01fb9c708325fdeee0b51a1467a4d744af37ad0d Mon Sep 17 00:00:00 2001 From: Pavel Dohnal Date: Wed, 21 Aug 2019 10:02:54 +0200 Subject: [PATCH] Move test to unit [MAILPOET-2219] --- .../Features/FeaturesControllerTest.php | 60 ++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) rename tests/{integration => unit}/Features/FeaturesControllerTest.php (50%) diff --git a/tests/integration/Features/FeaturesControllerTest.php b/tests/unit/Features/FeaturesControllerTest.php similarity index 50% rename from tests/integration/Features/FeaturesControllerTest.php rename to tests/unit/Features/FeaturesControllerTest.php index 7fd83aeab7..8d726ec7e7 100644 --- a/tests/integration/Features/FeaturesControllerTest.php +++ b/tests/unit/Features/FeaturesControllerTest.php @@ -1,23 +1,29 @@ make(FeaturesController::class, [ - 'defaults' => [ - 'feature-a' => true, - 'feature-b' => false, - ], - ]); + $repository = $this->makeEmpty( + FeatureFlagsRepository::class, + [ + 'findAll' => [], + ] + ); + $controller = $this->construct( + FeaturesController::class, + [$repository], + [ + 'defaults' => [ + 'feature-a' => true, + 'feature-b' => false, + ], + ] + ); expect($controller->isSupported('feature-a'))->equals(true); expect($controller->isSupported('feature-b'))->equals(false); @@ -28,12 +34,14 @@ class FeaturesControllerTest extends \MailPoetTest { } function testItWorksWithDatabaseValues() { - FeatureFlag::createOrUpdate([ - 'name' => 'feature-a', - 'value' => false, - ]); + $repository = $this->makeEmpty( + FeatureFlagsRepository::class, + [ + 'findAll' => [new FeatureFlagEntity('feature-a', false)], + ] + ); - $controller = $this->make(FeaturesController::class, [ + $controller = $this->construct(FeaturesController::class, [$repository], [ 'defaults' => [ 'feature-a' => true, ], @@ -46,12 +54,14 @@ class FeaturesControllerTest extends \MailPoetTest { } function testItDoesNotReturnUnknownFlag() { - FeatureFlag::createOrUpdate([ - 'name' => 'feature-unknown', - 'value' => true, - ]); + $repository = $this->makeEmpty( + FeatureFlagsRepository::class, + [ + 'findAll' => [new FeatureFlagEntity('feature-unknown', true)], + ] + ); - $controller = $this->make(FeaturesController::class, [ + $controller = $this->construct(FeaturesController::class, [$repository], [ 'defaults' => [], ]); @@ -63,8 +73,4 @@ class FeaturesControllerTest extends \MailPoetTest { expect($controller->getAllFlags())->isEmpty(); } - function _after() { - parent::_before(); - FeatureFlag::deleteMany(); - } }