|
5 | 5 | use A17\Twill\Commands\Traits\HandlesPresets; |
6 | 6 | use A17\Twill\Models\User; |
7 | 7 | use A17\Twill\RouteServiceProvider; |
8 | | -use A17\Twill\Services\Blocks\Block; |
9 | 8 | use A17\Twill\Tests\Integration\Behaviors\CopyBlocks; |
10 | | -use A17\Twill\Facades\TwillBlocks; |
11 | 9 | use A17\Twill\TwillServiceProvider; |
12 | 10 | use A17\Twill\ValidationServiceProvider; |
13 | 11 | use Carbon\Carbon; |
@@ -74,6 +72,7 @@ public static function setUpBeforeClass(): void |
74 | 72 | self::prepareParallelTestbenchApplication(); |
75 | 73 | self::configureParallelDatabase(); |
76 | 74 | cleanupTestState(self::applicationBasePath()); |
| 75 | + self::copyTestBlockStubs(self::applicationBasePath()); |
77 | 76 | parent::setUpBeforeClass(); |
78 | 77 | } |
79 | 78 |
|
@@ -138,7 +137,6 @@ public function setUp(): void |
138 | 137 | $this->instantiateFaker(); |
139 | 138 |
|
140 | 139 | $this->copyBlocks(); |
141 | | - $this->registerCopiedBlocks(); |
142 | 140 |
|
143 | 141 | $this->installTwill(); |
144 | 142 |
|
@@ -561,21 +559,6 @@ public function loadConfig() |
561 | 559 | { |
562 | 560 | } |
563 | 561 |
|
564 | | - protected function registerCopiedBlocks(): void |
565 | | - { |
566 | | - if (Block::getForComponent('a17-block-quote')) { |
567 | | - return; |
568 | | - } |
569 | | - |
570 | | - foreach (config('twill.block_editor.directories.source.blocks') as $path) { |
571 | | - TwillBlocks::registerPackageBlocksDirectory($this->normalizeDir($path['path'])); |
572 | | - } |
573 | | - |
574 | | - foreach (config('twill.block_editor.directories.source.repeaters') as $path) { |
575 | | - TwillBlocks::registerPackageRepeatersDirectory($this->normalizeDir($path['path'])); |
576 | | - } |
577 | | - } |
578 | | - |
579 | 562 | protected static function getBasePathStatic(): string |
580 | 563 | { |
581 | 564 | $basePath = __DIR__ . '/../../vendor/orchestra/testbench-core/laravel'; |
@@ -660,4 +643,31 @@ protected static function copyDirectory(string $source, string $target): void |
660 | 643 | } |
661 | 644 | } |
662 | 645 | } |
| 646 | + |
| 647 | + protected static function copyTestBlockStubs(string $basePath): void |
| 648 | + { |
| 649 | + $blockPath = $basePath . '/resources/views/twill/blocks'; |
| 650 | + $repeaterPath = $basePath . '/resources/views/twill/repeaters'; |
| 651 | + |
| 652 | + foreach (['carousel', 'footnote', 'gallery', 'image', 'quote'] as $block) { |
| 653 | + self::copyTestStub( |
| 654 | + __DIR__ . "/../../src/Commands/stubs/blocks/{$block}.blade.php", |
| 655 | + "{$blockPath}/{$block}.blade.php" |
| 656 | + ); |
| 657 | + } |
| 658 | + |
| 659 | + self::copyTestStub( |
| 660 | + __DIR__ . '/../../src/Commands/stubs/repeaters/carousel-item.blade.php', |
| 661 | + "{$repeaterPath}/carousel-item.blade.php" |
| 662 | + ); |
| 663 | + } |
| 664 | + |
| 665 | + protected static function copyTestStub(string $source, string $target): void |
| 666 | + { |
| 667 | + if (! is_dir(dirname($target))) { |
| 668 | + mkdir(dirname($target), 0755, true); |
| 669 | + } |
| 670 | + |
| 671 | + copy($source, $target); |
| 672 | + } |
663 | 673 | } |
0 commit comments