Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BcUploaderを全体テストの実行対象に追加する #2838

Merged
merged 25 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0d5ec2c
BcUploaderを全体テストの実行対象に追加する
dovanhung Oct 31, 2023
5fa2270
Merge branch 'dev-5' into overall_test_BcUploader
dovanhung Nov 2, 2023
048ede5
コメントの修正
dovanhung Nov 2, 2023
c04027b
ユニットテストを調整
dovanhung Nov 6, 2023
bf5006b
ユニットテストを調整
dovanhung Nov 6, 2023
fb2cdc3
ユニットテストを調整
dovanhung Nov 6, 2023
aeebde6
ユニットテストを調整
dovanhung Nov 6, 2023
fc14d96
ユニットテストを調整
dovanhung Nov 7, 2023
f26030b
ユニットテストを調整
dovanhung Nov 7, 2023
a44b15e
Merge branch 'fix_warning' into overall_test_BcUploader
dovanhung Nov 7, 2023
69c112b
ユニットテストを調整
dovanhung Nov 7, 2023
6bf6011
ユニットテストを調整
dovanhung Nov 7, 2023
3fd0381
ユニットテスト調整
dovanhung Nov 7, 2023
efba8b5
ユニットテスト調整
dovanhung Nov 7, 2023
8d44ea8
ユニットテスト調整
dovanhung Nov 8, 2023
da63d38
ユニットテスト調整
dovanhung Nov 8, 2023
d226b46
Merge branch 'fix_warning' into overall_test_BcUploader
dovanhung Nov 8, 2023
26c5f67
Merge branch 'dev-5' into overall_test_BcUploader
dovanhung Nov 8, 2023
371e30d
ユニットテスト調整
dovanhung Nov 8, 2023
805e6a0
ユニットテスト調整
dovanhung Nov 8, 2023
64d00e1
ユニットテスト調整
dovanhung Nov 8, 2023
050d643
ユニットテスト調整
dovanhung Nov 8, 2023
b554993
Merge branch 'dev-5' into overall_test_BcUploader
dovanhung Nov 9, 2023
fdebd65
ユニットテスト調整
dovanhung Nov 9, 2023
27a57ab
ユニットテスト調整
dovanhung Nov 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
<testsuite name="BcThemeFile">
<directory>plugins/bc-theme-file/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcUploader">-->
<!-- <directory>plugins/bc-uploader/tests/TestCase</directory>-->
<!-- </testsuite>-->
<testsuite name="BcUploader">
<directory>plugins/bc-uploader/tests/TestCase</directory>
</testsuite>
<!-- <testsuite name="BcWidgetArea">-->
<!-- <directory>plugins/bc-widget-area/tests/TestCase</directory>-->
<!-- </testsuite>-->
Expand Down
3 changes: 2 additions & 1 deletion plugins/bc-theme-config/src/Service/ThemeConfigsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ public function saveImage($entity)
// サムネイルを保存
$imageresizer = new Imageresizer();
$thumbPath = $saveDir . $image . $thumbSuffix . '.' . $ext;
$imageresizer->resize($filePath, $thumbPath, 320, 320);
if (file_exists($filePath))
$imageresizer->resize($filePath, $thumbPath, 320, 320);

// エンティティを更新
$entity->{$image} = $fileName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

use BaserCore\Model\Entity\SiteConfig;
use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Factory\UserFactory;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcContainerTrait;
use BcThemeConfig\Model\Entity\ThemeConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ public function test_upload()
//テストファイルとフォルダを削除
rmdir($filePath);
unlink($fullpath . 'uploadTestFile.html');

//エラーを発生した場合
$this->post('/baser/admin/bc-theme-file/theme_files/index/BcThemeSample/layout3');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HungDV2022 削除した理由はなんでしょうか?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ryuring
こちらと同じ理由です。#2844 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

了解しました。

//ステータスを確認
$this->assertResponseCode(500);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use BaserCore\Test\Factory\SiteFactory;
use BaserCore\Test\Factory\UserFactory;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcFile;
use BaserCore\Utility\BcFolder;
use Cake\Filesystem\File;
use Cake\Filesystem\Folder;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
Expand Down Expand Up @@ -61,6 +63,7 @@ public function test_add()
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/';
$data = [
'theme' => 'BcThemeSample',
'parent' => $fullpath,
'type' => 'layout',
'path' => '',
'base_name' => 'base_name_1',
Expand Down Expand Up @@ -316,13 +319,17 @@ public function test_upload()
{
//テストテーマフォルダを作成
$fullpath = BASER_PLUGINS . 'BcThemeSample' . '/templates/layout/';
(new Folder())->create($fullpath . 'new_folder', 0777);
$folder = new BcFolder($fullpath . 'new_folder');
$folder->create();

//テストファイルを作成
$filePath = TMP . 'test_upload' . DS;
(new Folder())->create($filePath, 0777);
$filePath = TMP . 'test_upload' . DS;
$folder = new BcFolder($filePath);
$folder->create();

$testFile = $filePath . 'uploadTestFile.html';
new File($testFile, true);
$file = new BcFile($testFile);
$file->create();

//Postデータを生成
$data = [
Expand All @@ -344,8 +351,6 @@ public function test_upload()
$this->assertTrue(file_exists($fullpath . 'new_folder/uploadTestFile.html'));

//テストファイルとフォルダを削除
rmdir($filePath);
unlink($fullpath . 'new_folder/uploadTestFile.html');
rmdir($fullpath . 'new_folder');
$folder->delete();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public function index(UploaderFilesServiceInterface $service)
* @param UploaderFilesServiceInterface $service
* @checked
* @noTodo
* @unitTest
*/
public function upload(UploaderFilesServiceInterface $service)
{
Expand Down Expand Up @@ -146,7 +145,7 @@ public function delete(UploaderFilesServiceInterface $service, int $id)
'uploaderFile' => $entity,
'message' => $message
]);
$this->viewBuilder()->setOption('serialize', ['uploadFile', 'message']);
$this->viewBuilder()->setOption('serialize', ['uploaderFile', 'message']);
}

}
1 change: 0 additions & 1 deletion plugins/bc-uploader/src/Service/UploaderFilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ public function update(EntityInterface $entity, array $postData)
* @return bool
* @checked
* @noTodo
* @unitTest
*/
public function isEditable(array $postData)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
$this->truncateTable('uploader_categories');
$this->truncateTable('uploader_files');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license https://basercms.net/license/index.html MIT License
*/

namespace BcUploader\Test\TestCase\Controller\Api;
namespace BcUploader\Test\TestCase\Controller;

use BaserCore\Service\DblogsServiceInterface;
use BaserCore\Test\Scenario\InitAppScenario;
Expand Down Expand Up @@ -64,6 +64,8 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
$this->truncateTable('uploader_categories');
$this->truncateTable('uploader_files');
}

/**
Expand All @@ -74,7 +76,7 @@ public function test_index()
{
$this->loadFixtureScenario(UploaderFilesScenario::class);
//APIを呼ぶ
$this->get("/baser/api/bc-uploader/uploader_categories/index.json?token=" . $this->accessToken);
$this->get("/baser/api/admin/bc-uploader/uploader_categories/index.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -93,7 +95,7 @@ public function test_add()
'name' => 'japan'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -106,7 +108,7 @@ public function test_add()
'name' => null
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(400);
//戻る値を確認
Expand All @@ -119,7 +121,7 @@ public function test_add()
'name' => 'name...................................................'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/add.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(500);
//戻る値を確認
Expand All @@ -139,7 +141,7 @@ public function test_edit()
'name' => '更新!'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/edit/1.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/edit/1.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -149,7 +151,7 @@ public function test_edit()

//無効なアップロードカテゴリIDを指定した場合、
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/edit/10.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/edit/10.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(404);
//戻る値を確認
Expand All @@ -158,7 +160,7 @@ public function test_edit()

//入力内容はヌルの場合、
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/edit/1.json?token=" . $this->accessToken, ['name' => '']);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/edit/1.json?token=" . $this->accessToken, ['name' => '']);
//ステータスを確認
$this->assertResponseCode(400);
//戻る値を確認
Expand All @@ -176,7 +178,7 @@ public function test_copy()
//テストデーターを生成
$this->loadFixtureScenario(UploaderCategoriesScenario::class);
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/copy/1.json?token=" . $this->accessToken);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/copy/1.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -186,7 +188,7 @@ public function test_copy()

//無効なアップロードカテゴリIDを指定した場合、
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/copy/11.json?token=" . $this->accessToken);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/copy/11.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseCode(500);
//戻る値を確認
Expand All @@ -203,7 +205,7 @@ public function test_delete()
//テストデーターを生成
$this->loadFixtureScenario(UploaderCategoriesScenario::class);
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/delete/1.json?token=" . $this->accessToken);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/delete/1.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -213,7 +215,7 @@ public function test_delete()

//無効なアップロードカテゴリIDを指定した場合、
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/delete/10.json?token=" . $this->accessToken);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/delete/10.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseCode(404);
//戻る値を確認
Expand All @@ -237,7 +239,7 @@ public function test_batch()
'batch_targets' => [1, 2, 3]
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -257,7 +259,7 @@ public function test_batch()

//存在しないアップロードカテゴリIDを指定した場合、
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(404);
//戻る値を確認
Expand All @@ -270,7 +272,7 @@ public function test_batch()
'batch_targets' => [1, 2, 3]
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_categories/batch.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(500);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license https://basercms.net/license/index.html MIT License
*/

namespace BcUploader\Test\TestCase\Controller\Api;
namespace BcUploader\Test\TestCase\Controller;

use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
Expand Down Expand Up @@ -61,6 +61,8 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
$this->truncateTable('uploader_categories');
$this->truncateTable('uploader_files');
}

/**
Expand All @@ -73,7 +75,7 @@ public function test_view()
UploaderConfigFactory::make(['name' => 'name_1', 'value' => 'value_1'])->persist();
UploaderConfigFactory::make(['name' => 'name_2', 'value' => 'value_2'])->persist();
//APIを呼ぶ
$this->get("/baser/api/bc-uploader/uploader_configs/view.json?token=" . $this->accessToken);
$this->get("/baser/api/admin/bc-uploader/uploader_configs/view.json?token=" . $this->accessToken);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -93,7 +95,7 @@ public function test_edit()
'name_add' => 'value_add'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -106,7 +108,7 @@ public function test_edit()
'name_add' => 'value_edit'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseSuccess();
//戻る値を確認
Expand All @@ -119,7 +121,7 @@ public function test_edit()
'test'
];
//APIを呼ぶ
$this->post("/baser/api/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
$this->post("/baser/api/admin/bc-uploader/uploader_configs/edit.json?token=" . $this->accessToken, $data);
//ステータスを確認
$this->assertResponseCode(500);
//戻る値を確認
Expand Down
Loading