diff --git a/plugins/bc-theme-config/src/View/Helper/BcThemeConfigHelper.php b/plugins/bc-theme-config/src/View/Helper/BcThemeConfigHelper.php index 41e9d8f604..48ae996990 100644 --- a/plugins/bc-theme-config/src/View/Helper/BcThemeConfigHelper.php +++ b/plugins/bc-theme-config/src/View/Helper/BcThemeConfigHelper.php @@ -49,6 +49,7 @@ class BcThemeConfigHelper extends Helper * @return void * @checked * @noTodo + * @unitTest */ public function mainImage($options = []) { @@ -94,6 +95,7 @@ public function mainImage($options = []) * @return void * @checked * @noTodo + * @unitTest */ public function logo($options = []) { @@ -120,6 +122,7 @@ public function logo($options = []) * @return string $tag テーマ画像のHTMLタグ * @checked * @noTodo + * @unitTest */ public function getThemeImage($name, $options = []) { diff --git a/plugins/bc-theme-config/tests/TestCase/View/Helper/BcThemeConfigHelperTest.php b/plugins/bc-theme-config/tests/TestCase/View/Helper/BcThemeConfigHelperTest.php index b9ea57dbcb..8d5e916867 100644 --- a/plugins/bc-theme-config/tests/TestCase/View/Helper/BcThemeConfigHelperTest.php +++ b/plugins/bc-theme-config/tests/TestCase/View/Helper/BcThemeConfigHelperTest.php @@ -11,13 +11,23 @@ namespace BcThemeConfig\Test\TestCase\View\Helper; +use BaserCore\Test\Scenario\InitAppScenario; use BaserCore\TestSuite\BcTestCase; +use BaserCore\View\BcAdminAppView; +use BcThemeConfig\View\Helper\BcThemeConfigHelper; +use CakephpFixtureFactories\Scenario\ScenarioAwareTrait; /** * BcThemeConfigHelperTest */ class BcThemeConfigHelperTest extends BcTestCase { + use ScenarioAwareTrait; + + /** + * @var $BcThemeConfigHelper + */ + private $BcThemeConfigHelper; /** * set up @@ -25,6 +35,9 @@ class BcThemeConfigHelperTest extends BcTestCase public function setUp(): void { parent::setUp(); + $this->loadFixtureScenario(InitAppScenario::class); + $BcAdminAppView = new BcAdminAppView($this->getRequest('/')); + $this->BcThemeConfigHelper = new BcThemeConfigHelper($BcAdminAppView); } /** @@ -41,9 +54,10 @@ public function tearDown(): void */ public function testLogo() { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $this->expectOutputRegex('/baserCMS/'); - $this->BcBaser->logo(); + ob_start(); + $this->BcThemeConfigHelper->logo(); + $result = ob_get_clean(); + $this->assertEquals('', $result); } /** @@ -54,9 +68,10 @@ public function testLogo() */ public function testMainImage($options, $expect) { - $this->markTestIncomplete('このテストは、まだ実装されていません。'); - $this->expectOutputRegex('/' . $expect . '/s'); - $this->BcBaser->mainImage($options); + ob_start(); + $this->BcThemeConfigHelper->mainImage($options); + $result = ob_get_clean(); + $this->assertEquals($expect, $result); } /** @@ -78,16 +93,23 @@ public function testMainImage($options, $expect) public static function mainImageDataProvider() { return [ - [[], 'コーポレートサイトにちょうどいい国産CMS'], - [['num' => 2], 'main_image_2'], - [['all' => true, 'num' => 2], '^(.*main_image_1.*main_image_2)'], - [['all' => true, 'class' => 'test-class', 'id' => 'test-id'], '^(.*id="test-id".*class="test-class")'], - [['popup' => true], 'href="\/theme\/nada-icons\/img\/main_image_1.jpg"'], - [['alt' => 'テスト'], 'alt="テスト"'], - [['link' => '/test'], 'href="\/test"'], - [['maxWidth' => '200', 'maxHeight' => '200'], 'width="200"'], - [['width' => '200', 'height' => '200'], '^(.*width="200".*height="200")'], - [['hoge' => 'hoge'], 'main_image_1'], + [[], ''], + [['num' => 2], ''], + [['all' => true, 'num' => 2], ''], + [['all' => true, 'class' => 'test-class', 'id' => 'test-id'], ''], + [['popup' => true], ''], + [['alt' => 'テスト'], 'テスト'], + [['link' => '/test'], ''], + [['maxWidth' => '200', 'maxHeight' => '200'], ''], + [['width' => '200', 'height' => '200'], ''], + [['hoge' => 'hoge'], ''], ]; }