2121use Cake \Routing \Router ;
2222use Cake \TestSuite \StringCompareTrait ;
2323use Cake \TestSuite \TestCase ;
24+ use PHPUnit \Framework \Attributes \CoversClass ;
25+ use PHPUnit \Framework \Attributes \CoversMethod ;
2426
2527/**
26- * Test resources migration task.
27- *
28- * @coversDefaultClass \BEdita\DevTools\Command\ResourcesMigrationCommand
28+ * Test resources migration task
2929 */
30+ #[CoversClass(ResourcesMigrationCommand::class)]
31+ #[CoversMethod(ResourcesMigrationCommand::class, 'bake ' )]
32+ #[CoversMethod(ResourcesMigrationCommand::class, 'buildOptionParser ' )]
33+ #[CoversMethod(ResourcesMigrationCommand::class, 'fileName ' )]
34+ #[CoversMethod(ResourcesMigrationCommand::class, 'name ' )]
35+ #[CoversMethod(ResourcesMigrationCommand::class, 'template ' )]
3036class ResourcesMigrationCommandTest extends TestCase
3137{
3238 use ConsoleIntegrationTestTrait;
@@ -48,7 +54,7 @@ public function setUp(): void
4854 Router::reload ();
4955 $ this ->loadPlugins (['Bake ' ]);
5056 $ this ->setAppNamespace ('BEdita\DevTools\Test\TestApp ' );
51- $ this ->_compareBasePath = Plugin::path ('BEdita/DevTools ' ) . 'tests ' . DS . 'comparisons ' . DS . ' Migrations ' . DS ;
57+ $ this ->_compareBasePath = Plugin::path ('BEdita/DevTools ' ) . 'tests ' . DS . 'Migrations ' . DS ;
5258 }
5359
5460 /**
@@ -67,7 +73,6 @@ public function tearDown(): void
6773 * Test `name`.
6874 *
6975 * @return void
70- * @covers ::name()
7176 */
7277 public function testName (): void
7378 {
@@ -81,7 +86,6 @@ public function testName(): void
8186 * Test `fileName`.
8287 *
8388 * @return void
84- * @covers ::fileName()
8589 */
8690 public function testFileName (): void
8791 {
@@ -103,7 +107,6 @@ public function setArgs(Arguments $args): void
103107 * Test `template`.
104108 *
105109 * @return void
106- * @covers ::template()
107110 */
108111 public function testTemplate (): void
109112 {
@@ -117,8 +120,6 @@ public function testTemplate(): void
117120 * Test `bake`.
118121 *
119122 * @return void
120- * @covers ::bake()
121- * @covers ::buildOptionParser()
122123 */
123124 public function testBake (): void
124125 {
@@ -140,8 +141,26 @@ public function testBake(): void
140141 $ this ->createdFiles [] = $ phpFile ;
141142 $ this ->createdFiles [] = $ yamlFile ;
142143
143- self ::assertSameMigration ((string )$ phpResult , (string )file_get_contents ($ this ->_compareBasePath . 'testMyMigration.php ' ));
144- self ::assertSameMigration ((string )$ yamlResult , (string )file_get_contents ($ this ->_compareBasePath . 'testMyMigration.yml ' ));
144+ $ expectedPhp = <<<PHP
145+ <?php
146+ use BEdita\Core\Migration\ResourcesMigration;
147+
148+ class MyMigration extends ResourcesMigration
149+ {
150+ }
151+ PHP ;
152+ self ::assertSameMigration ((string )$ phpResult , $ expectedPhp );
153+ $ expectedYaml = <<<YAML
154+ # MyMigration migration
155+ ---
156+
157+ #create:
158+
159+ #update:
160+
161+ #remove:
162+ YAML ;
163+ self ::assertSameMigration ((string )$ yamlResult , $ expectedYaml );
145164 }
146165
147166 /**
0 commit comments