diff --git a/README.md b/README.md index 76ac9df..96aeca8 100644 --- a/README.md +++ b/README.md @@ -122,8 +122,9 @@ you will need to include both. ## Testing -This library includes some PHPUnit extension classes in **src/Test/** to assist with testing -vendor-sourced Bundles and Publishers. These are uses to test the files from this library -but are also available for other projects that use `Tatter\Frontend`. To test your own -classes simply extend the appropriate test case and add a data provider method with your -class name and criteria to meet. See the test files in **tests/** for examples. +This library includes a PHPUnit extension classes in **src/Test/** to assist with testing +vendor-sourced Publishers. `Tatter\Assets` has a similar test case for Bundles. These two +classes are used to test the files from this library but are also available for other projects +that use `Tatter\Frontend`. To test your own classes simply extend the appropriate test case +and add a data provider method with your class name and criteria to meet. See the test files +in **tests/** for examples. diff --git a/src/Test/BundlesTestCase.php b/src/Test/BundlesTestCase.php deleted file mode 100644 index a13c802..0000000 --- a/src/Test/BundlesTestCase.php +++ /dev/null @@ -1,57 +0,0 @@ -didPublish) { - foreach (Publisher::discover() as $publisher) { - $publisher->publish(); - } - - $this->didPublish = true; - } - } - - /** - * @dataProvider bundleProvider - * - * @param class-string $class - * @param string[] $expectedHeadFiles - * @param string[] $expectedBodyFiles - */ - public function testBundlesFiles(string $class, array $expectedHeadFiles, array $expectedBodyFiles): void - { - $bundle = new $class(); - $head = $bundle->head(); - $body = $bundle->body(); - - foreach ($expectedHeadFiles as $file) { - $this->assertStringContainsString($file, $head); - } - - foreach ($expectedBodyFiles as $file) { - $this->assertStringContainsString($file, $body); - } - } - - /** - * Returns an array of items to test with each item - * as a triple of [string publisherClassName, string[] headFileNames, string[] bodyFileNames] - */ - abstract public function bundleProvider(): array; -} diff --git a/src/Test/PublishersTestCase.php b/src/Test/PublishersTestCase.php index 1d0bd78..cc85f60 100644 --- a/src/Test/PublishersTestCase.php +++ b/src/Test/PublishersTestCase.php @@ -2,6 +2,7 @@ namespace Tatter\Frontend\Test; +use Tatter\Assets\Test\TestCase; use Tatter\Frontend\FrontendPublisher; abstract class PublishersTestCase extends TestCase diff --git a/src/Test/TestCase.php b/src/Test/TestCase.php deleted file mode 100644 index a6e9f31..0000000 --- a/src/Test/TestCase.php +++ /dev/null @@ -1,55 +0,0 @@ -root = vfsStream::setup('root'); - - // Create the config - $this->config = config('Assets'); - $this->config->directory = $this->root->url() . DIRECTORY_SEPARATOR; - $this->config->useTimestamps = false; // These make testing much harder - - Asset::useConfig($this->config); - - // Add VFS as an allowed Publisher directory - config('Publisher')->restrictions[$this->config->directory] = '*'; - } - - /** - * Preps the config and VFS. - */ - protected function tearDown(): void - { - parent::tearDown(); - - $this->root = null; // @phpstan-ignore-line - $this->resetServices(); - } -} diff --git a/tests/BundlesTest.php b/tests/BundlesTest.php index 32cf311..9a2b0c4 100644 --- a/tests/BundlesTest.php +++ b/tests/BundlesTest.php @@ -2,7 +2,7 @@ namespace Tatter\Frontend\Bundles; -use Tatter\Frontend\Test\BundlesTestCase; +use Tatter\Assets\Test\BundlesTestCase; /** * @internal diff --git a/tests/FrontendPublisherTest.php b/tests/FrontendPublisherTest.php index f4c951f..635e39f 100644 --- a/tests/FrontendPublisherTest.php +++ b/tests/FrontendPublisherTest.php @@ -1,7 +1,7 @@