wcAdapter = $this->createMock( WcAdapter::class ); $this->optionsProvider = $this->createMock( OptionsProvider::class ); return new DetailCommonLogic( $this->createMock( ContextResolver::class ), $this->createMock( Request::class ), $this->createMock( Repository::class ), $this->optionsProvider, $this->wcAdapter, ); } public static function shouldDisplayPickupPointInfoProvider(): array { return [ [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => false, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => true, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => false, ], ]; } /** * @dataProvider shouldDisplayPickupPointInfoProvider */ public function testShouldDisplayPickupPointInfo( bool $expected, bool $replaceShippingAddressWithPickupPointAddress, bool $shipToBillingAddressOnly, ): void { $detailCommonLogic = $this->createDetailCommonLogic(); $this->optionsProvider->method( 'replaceShippingAddressWithPickupPointAddress' )->willReturn( $replaceShippingAddressWithPickupPointAddress ); $this->wcAdapter->method( 'shipToBillingAddressOnly' )->willReturn( $shipToBillingAddressOnly ); $this->assertSame( $expected, $detailCommonLogic->shouldDisplayPickupPointInfo() ); } public static function shouldHidePacketaInfoProvider(): array { return [ [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => null, 'orderExported' => false, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => null, 'orderExported' => false, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => null, 'orderExported' => false, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => null, 'orderExported' => false, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => null, 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => null, 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => null, 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => null, 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => false, ], [ 'expected' => true, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => false, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => false, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => false, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => true, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => true, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => true, ], [ 'expected' => false, 'replaceShippingAddressWithPickupPointAddress' => false, 'shipToBillingAddressOnly' => false, 'orderPickupPoint' => new PickupPoint(), 'orderExported' => true, ], ]; } /** * @dataProvider shouldHidePacketaInfoProvider */ public function testShouldHidePacketaInfo( bool $expected, bool $replaceShippingAddressWithPickupPointAddress, bool $shipToBillingAddressOnly, ?PickupPoint $orderPickupPoint, bool $orderExported, ): void { $detailCommonLogic = $this->createDetailCommonLogic(); $this->optionsProvider->method( 'replaceShippingAddressWithPickupPointAddress' )->willReturn( $replaceShippingAddressWithPickupPointAddress ); $this->wcAdapter->method( 'shipToBillingAddressOnly' )->willReturn( $shipToBillingAddressOnly ); $dummyOrder = DummyFactory::createOrderCzPp(); if ( $orderPickupPoint !== null ) { $dummyOrder->setPickupPoint( $orderPickupPoint ); } $dummyOrder->setIsExported( $orderExported ); $this->assertSame( $expected, $detailCommonLogic->shouldHidePacketaInfo( $dummyOrder ) ); } }