From d0a746bec0390a39cd3c5c6ba6e523dda0f5a47c Mon Sep 17 00:00:00 2001 From: thangnn Date: Tue, 7 May 2024 14:35:00 +0700 Subject: [PATCH] add unitTest_WidgetArea_setWidgets --- .../src/Model/Entity/WidgetArea.php | 1 + .../TestCase/Model/Entity/WidgetAreaTest.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/bc-widget-area/src/Model/Entity/WidgetArea.php b/plugins/bc-widget-area/src/Model/Entity/WidgetArea.php index 6b7bc83ff7..cd85632562 100644 --- a/plugins/bc-widget-area/src/Model/Entity/WidgetArea.php +++ b/plugins/bc-widget-area/src/Model/Entity/WidgetArea.php @@ -86,6 +86,7 @@ protected function _getWidgetsArray() * @return string|null * @checked * @noTodo + * @unitTest */ protected function _setWidgets($value) { diff --git a/plugins/bc-widget-area/tests/TestCase/Model/Entity/WidgetAreaTest.php b/plugins/bc-widget-area/tests/TestCase/Model/Entity/WidgetAreaTest.php index 78ac6c3671..357ab05ed0 100644 --- a/plugins/bc-widget-area/tests/TestCase/Model/Entity/WidgetAreaTest.php +++ b/plugins/bc-widget-area/tests/TestCase/Model/Entity/WidgetAreaTest.php @@ -44,6 +44,20 @@ public function test_getWidgetsArray() */ public function test_setWidgets() { - $this->markTestIncomplete('こちらのテストはまだ未確認です'); + $widgetArea = new WidgetArea(); + + //正常系実行 + $setWidgets = $this->execPrivateMethod($widgetArea, '_setWidgets', + [['test' => ['sort' => 1, 'name' => 'test']]]); + $this->assertEquals('YToxOntzOjQ6InRlc3QiO2E6Mjp7czo0OiJzb3J0IjtpOjE7czo0OiJuYW1lIjtzOjQ6InRlc3QiO319', + $setWidgets); + + //case is not array + $setWidgets = $this->execPrivateMethod($widgetArea, '_setWidgets', ['test']); + $this->assertEquals('test', $setWidgets); + + //case is array but value is empty + $setWidgets = $this->execPrivateMethod($widgetArea, '_setWidgets', [[]]); + $this->assertNull($setWidgets); } } \ No newline at end of file