- Issue created by @andileco
- Status changed to Needs review
about 1 year ago 3:33am 2 October 2023 - last update
about 1 year ago 10 pass - last update
about 1 year ago 10 pass - 🇨🇦Canada nikathone Ontario
Did a quick review of the code and some initial manual test. I think we need to create a follow up issue for adding test coverage or commit the current patch, then change its status to needs work and tag it with need tests.
- 🇺🇸United States andileco
Thank you, @nikathone! Let's commit this and then add tags for tests.
-
andileco →
committed 077d8527 on 5.0.x authored by
nikathone →
Issue #3390738 by andileco, nikathone: Dynamically hide chart types that...
-
andileco →
committed 077d8527 on 5.0.x authored by
nikathone →
- Status changed to Needs work
about 1 year ago 3:34pm 2 October 2023 - Status changed to Needs review
about 1 year ago 6:28pm 13 October 2023 - last update
about 1 year ago 11 pass - last update
about 1 year ago 11 pass - Status changed to Needs work
about 1 year ago 5:14pm 26 October 2023 - 🇨🇦Canada nikathone Ontario
+++ b/src/Element/Chart.php @@ -202,12 +203,11 @@ class Chart extends RenderElement implements ContainerFactoryPluginInterface { + throw new PluginNotFoundException($plugin->getChartName(), 'Chart type @type not supported by @plugin', [ + '@type' => $type_name, + '@plugin' => $plugin->getChartName(), + ]);
Maybe we should throw a logic exception here instead of the plugin not found one. This could be something like
throw new \LogicException(sprintf('The provided chart type "%s" is not supported by "%s" chart plugin library.', $type_name, $plugin->getChartName()));
.If you agree with the above then we should also update the test to catch the logic exception.
+++ b/tests/src/Kernel/ChartTypeSupportTest.php @@ -0,0 +1,58 @@ + $this->expectException(PluginNotFoundException::class); + $this->assertNotEmpty($this->renderer->renderRoot($element));
I don't think we need to assert that the element is not empty since our primary goal is to check for the exception. However we need to change the expected exception to
$this->expectException(\LogicException::class);
and also maybe check for the expected message to see if it includes our "not_supported" type and the "charts_test_library" something like$this->expectExceptionMessage('The provided chart type "not_supported" is not supported by "Charts Test Library" chart plugin library.');
should do.+++ b/tests/src/Kernel/ChartTypeSupportTest.php @@ -0,0 +1,58 @@ + $element = [ + '#type' => 'chart', + '#library' => 'charts_test_library', + '#chart_type' => 'bar', + ]; + + // Assert that bar chart type is supported. The chart should be rendered. + $this->assertNotEmpty($this->renderer->renderRoot($element)); +
This part is already covered by https://git.drupalcode.org/project/charts/-/blob/5.0.x/tests/src/Kernel/.... If for example in that test they were using a not supported type the test would fail.
- Merge request !73Issue #3390738 by diaodiallo: Dynamically hide chart types that are not... → (Merged) created by nikathone
- last update
12 months ago 12 pass - last update
12 months ago 12 pass - last update
12 months ago 12 pass - last update
12 months ago 13 pass - last update
12 months ago 13 pass - last update
12 months ago 13 pass - last update
12 months ago 13 pass - last update
12 months ago 13 pass -
andileco →
committed 647c9785 on 5.0.x authored by
nikathone →
Issue #3390738 by nikathone, andileco, diaodiallo: Dynamically hide...
-
andileco →
committed 647c9785 on 5.0.x authored by
nikathone →
- Status changed to Fixed
12 months ago 4:41am 6 December 2023 -
andileco →
committed a866ee16 on 5.0.x authored by
nikathone →
Issue #3390738 by nikathone, andileco, diaodiallo: Dynamically hide...
-
andileco →
committed a866ee16 on 5.0.x authored by
nikathone →
Automatically closed - issue fixed for 2 weeks with no activity.