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

CustomContentAppHelperTest::searchControl() ユニットテスト #3958

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,5 @@ public function testExecCommand()

$this->assertEquals(0, $rs['code']);
$this->assertEquals("A script named install would override a Composer command and has been skipped", $rs['out'][0]);
$this->assertStringContainsString("Loading composer repositories with package information", $rs['out'][1]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function getEntryUrl(CustomEntry $entry, $full = true)
* @return string
* @checked
* @noTodo
* @unitTest
*/
public function searchControl(CustomLink $customLink, array $options = []): string
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
use BaserCore\Service\BcDatabaseServiceInterface;
use BaserCore\Test\Scenario\SitesScenario;
use BaserCore\TestSuite\BcTestCase;
use BaserCore\Utility\BcUtil;
use BcCustomContent\Model\Entity\CustomLink;
use BcCustomContent\Service\CustomContentsServiceInterface;
use BcCustomContent\Service\CustomEntriesServiceInterface;
use BcCustomContent\Service\CustomLinksServiceInterface;
use BcCustomContent\Service\CustomTablesServiceInterface;
use BcCustomContent\Test\Factory\CustomEntryFactory;
use BcCustomContent\Test\Factory\CustomFieldFactory;
use BcCustomContent\Test\Factory\CustomLinkFactory;
use BcCustomContent\Test\Scenario\CustomContentsScenario;
use BcCustomContent\Test\Scenario\CustomEntriesScenario;
use BcCustomContent\View\Helper\CustomContentAppHelper;
use Cake\Core\Configure;
use Cake\Core\Plugin;
use Cake\View\View;
use CakephpFixtureFactories\Scenario\ScenarioAwareTrait;

Expand All @@ -33,6 +37,10 @@ public function setUp(): void
{
parent::setUp();
$this->CustomContentAppHelper = new CustomContentAppHelper(new View());
BcUtil::includePluginClass('BcCustomContent');
$plugins = Plugin::getCollection();
$this->Plugin = $plugins->create('BcCustomContent');
$plugins->add($this->Plugin);
}
/**
* tearDown
Expand Down Expand Up @@ -140,7 +148,28 @@ public function test_getEntryUrl()
*/
public function test_searchControl()
{
$this->markTestIncomplete('このテストはまだ実装されていません。');
//サービスをコル
$dataBaseService = $this->getService(BcDatabaseServiceInterface::class);
$customTable = $this->getService(CustomTablesServiceInterface::class);
$customLinksService = $this->getService(CustomLinksServiceInterface::class);
//データを生成
$this->loadFixtureScenario(CustomContentsScenario::class);
CustomFieldFactory::make(['id' => 1, 'title' => 'テキスト60', 'type' => 'BcCcText', 'status' => 1])->persist();
CustomLinkFactory::make(['id' => 1, 'custom_table_id' => 1, 'custom_field_id' => 1])->persist();
CustomLinkFactory::make(['id' => 2, 'custom_table_id' => 1, 'custom_field_id' => 2])->persist();
$customTable->create(['type' => 'contact', 'name' => 'contact']);

//テストを実行

$rs = $this->CustomContentAppHelper->searchControl($customLinksService->get(1));
$this->assertTextContains('<span class="bca-textbox"><input type="text"', $rs);

//異常テスト
$rs = $this->CustomContentAppHelper->searchControl($customLinksService->get(2));
$this->assertEquals('', $rs);

//不要なテーブルを削除
$dataBaseService->dropTable('custom_entry_1_contact');
}

/**
Expand Down
Loading