From beaa305c6f0cc6d4b3bcebec89fb9e9cd2d5c598 Mon Sep 17 00:00:00 2001 From: J0rdyV <28193980+J0rdyV@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:00:35 +0200 Subject: [PATCH] CalculateActionTest --- .../Component/Action/CalculateActionTest.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/Component/Action/CalculateActionTest.php diff --git a/tests/Component/Action/CalculateActionTest.php b/tests/Component/Action/CalculateActionTest.php new file mode 100644 index 00000000..6df828d4 --- /dev/null +++ b/tests/Component/Action/CalculateActionTest.php @@ -0,0 +1,73 @@ + 'louis', + 'description' => 'LV', + 'sku' => '1', + ]; + + $format->setOptions([ + 'keys' => ['brand', 'description'], + ]); + + $this->assertEquals([ + 'brand' => 'louis', + 'description' => 'LV', + ], $format->apply($item)); + } + + public function test_it_should_not_retain_action_with_keys(): void + { + $format = new RetainAction(); + + $item = [ + 'brand' => 'louis', + 'description' => 'LV', + 'sku' => '1', + ]; + + $format->setOptions([ + 'keys' => [], + ]); + + $this->assertEquals([ + 'brand' => 'louis', + 'description' => 'LV', + 'sku' => '1', + ], $format->apply($item)); + } + + + public function test_it_should_do_a_retain_action_with_bad_keys(): void + { + $format = new RetainAction(); + + $item = [ + 'brand' => 'louis', + 'description' => 'LV', + 'sku' => '1', + 0 => [false], + ]; + + $format->setOptions([ + 'keys' => ['brand', 'description', 0, false, true, '', -1, 'the-unknown'], + ]); + + $this->assertEquals([ + 'brand' => 'louis', + 'description' => 'LV', + 0 => [false], + ], $format->apply($item)); + } +} \ No newline at end of file