diff --git a/plugins/bc-uploader/tests/Scenario/UploaderFilesScenario.php b/plugins/bc-uploader/tests/Scenario/UploaderFilesScenario.php index 60209fcff0..61a0a223a9 100755 --- a/plugins/bc-uploader/tests/Scenario/UploaderFilesScenario.php +++ b/plugins/bc-uploader/tests/Scenario/UploaderFilesScenario.php @@ -52,7 +52,7 @@ public function load(...$args) UploaderCategoryFactory::make(['id' => 2, 'name' => 'contact'])->persist(); //アップロードファイルデータを生成 - UploaderFileFactory::make(['id' => 1, 'name' => 'social_new.jpg', 'atl' => 'social_new.jpg', 'uploader_category_id' => 1, 'user_id' => 1])->persist(); + UploaderFileFactory::make(['id' => 1, 'name' => 'social_new.jpg', 'atl' => 'social_new.jpg', 'uploader_category_id' => 1, 'user_id' => 1, 'publish_begin' => '2017-07-09 03:38:07', 'publish_end' => '2017-07-09 03:38:07'])->persist(); UploaderFileFactory::make(['id' => 2, 'name' => 'widget-hero.jpg', 'atl' => 'widget-hero.jpg', 'uploader_category_id' => 1, 'user_id' => 1])->persist(); UploaderFileFactory::make(['id' => 3, 'name' => 'logo-48x48_c.png', 'atl' => 'logo-48x48_c.jpg', 'uploader_category_id' => 2, 'user_id' => 1])->persist(); UploaderFileFactory::make(['id' => 4, 'name' => '2_1.jpg', 'atl' => '2_1.jpg', 'user_id' => 1])->persist(); diff --git a/plugins/bc-uploader/tests/TestCase/Controller/UploaderFilesControllerTest.php b/plugins/bc-uploader/tests/TestCase/Controller/UploaderFilesControllerTest.php index 41538e1576..57fa1f132d 100644 --- a/plugins/bc-uploader/tests/TestCase/Controller/UploaderFilesControllerTest.php +++ b/plugins/bc-uploader/tests/TestCase/Controller/UploaderFilesControllerTest.php @@ -64,6 +64,7 @@ public function tearDown(): void { parent::tearDown(); $this->truncateTable('uploader_categories'); + $this->truncateTable('uploader_files'); } /** @@ -126,14 +127,7 @@ public function test_upload() public function test_edit() { //データを生成 - UploaderFileFactory::make([ - 'id' => 1, - 'name' => '2_2.jpg', - 'atl' => '2_2.jpg', - 'user_id' => 1, - 'publish_begin' => '2017-07-09 03:38:07', - 'publish_end' => '2017-07-09 03:38:07', - ])->persist(); + $this->loadFixtureScenario(UploaderFilesScenario::class); $data = UploaderFileFactory::get(1); $data->alt = 'test edit'; //APIを呼ぶ @@ -143,7 +137,7 @@ public function test_edit() //戻る値を確認 $result = json_decode((string)$this->_response->getBody()); //メッセージを確認 - $this->assertEquals($result->message, 'アップロードファイル「2_2.jpg」を更新しました。'); + $this->assertEquals($result->message, 'アップロードファイル「social_new.jpg」を更新しました。'); //値が変更されるか確認 $this->assertEquals($result->uploaderFile->alt, 'test edit'); } @@ -156,17 +150,17 @@ public function test_delete() { $pathImg = WWW_ROOT . DS . 'files' . DS . 'uploads' . DS; //テストファイルを作成 - new File($pathImg . '2_2.jpg', true); + new File($pathImg . 'social_new.jpg', true); //データを生成 - UploaderFileFactory::make(['id' => 1, 'name' => '2_2.jpg', 'atl' => '2_2.jpg', 'user_id' => 1])->persist(); + $this->loadFixtureScenario(UploaderFilesScenario::class); //APIを呼ぶ $this->post("/baser/api/admin/bc-uploader/uploader_files/delete/1.json?token=" . $this->accessToken); // レスポンスコードを確認する $this->assertResponseOk(); //戻る値を確認 $result = json_decode((string)$this->_response->getBody()); - $this->assertEquals($result->message, 'アップロードファイル「2_2.jpg」を削除しました。'); - $this->assertEquals($result->uploaderFile->name, '2_2.jpg'); + $this->assertEquals($result->message, 'アップロードファイル「social_new.jpg」を削除しました。'); + $this->assertEquals($result->uploaderFile->name, 'social_new.jpg'); //ファイルが削除できるか確認 $this->assertFalse(file_exists($pathImg . '2_2.jpg')); }