-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug #11418 set default value for Channel taxCalculationStrategy (oall…
…ain) This PR was merged into the 1.7 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | fixes #11414 | License | MIT Commits ------- f4f0ed899d9709b6667b38e9ab7c5fbe641c1be1 set default value for Channel taxCalculationStrategy 0dd21deac7687c6a7f487733ca68704ec7516e37 factory extends component factory
- Loading branch information
Showing
7 changed files
with
126 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Component\Core\Factory; | ||
|
||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
|
||
class ChannelFactory implements ChannelFactoryInterface | ||
{ | ||
/** @var FactoryInterface */ | ||
private $decoratedFactory; | ||
|
||
/** @var string */ | ||
private $defaultCalculationStrategy; | ||
|
||
public function __construct(FactoryInterface $decoratedFactory, string $defaultCalculationStrategy) | ||
{ | ||
$this->decoratedFactory = $decoratedFactory; | ||
$this->defaultCalculationStrategy = $defaultCalculationStrategy; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createNew(): ChannelInterface | ||
{ | ||
/** @var \Sylius\Component\Core\Model\ChannelInterface $channel */ | ||
$channel = $this->decoratedFactory->createNew(); | ||
$channel->setTaxCalculationStrategy($this->defaultCalculationStrategy); | ||
|
||
return $channel; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function createNamed(string $name): ChannelInterface | ||
{ | ||
$channel = $this->createNew(); | ||
$channel->setName($name); | ||
|
||
return $channel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Component\Core\Factory; | ||
|
||
use Sylius\Component\Channel\Factory\ChannelFactoryInterface as BaseChannelFactoryInterface; | ||
use Sylius\Component\Channel\Model\ChannelInterface; | ||
|
||
interface ChannelFactoryInterface extends BaseChannelFactoryInterface | ||
{ | ||
public function createNamed(string $name): ChannelInterface; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace spec\Sylius\Component\Core\Factory; | ||
|
||
use PhpSpec\ObjectBehavior; | ||
use Sylius\Component\Core\Factory\ChannelFactoryInterface; | ||
use Sylius\Component\Core\Model\ChannelInterface; | ||
use Sylius\Component\Resource\Factory\FactoryInterface; | ||
|
||
final class ChannelFactorySpec extends ObjectBehavior | ||
{ | ||
function let(FactoryInterface $decoratedFactory): void | ||
{ | ||
$this->beConstructedWith($decoratedFactory, 'order_items_based'); | ||
} | ||
|
||
function it_implements_channel_factory_interface(): void | ||
{ | ||
$this->shouldImplement(ChannelFactoryInterface::class); | ||
} | ||
|
||
function it_is_a_resource_factory(): void | ||
{ | ||
$this->shouldImplement(FactoryInterface::class); | ||
} | ||
|
||
function it_creates_a_new_channel(FactoryInterface $decoratedFactory, ChannelInterface $channel): void | ||
{ | ||
$decoratedFactory->createNew()->willReturn($channel); | ||
$channel->setTaxCalculationStrategy('order_items_based')->shouldBeCalled(); | ||
|
||
$this->createNew()->shouldReturn($channel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters