diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 3cd8f9b62c..01c0e2d509 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -21,9 +21,9 @@
-
-
-
+
+ plugins/bc-editor-template/tests/TestCase
+
plugins/bc-favorite/tests/TestCase
diff --git a/plugins/bc-custom-content/tests/Scenario/CustomTablesScenario.php b/plugins/bc-custom-content/tests/Scenario/CustomTablesScenario.php
index 138d55954d..d64bf6f91c 100644
--- a/plugins/bc-custom-content/tests/Scenario/CustomTablesScenario.php
+++ b/plugins/bc-custom-content/tests/Scenario/CustomTablesScenario.php
@@ -11,8 +11,7 @@
namespace BcCustomContent\Test\Scenario;
-use BcCustomContent\Test\Factory\CustomFieldFactory;
-use BcCustomContent\Test\Factory\CustomLinkFactory;
+use BaserCore\Test\Factory\PluginFactory;
use BcCustomContent\Test\Factory\CustomTableFactory;
use CakephpFixtureFactories\Scenario\FixtureScenarioInterface;
diff --git a/plugins/bc-editor-template/tests/Scenario/EditorTemplatesScenario.php b/plugins/bc-editor-template/tests/Scenario/EditorTemplatesScenario.php
index d768c12378..e3ac72004e 100644
--- a/plugins/bc-editor-template/tests/Scenario/EditorTemplatesScenario.php
+++ b/plugins/bc-editor-template/tests/Scenario/EditorTemplatesScenario.php
@@ -27,7 +27,7 @@ class EditorTemplatesScenario implements FixtureScenarioInterface
public function load(...$args)
{
EditorTemplateFactory::make([
- 'id' => '1',
+ 'id' => '11',
'name' => '画像(左)とテキスト',
'image' => 'template1.gif',
'description' => '画像を左に配置し、その右にテキストを配置するブロックです。',
@@ -44,7 +44,7 @@ public function load(...$args)
'created' => '2015-01-27 12:56:52'
])->persist();
EditorTemplateFactory::make([
- 'id' => '2',
+ 'id' => '12',
'name' => '画像(右)とテキスト',
'image' => 'template2.gif',
'description' => '画像を右に配置し、その左にテキストを配置するブロックです。',
@@ -61,7 +61,7 @@ public function load(...$args)
'created' => '2015-01-27 12:56:52'
])->persist();
EditorTemplateFactory::make([
- 'id' => '3',
+ 'id' => '13',
'name' => 'テキスト2段組',
'image' => 'template3.gif',
'description' => 'テキストを左右に2段組するブロックです。',
diff --git a/plugins/bc-editor-template/tests/TestCase/Controller/Admin/EditorTemplatesControllerTest.php b/plugins/bc-editor-template/tests/TestCase/Controller/Admin/EditorTemplatesControllerTest.php
index 1a040d7ed3..353e11da69 100644
--- a/plugins/bc-editor-template/tests/TestCase/Controller/Admin/EditorTemplatesControllerTest.php
+++ b/plugins/bc-editor-template/tests/TestCase/Controller/Admin/EditorTemplatesControllerTest.php
@@ -13,6 +13,7 @@
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
+use BaserCore\Utility\BcContainerTrait;
use BcEditorTemplate\Test\Scenario\EditorTemplatesScenario;
use Cake\Datasource\ConnectionManager;
use Cake\Event\Event;
@@ -30,6 +31,7 @@ class EditorTemplatesControllerTest extends BcTestCase
* ScenarioAwareTrait
*/
use ScenarioAwareTrait;
+ use BcContainerTrait;
use IntegrationTestTrait;
/**
@@ -51,6 +53,7 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
+ $this->truncateTable('editor_templates');
}
/**
@@ -112,7 +115,7 @@ public function testBeforeEditEvent()
$data = [
'name' => 'japan'
];
- $this->post('/baser/admin/bc-editor-template/editor_templates/edit/1', $data);
+ $this->post('/baser/admin/bc-editor-template/editor_templates/edit/11', $data);
$editorTemplates = $this->getTableLocator()->get('BcEditorTemplate.EditorTemplates');
$query = $editorTemplates->find()->where(['name' => 'beforeAdd']);
$this->assertEquals(1, $query->count());
@@ -135,7 +138,7 @@ public function testAfterEditEvent()
$data = [
'name' => 'japan2'
];
- $this->post('/baser/admin/bc-editor-template/editor_templates/edit/1', $data);
+ $this->post('/baser/admin/bc-editor-template/editor_templates/edit/11', $data);
$editorTemplates = $this->getTableLocator()->get('BcEditorTemplate.EditorTemplates');
$query = $editorTemplates->find()->where(['name' => 'afterAdd']);
$this->assertEquals(1, $query->count());
diff --git a/plugins/bc-editor-template/tests/TestCase/Controller/Api/Admin/EditorTemplatesControllerTest.php b/plugins/bc-editor-template/tests/TestCase/Controller/Api/Admin/EditorTemplatesControllerTest.php
index 7376ca2694..5beb046bc5 100644
--- a/plugins/bc-editor-template/tests/TestCase/Controller/Api/Admin/EditorTemplatesControllerTest.php
+++ b/plugins/bc-editor-template/tests/TestCase/Controller/Api/Admin/EditorTemplatesControllerTest.php
@@ -13,6 +13,7 @@
use BaserCore\Test\Scenario\InitAppScenario;
use BaserCore\TestSuite\BcTestCase;
+use BaserCore\Utility\BcContainerTrait;
use BcEditorTemplate\Test\Scenario\EditorTemplatesScenario;
use Cake\TestSuite\IntegrationTestTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
@@ -27,6 +28,7 @@ class EditorTemplatesControllerTest extends BcTestCase
* ScenarioAwareTrait
*/
use ScenarioAwareTrait;
+ use BcContainerTrait;
use IntegrationTestTrait;
/**
@@ -60,6 +62,7 @@ public function setUp(): void
public function tearDown(): void
{
parent::tearDown();
+ $this->truncateTable('editor_templates');
}
/**
@@ -83,7 +86,7 @@ public function test_view()
{
//データを生成
$this->loadFixtureScenario(EditorTemplatesScenario::class);
- $this->get('/baser/api/admin/bc-editor-template/editor_templates/view/1.json?token=' . $this->accessToken);
+ $this->get('/baser/api/admin/bc-editor-template/editor_templates/view/11.json?token=' . $this->accessToken);
//ステータスを確認
$this->assertResponseOk();
//戻る値を確認
@@ -135,7 +138,7 @@ public function test_add()
public function test_edit()
{
$this->loadFixtureScenario(EditorTemplatesScenario::class);
- $this->post('/baser/api/admin/bc-editor-template/editor_templates/edit/1.json?token=' . $this->accessToken, ['name' => 'name edit']);
+ $this->post('/baser/api/admin/bc-editor-template/editor_templates/edit/11.json?token=' . $this->accessToken, ['name' => 'name edit']);
//ステータスを確認
$this->assertResponseOk();
//戻る値を確認
@@ -152,7 +155,7 @@ public function test_edit()
$this->assertEquals('データが見つかりません。', $result->message);
//無効なIDを指定した場合、
- $this->post('/baser/api/admin/bc-editor-template/editor_templates/edit/1.json?token=' . $this->accessToken, ['name' => '']);
+ $this->post('/baser/api/admin/bc-editor-template/editor_templates/edit/11.json?token=' . $this->accessToken, ['name' => '']);
//ステータスを確認
$this->assertResponseCode(400);
//戻る値を確認
@@ -168,7 +171,7 @@ public function test_delete()
{
//データを生成
$this->loadFixtureScenario(EditorTemplatesScenario::class);
- $this->post('/baser/api/admin/bc-editor-template/editor_templates/delete/1.json?token=' . $this->accessToken);
+ $this->post('/baser/api/admin/bc-editor-template/editor_templates/delete/11.json?token=' . $this->accessToken);
//ステータスを確認
$this->assertResponseOk();
//戻る値を確認
@@ -198,6 +201,6 @@ public function test_list()
$this->assertResponseOk();
//戻る値を確認
$result = json_decode((string)$this->_response->getBody());
- $this->assertEquals(get_object_vars($result->editorTemplates)[3], 'テキスト2段組');
+ $this->assertEquals(get_object_vars($result->editorTemplates)[13], 'テキスト2段組');
}
}
diff --git a/plugins/bc-editor-template/tests/TestCase/Service/EditorTemplatesServiceTest.php b/plugins/bc-editor-template/tests/TestCase/Service/EditorTemplatesServiceTest.php
index 998eca259d..c40a059b07 100644
--- a/plugins/bc-editor-template/tests/TestCase/Service/EditorTemplatesServiceTest.php
+++ b/plugins/bc-editor-template/tests/TestCase/Service/EditorTemplatesServiceTest.php
@@ -12,8 +12,10 @@
namespace BcEditorTemplate\Test\TestCase\Service;
use BaserCore\TestSuite\BcTestCase;
+use BaserCore\Utility\BcContainerTrait;
use BcEditorTemplate\Service\EditorTemplatesService;
use BcEditorTemplate\Test\Scenario\EditorTemplatesScenario;
+use Cake\TestSuite\IntegrationTestTrait;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;
/**
@@ -26,6 +28,8 @@ class EditorTemplatesServiceTest extends BcTestCase
* ScenarioAwareTrait
*/
use ScenarioAwareTrait;
+ use BcContainerTrait;
+ use IntegrationTestTrait;
/**
* set up
@@ -43,6 +47,7 @@ public function tearDown(): void
{
unset($this->EditorTemplatesService);
parent::tearDown();
+ $this->truncateTable('editor_templates');
}
/**
@@ -58,7 +63,7 @@ public function testConstruct()
*/
public function testGetNew()
{
- $this->assertEquals($this->EditorTemplatesService->getNew()->toArray(), []);
+ $this->assertEquals($this->EditorTemplatesService->getNew()->toArray(), ['_bc_upload_id' => 1]);
}
/**
@@ -70,10 +75,10 @@ public function testGet()
$this->loadFixtureScenario(EditorTemplatesScenario::class);
//Getサービスをコル
- $rs = $this->EditorTemplatesService->get(1);
+ $rs = $this->EditorTemplatesService->get(11);
//戻る値を確認
- $this->assertEquals(1, $rs->id);
+ $this->assertEquals(11, $rs->id);
$this->assertEquals('画像(左)とテキスト', $rs->name);
}
@@ -90,7 +95,7 @@ public function testGetIndex()
//戻る値を確認
$this->assertEquals(3, $rs->count());
- $this->assertEquals(1, $rs->all()->toArray()[0]->id);
+ $this->assertEquals(11, $rs->all()->toArray()[0]->id);
$this->assertEquals('画像(左)とテキスト', $rs->all()->toArray()[0]->name);
}
@@ -105,9 +110,9 @@ public function testGetList()
$rs = $this->EditorTemplatesService->getList();
//期待値
$expect = [
- 1 => '画像(左)とテキスト',
- 2 => '画像(右)とテキスト',
- 3 => 'テキスト2段組',
+ 11 => '画像(左)とテキスト',
+ 12 => '画像(右)とテキスト',
+ 13 => 'テキスト2段組',
];
//期待値を戻るかどうか確認
$this->assertEquals($expect, $rs);
@@ -140,7 +145,7 @@ public function testUpdate()
//データを生成
$this->loadFixtureScenario(EditorTemplatesScenario::class);
//対象メソッドをコル
- $rs = $this->EditorTemplatesService->update($this->EditorTemplatesService->get(1), ['name' => 'edited']);
+ $rs = $this->EditorTemplatesService->update($this->EditorTemplatesService->get(11), ['name' => 'edited']);
//エディターテンプレートの名前が変更されるか確認
$this->assertEquals('edited', $rs->name);
@@ -148,7 +153,7 @@ public function testUpdate()
$this->expectException('Cake\ORM\Exception\PersistenceFailedException');
$this->expectExceptionMessage('Entity save failure. Found the following errors (name.maxLength: "テンプレート名は50文字以内で入力してください。');
$data['name'] = str_repeat('a', 51);
- $this->EditorTemplatesService->update($this->EditorTemplatesService->get(1), $data);
+ $this->EditorTemplatesService->update($this->EditorTemplatesService->get(11), $data);
}
/**
@@ -159,13 +164,13 @@ public function testDelete()
//データを生成
$this->loadFixtureScenario(EditorTemplatesScenario::class);
//対象メソッドをコル
- $rs = $this->EditorTemplatesService->delete(1);
+ $rs = $this->EditorTemplatesService->delete(11);
//戻り値を確認
$this->assertTrue($rs);
//削除したエディターテンプレートが存在しないか確認すること
$this->expectException("Cake\Datasource\Exception\RecordNotFoundException");
- $this->EditorTemplatesService->get(1);
+ $this->EditorTemplatesService->get(11);
}
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 5a032b61db..ea7d2e57e7 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -95,6 +95,7 @@
(new Migrator())->runMany([
['plugin' => 'BaserCore'],
['plugin' => 'BcBlog'],
+ ['plugin' => 'BcEditorTemplate'],
['plugin' => 'BcSearchIndex'],
['plugin' => 'BcFavorite'],
['plugin' => 'BcContentLink'],