File tree Expand file tree Collapse file tree 7 files changed +110
-0
lines changed
stubs/Sylius/RfqPlugin/Entity/Order
tests/Set/SyliusPlus/RfqPlugin Expand file tree Collapse file tree 7 files changed +110
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Config \RectorConfig ;
6+ use Sylius \SyliusRector \Rector \Class_ \AddInterfaceToClassExtendingTypeRector ;
7+ use Sylius \SyliusRector \Rector \Class_ \AddTraitToClassExtendingTypeRector ;
8+
9+ return static function (RectorConfig $ rectorConfig ): void {
10+ $ rectorConfig ->ruleWithConfiguration (AddInterfaceToClassExtendingTypeRector::class, [
11+ 'Sylius\Component\Core\Model\OrderItem ' => [
12+ 'Sylius\RfqPlugin\Entity\Order\OrderItemInterface ' ,
13+ ],
14+ ]);
15+ $ rectorConfig ->ruleWithConfiguration (AddTraitToClassExtendingTypeRector::class, [
16+ 'Sylius\Component\Core\Model\OrderItem ' => [
17+ 'Sylius\RfqPlugin\Entity\Order\OfferAwareTrait ' ,
18+ ],
19+ ]);
20+ };
Original file line number Diff line number Diff line change @@ -23,4 +23,6 @@ final class SyliusPlus
2323 public const RETURN_PLUGIN = __DIR__ . '/../../config/sets/sylius/plus/return-plugin.php ' ;
2424
2525 public const UPGRADE_TO_MODULAR = __DIR__ . '/../../config/sets/sylius/plus/up-to-plus-modular.php ' ;
26+
27+ public const RFQ_PLUGIN = __DIR__ . '/../../config/sets/sylius/plus/rfq-plugin.php ' ;
2628}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+
6+ if (trait_exists ('Sylius\RfqPlugin\Entity\Order\OfferAwareTrait ' )) {
7+ return ;
8+ }
9+
10+ trait OfferAwareTrait
11+ {
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+
6+ if (class_exists ('Sylius\RfqPlugin\Entity\Order\OrderItemInterface ' )) {
7+ return ;
8+ }
9+
10+ interface OrderItemInterface
11+ {
12+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Sylius \SyliusRector \Tests \Rector \Class_ \AddInterfaceToClassExtendingType \Fixture ;
4+
5+ use Sylius \Component \Core \Model \OrderItem as BaseOrderItem ;
6+
7+ class OrderItem extends BaseOrderItem
8+ {
9+ }
10+
11+ ?>
12+ -----
13+ <?php
14+
15+ namespace Sylius \SyliusRector \Tests \Rector \Class_ \AddInterfaceToClassExtendingType \Fixture ;
16+
17+ use Sylius \Component \Core \Model \OrderItem as BaseOrderItem ;
18+
19+ class OrderItem extends BaseOrderItem implements \Sylius \RfqPlugin \Entity \Order \OrderItemInterface
20+ {
21+ use \Sylius \RfqPlugin \Entity \Order \OfferAwareTrait;
22+ }
23+
24+ ?>
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Sylius \SyliusRector \Tests \Set \SyliusPlus \RfqPlugin ;
6+
7+ use Rector \Testing \PHPUnit \AbstractRectorTestCase ;
8+
9+ final class RfqPluginTest extends AbstractRectorTestCase
10+ {
11+ /** @dataProvider provideData() */
12+ public function test (string $ file ): void
13+ {
14+ $ this ->doTestFile ($ file );
15+ }
16+
17+ /** @return \Iterator<string> */
18+ public function provideData (): \Iterator
19+ {
20+ return self ::yieldFilesFromDirectory (__DIR__ . '/Fixture ' );
21+ }
22+
23+ public function provideConfigFilePath (): string
24+ {
25+ return __DIR__ . '/config/configured_rule.php ' ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ use Rector \Config \RectorConfig ;
6+ use Sylius \SyliusRector \Set \SyliusPlus ;
7+
8+ return static function (RectorConfig $ rectorConfig ): void {
9+ $ rectorConfig ->import (__DIR__ . '/../../../../../config/config.php ' );
10+ $ rectorConfig ->sets ([
11+ SyliusPlus::RFQ_PLUGIN ,
12+ ]);
13+ };
You can’t perform that action at this time.
0 commit comments