From 0058ea22dba90f77766cf0e854592434cfb594c0 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 24 Jul 2024 15:58:10 +0200 Subject: [PATCH] Update use ProphecyTrait usage --- .../Controller/RedirectControllerTest.php | 3 ++ .../RedirectRouteImportControllerTest.php | 35 ++++++++----------- .../GoneDocumentSubscriberTest.php | 3 ++ .../GoneEntitySubscriberTest.php | 3 ++ .../Import/Converter/ConverterFacadeTest.php | 3 ++ Tests/Unit/Import/Converter/ConverterTest.php | 3 ++ Tests/Unit/Import/FileImportTest.php | 3 ++ Tests/Unit/Import/Reader/ReaderFacadeTest.php | 3 ++ Tests/Unit/Import/Writer/WriterTest.php | 3 ++ .../Unit/Manager/RedirectRouteManagerTest.php | 3 ++ .../Routing/RedirectRouteProviderTest.php | 3 ++ Tests/prophecy-trailt-bc-layer.php | 19 ++++++++++ Tests/test-bootstrap.php | 4 +++ composer.json | 3 +- 14 files changed, 69 insertions(+), 22 deletions(-) create mode 100644 Tests/prophecy-trailt-bc-layer.php diff --git a/Tests/Unit/Controller/RedirectControllerTest.php b/Tests/Unit/Controller/RedirectControllerTest.php index 31f4302..6dbafc9 100644 --- a/Tests/Unit/Controller/RedirectControllerTest.php +++ b/Tests/Unit/Controller/RedirectControllerTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\RedirectBundle\Tests\Unit\Controller; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\RedirectBundle\Controller\WebsiteRedirectController; use Sulu\Bundle\RedirectBundle\Model\RedirectRouteInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -19,6 +20,8 @@ class RedirectControllerTest extends TestCase { + use ProphecyTrait; + /** * @var WebsiteRedirectController */ diff --git a/Tests/Unit/Controller/RedirectRouteImportControllerTest.php b/Tests/Unit/Controller/RedirectRouteImportControllerTest.php index ea32b18..f29438c 100644 --- a/Tests/Unit/Controller/RedirectRouteImportControllerTest.php +++ b/Tests/Unit/Controller/RedirectRouteImportControllerTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\RedirectBundle\Controller\RedirectRouteImportController; use Sulu\Bundle\RedirectBundle\Import\Converter\ConverterNotFoundException; use Sulu\Bundle\RedirectBundle\Import\FileImportInterface; @@ -27,6 +28,8 @@ class RedirectRouteImportControllerTest extends TestCase { + use ProphecyTrait; + /** * @var string */ @@ -39,15 +42,12 @@ class RedirectRouteImportControllerTest extends TestCase public function testImportAction() { - $request = $this->prophesize(Request::class); - - $fileBag = $this->prophesize(FileBag::class); - $request->reveal()->files = $fileBag->reveal(); + $request = Request::create('/'); $uploadedFile = $this->createUploadedFile(__DIR__ . '/import.csv'); - - $fileBag->has('redirectRoutes')->willReturn(true); - $fileBag->get('redirectRoutes')->willReturn($uploadedFile); + $request->files->add([ + 'redirectRoutes' => $uploadedFile, + ]); $items = [ new Item(1, '', $this->prophesize(RedirectRouteInterface::class)->reveal()), @@ -59,7 +59,7 @@ public function testImportAction() $import->import(Argument::any())->willReturn($items); $controller = new RedirectRouteImportController($import->reveal(), $this->importPath); - $response = $controller->postAction($request->reveal()); + $response = $controller->postAction($request); $this->assertInstanceOf(JsonResponse::class, $response); $this->assertEquals(200, $response->getStatusCode()); @@ -96,15 +96,12 @@ public function testImportActionReaderNotFound() public function testImportActionConverterNotFound() { - $request = $this->prophesize(Request::class); - - $fileBag = $this->prophesize(FileBag::class); - $request->reveal()->files = $fileBag->reveal(); + $request = Request::create('/'); $uploadedFile = $this->createUploadedFile(__DIR__ . '/import.csv'); - - $fileBag->has('redirectRoutes')->willReturn(true); - $fileBag->get('redirectRoutes')->willReturn($uploadedFile); + $request->files->add([ + 'redirectRoutes' => $uploadedFile, + ]); $import = $this->prophesize(FileImportInterface::class); $import->import(Argument::any())->willThrow(ConverterNotFoundException::class); @@ -118,12 +115,8 @@ public function testImportActionConverterNotFound() public function testImportActionNoFile() { - $request = $this->prophesize(Request::class); - - $fileBag = $this->prophesize(FileBag::class); - $request->reveal()->files = $fileBag->reveal(); - - $fileBag->has('redirectRoutes')->willReturn(false); + $request = Request::create('/'); + $request->files->add([]); $import = $this->prophesize(FileImportInterface::class); $import->import(Argument::any())->shouldNotBeCalled(); diff --git a/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php b/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php index d6f8f32..8daf03b 100644 --- a/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php +++ b/Tests/Unit/GoneSubscriber/GoneDocumentSubscriberTest.php @@ -14,6 +14,7 @@ use Doctrine\ORM\EntityManager; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\DocumentManagerBundle\Bridge\DocumentInspector; use Sulu\Bundle\PageBundle\Document\BasePageDocument; @@ -30,6 +31,8 @@ class GoneDocumentSubscriberTest extends TestCase { + use ProphecyTrait; + /** * @var GoneDocumentSubscriber */ diff --git a/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php b/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php index 1d8a767..e950d06 100644 --- a/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php +++ b/Tests/Unit/GoneSubscriber/GoneEntitySubscriberTest.php @@ -14,6 +14,7 @@ use Doctrine\ORM\Event\LifecycleEventArgs; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Entity\RedirectRoute; use Sulu\Bundle\RedirectBundle\GoneSubscriber\GoneEntitySubscriber; @@ -22,6 +23,8 @@ class GoneEntitySubscriberTest extends TestCase { + use ProphecyTrait; + /** * @var GoneEntitySubscriber */ diff --git a/Tests/Unit/Import/Converter/ConverterFacadeTest.php b/Tests/Unit/Import/Converter/ConverterFacadeTest.php index a1e4acd..030d6cd 100644 --- a/Tests/Unit/Import/Converter/ConverterFacadeTest.php +++ b/Tests/Unit/Import/Converter/ConverterFacadeTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\RedirectBundle\Tests\Unit\Import\Converter; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Import\Converter\ConverterFacade; use Sulu\Bundle\RedirectBundle\Import\Converter\ConverterInterface; @@ -19,6 +20,8 @@ class ConverterFacadeTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $data = ['title' => 'Test-Title']; diff --git a/Tests/Unit/Import/Converter/ConverterTest.php b/Tests/Unit/Import/Converter/ConverterTest.php index 99a6fb8..5068e78 100644 --- a/Tests/Unit/Import/Converter/ConverterTest.php +++ b/Tests/Unit/Import/Converter/ConverterTest.php @@ -13,12 +13,15 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\RedirectBundle\Import\Converter\Converter; use Sulu\Bundle\RedirectBundle\Model\RedirectRouteInterface; use Sulu\Bundle\RedirectBundle\Model\RedirectRouteRepositoryInterface; class ConverterTest extends TestCase { + use ProphecyTrait; + public function testSupports() { $repository = $this->prophesize(RedirectRouteRepositoryInterface::class); diff --git a/Tests/Unit/Import/FileImportTest.php b/Tests/Unit/Import/FileImportTest.php index 00c16b5..a4ebd33 100644 --- a/Tests/Unit/Import/FileImportTest.php +++ b/Tests/Unit/Import/FileImportTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Import\Converter\Converter; use Sulu\Bundle\RedirectBundle\Import\Converter\ConverterInterface; @@ -28,6 +29,8 @@ class FileImportTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy */ diff --git a/Tests/Unit/Import/Reader/ReaderFacadeTest.php b/Tests/Unit/Import/Reader/ReaderFacadeTest.php index 4119848..d2a286b 100644 --- a/Tests/Unit/Import/Reader/ReaderFacadeTest.php +++ b/Tests/Unit/Import/Reader/ReaderFacadeTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\RedirectBundle\Tests\Unit\Import\Reader; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Import\Converter\Converter; use Sulu\Bundle\RedirectBundle\Import\Reader\ReaderFacade; @@ -19,6 +20,8 @@ class ReaderFacadeTest extends TestCase { + use ProphecyTrait; + /** * @var string */ diff --git a/Tests/Unit/Import/Writer/WriterTest.php b/Tests/Unit/Import/Writer/WriterTest.php index a96bdef..acd9b31 100644 --- a/Tests/Unit/Import/Writer/WriterTest.php +++ b/Tests/Unit/Import/Writer/WriterTest.php @@ -13,6 +13,7 @@ use Doctrine\ORM\EntityManagerInterface; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Exception\RedirectRouteNotUniqueException; use Sulu\Bundle\RedirectBundle\Import\Writer\DuplicatedSourceException; @@ -24,6 +25,8 @@ class WriterTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy */ diff --git a/Tests/Unit/Manager/RedirectRouteManagerTest.php b/Tests/Unit/Manager/RedirectRouteManagerTest.php index a16ed17..4b6106c 100644 --- a/Tests/Unit/Manager/RedirectRouteManagerTest.php +++ b/Tests/Unit/Manager/RedirectRouteManagerTest.php @@ -13,6 +13,7 @@ use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Prophecy\Prophecy\ObjectProphecy; use Sulu\Bundle\RedirectBundle\Exception\RedirectRouteNotUniqueException; use Sulu\Bundle\RedirectBundle\Manager\RedirectRouteManager; @@ -22,6 +23,8 @@ class RedirectRouteManagerTest extends TestCase { + use ProphecyTrait; + /** * @var ObjectProphecy */ diff --git a/Tests/Unit/Routing/RedirectRouteProviderTest.php b/Tests/Unit/Routing/RedirectRouteProviderTest.php index d686b3a..76e031d 100644 --- a/Tests/Unit/Routing/RedirectRouteProviderTest.php +++ b/Tests/Unit/Routing/RedirectRouteProviderTest.php @@ -12,6 +12,7 @@ namespace Sulu\Bundle\RedirectBundle\Tests\Unit\Routing; use PHPUnit\Framework\TestCase; +use Prophecy\PhpUnit\ProphecyTrait; use Sulu\Bundle\RedirectBundle\Model\RedirectRouteInterface; use Sulu\Bundle\RedirectBundle\Model\RedirectRouteRepositoryInterface; use Sulu\Bundle\RedirectBundle\Routing\RedirectRouteProvider; @@ -20,6 +21,8 @@ class RedirectRouteProviderTest extends TestCase { + use ProphecyTrait; + /** * @var RedirectRouteRepositoryInterface */ diff --git a/Tests/prophecy-trailt-bc-layer.php b/Tests/prophecy-trailt-bc-layer.php new file mode 100644 index 0000000..55757af --- /dev/null +++ b/Tests/prophecy-trailt-bc-layer.php @@ -0,0 +1,19 @@ +