From 47e45b3012fba968aa7811cc5a8e44595581e4d7 Mon Sep 17 00:00:00 2001 From: tienvx Date: Sat, 16 Jul 2022 00:07:53 +0700 Subject: [PATCH] Test commands require target and value --- .../Command/Runner/AlertCommandRunnerTest.php | 12 ++++++ tests/Command/Runner/AssertionRunnerTest.php | 38 +++++++++++++++++++ .../Runner/CustomCommandRunnerTest.php | 14 +++++++ .../Runner/KeyboardCommandRunnerTest.php | 13 +++++++ .../Command/Runner/MouseCommandRunnerTest.php | 38 +++++++++++++++++++ tests/Command/Runner/RunnerTestCase.php | 14 +++++++ .../Runner/ScriptCommandRunnerTest.php | 17 +++++++++ .../Command/Runner/StoreCommandRunnerTest.php | 26 +++++++++++++ .../Command/Runner/WaitCommandRunnerTest.php | 24 ++++++++++++ .../Runner/WindowCommandRunnerTest.php | 15 ++++++++ 10 files changed, 211 insertions(+) diff --git a/tests/Command/Runner/AlertCommandRunnerTest.php b/tests/Command/Runner/AlertCommandRunnerTest.php index 78764c98..42de9f40 100644 --- a/tests/Command/Runner/AlertCommandRunnerTest.php +++ b/tests/Command/Runner/AlertCommandRunnerTest.php @@ -87,4 +87,16 @@ public function targetProvider(): array [AlertCommandRunner::ANSWER_PROMPT, 'anything', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + AlertCommandRunner::ANSWER_PROMPT, + ]; + } + + public function commandsRequireValue(): array + { + return []; + } } diff --git a/tests/Command/Runner/AssertionRunnerTest.php b/tests/Command/Runner/AssertionRunnerTest.php index b2f4c522..ea5097c3 100644 --- a/tests/Command/Runner/AssertionRunnerTest.php +++ b/tests/Command/Runner/AssertionRunnerTest.php @@ -602,4 +602,42 @@ public function targetProvider(): array [AssertionRunner::ASSERT, 'anything', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + AssertionRunner::ASSERT, + AssertionRunner::ASSERT_ALERT, + AssertionRunner::ASSERT_CONFIRMATION, + AssertionRunner::ASSERT_PROMPT, + AssertionRunner::ASSERT_TITLE, + AssertionRunner::ASSERT_TEXT, + AssertionRunner::ASSERT_NOT_TEXT, + AssertionRunner::ASSERT_VALUE, + AssertionRunner::ASSERT_EDITABLE, + AssertionRunner::ASSERT_NOT_EDITABLE, + AssertionRunner::ASSERT_ELEMENT_PRESENT, + AssertionRunner::ASSERT_ELEMENT_NOT_PRESENT, + AssertionRunner::ASSERT_CHECKED, + AssertionRunner::ASSERT_NOT_CHECKED, + AssertionRunner::ASSERT_SELECTED_VALUE, + AssertionRunner::ASSERT_NOT_SELECTED_VALUE, + AssertionRunner::ASSERT_SELECTED_LABEL, + AssertionRunner::ASSERT_NOT_SELECTED_LABEL, + ]; + } + + public function commandsRequireValue(): array + { + return [ + AssertionRunner::ASSERT, + AssertionRunner::ASSERT_TEXT, + AssertionRunner::ASSERT_NOT_TEXT, + AssertionRunner::ASSERT_VALUE, + AssertionRunner::ASSERT_SELECTED_VALUE, + AssertionRunner::ASSERT_NOT_SELECTED_VALUE, + AssertionRunner::ASSERT_SELECTED_LABEL, + AssertionRunner::ASSERT_NOT_SELECTED_LABEL, + ]; + } } diff --git a/tests/Command/Runner/CustomCommandRunnerTest.php b/tests/Command/Runner/CustomCommandRunnerTest.php index ba5d77d3..eb5e9ea9 100644 --- a/tests/Command/Runner/CustomCommandRunnerTest.php +++ b/tests/Command/Runner/CustomCommandRunnerTest.php @@ -54,4 +54,18 @@ public function targetProvider(): array [CustomCommandRunner::UPLOAD, 'xpath=//path/to/element', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + CustomCommandRunner::UPLOAD, + ]; + } + + public function commandsRequireValue(): array + { + return [ + CustomCommandRunner::UPLOAD, + ]; + } } diff --git a/tests/Command/Runner/KeyboardCommandRunnerTest.php b/tests/Command/Runner/KeyboardCommandRunnerTest.php index a475ca28..276d2719 100644 --- a/tests/Command/Runner/KeyboardCommandRunnerTest.php +++ b/tests/Command/Runner/KeyboardCommandRunnerTest.php @@ -64,4 +64,17 @@ public function targetProvider(): array [KeyboardCommandRunner::SEND_KEYS, 'xpath=//path/to/element', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + KeyboardCommandRunner::TYPE, + KeyboardCommandRunner::SEND_KEYS, + ]; + } + + public function commandsRequireValue(): array + { + return []; + } } diff --git a/tests/Command/Runner/MouseCommandRunnerTest.php b/tests/Command/Runner/MouseCommandRunnerTest.php index f9762668..2b42ec12 100644 --- a/tests/Command/Runner/MouseCommandRunnerTest.php +++ b/tests/Command/Runner/MouseCommandRunnerTest.php @@ -575,4 +575,42 @@ public function targetProvider(): array [MouseCommandRunner::CLICK, 'xpath=//path/to/element', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + MouseCommandRunner::ADD_SELECTION, + MouseCommandRunner::REMOVE_SELECTION, + MouseCommandRunner::CHECK, + MouseCommandRunner::UNCHECK, + MouseCommandRunner::CLICK, + MouseCommandRunner::CLICK_AT, + MouseCommandRunner::DOUBLE_CLICK, + MouseCommandRunner::DOUBLE_CLICK_AT, + MouseCommandRunner::DRAG_AND_DROP_TO_OBJECT, + MouseCommandRunner::MOUSE_DOWN, + MouseCommandRunner::MOUSE_DOWN_AT, + MouseCommandRunner::MOUSE_MOVE_AT, + MouseCommandRunner::MOUSE_OUT, + MouseCommandRunner::MOUSE_OVER, + MouseCommandRunner::MOUSE_UP, + MouseCommandRunner::MOUSE_UP_AT, + MouseCommandRunner::SELECT, + ]; + } + + public function commandsRequireValue(): array + { + return [ + MouseCommandRunner::ADD_SELECTION, + MouseCommandRunner::REMOVE_SELECTION, + MouseCommandRunner::CLICK_AT, + MouseCommandRunner::DOUBLE_CLICK_AT, + MouseCommandRunner::DRAG_AND_DROP_TO_OBJECT, + MouseCommandRunner::MOUSE_DOWN_AT, + MouseCommandRunner::MOUSE_MOVE_AT, + MouseCommandRunner::MOUSE_UP_AT, + MouseCommandRunner::SELECT, + ]; + } } diff --git a/tests/Command/Runner/RunnerTestCase.php b/tests/Command/Runner/RunnerTestCase.php index be6604f3..54565606 100644 --- a/tests/Command/Runner/RunnerTestCase.php +++ b/tests/Command/Runner/RunnerTestCase.php @@ -53,4 +53,18 @@ public function testValidateTarget(string $commandString, $target, bool $valid): } abstract public function targetProvider(): array; + + public function testGetCommandsRequireTarget(): void + { + $this->assertSame($this->commandsRequireTarget(), $this->runner->getCommandsRequireTarget()); + } + + abstract public function commandsRequireTarget(): array; + + public function testGetCommandsRequireValue(): void + { + $this->assertSame($this->commandsRequireValue(), $this->runner->getCommandsRequireValue()); + } + + abstract public function commandsRequireValue(): array; } diff --git a/tests/Command/Runner/ScriptCommandRunnerTest.php b/tests/Command/Runner/ScriptCommandRunnerTest.php index b8cd47ef..cdfa8625 100644 --- a/tests/Command/Runner/ScriptCommandRunnerTest.php +++ b/tests/Command/Runner/ScriptCommandRunnerTest.php @@ -68,4 +68,21 @@ public function targetProvider(): array [ScriptCommandRunner::RUN_SCRIPT, 'anything', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + ScriptCommandRunner::RUN_SCRIPT, + ScriptCommandRunner::EXECUTE_SCRIPT, + ScriptCommandRunner::EXECUTE_ASYNC_SCRIPT, + ]; + } + + public function commandsRequireValue(): array + { + return [ + ScriptCommandRunner::EXECUTE_SCRIPT, + ScriptCommandRunner::EXECUTE_ASYNC_SCRIPT, + ]; + } } diff --git a/tests/Command/Runner/StoreCommandRunnerTest.php b/tests/Command/Runner/StoreCommandRunnerTest.php index 0ad2034a..6e4f914a 100644 --- a/tests/Command/Runner/StoreCommandRunnerTest.php +++ b/tests/Command/Runner/StoreCommandRunnerTest.php @@ -145,4 +145,30 @@ public function targetProvider(): array [StoreCommandRunner::STORE_JSON, '{"key": "value"}', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + StoreCommandRunner::STORE_ATTRIBUTE, + StoreCommandRunner::STORE_ELEMENT_COUNT, + StoreCommandRunner::STORE_JSON, + StoreCommandRunner::STORE_TEXT, + StoreCommandRunner::STORE_TITLE, + StoreCommandRunner::STORE_VALUE, + StoreCommandRunner::STORE_WINDOW_HANDLE, + ]; + } + + public function commandsRequireValue(): array + { + return [ + StoreCommandRunner::STORE, + StoreCommandRunner::STORE_ATTRIBUTE, + StoreCommandRunner::STORE_ELEMENT_COUNT, + StoreCommandRunner::STORE_JSON, + StoreCommandRunner::STORE_TEXT, + StoreCommandRunner::STORE_TITLE, + StoreCommandRunner::STORE_VALUE, + ]; + } } diff --git a/tests/Command/Runner/WaitCommandRunnerTest.php b/tests/Command/Runner/WaitCommandRunnerTest.php index bed3b764..2f6d9e32 100644 --- a/tests/Command/Runner/WaitCommandRunnerTest.php +++ b/tests/Command/Runner/WaitCommandRunnerTest.php @@ -185,4 +185,28 @@ public function targetProvider(): array [WaitCommandRunner::WAIT_FOR_ELEMENT_VISIBLE, 'xpath=//path/to/element', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + WaitCommandRunner::WAIT_FOR_ELEMENT_EDITABLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_EDITABLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_PRESENT, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_PRESENT, + WaitCommandRunner::WAIT_FOR_ELEMENT_VISIBLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_VISIBLE, + ]; + } + + public function commandsRequireValue(): array + { + return [ + WaitCommandRunner::WAIT_FOR_ELEMENT_EDITABLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_EDITABLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_PRESENT, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_PRESENT, + WaitCommandRunner::WAIT_FOR_ELEMENT_VISIBLE, + WaitCommandRunner::WAIT_FOR_ELEMENT_NOT_VISIBLE, + ]; + } } diff --git a/tests/Command/Runner/WindowCommandRunnerTest.php b/tests/Command/Runner/WindowCommandRunnerTest.php index ba24e40b..dfbf5ff1 100644 --- a/tests/Command/Runner/WindowCommandRunnerTest.php +++ b/tests/Command/Runner/WindowCommandRunnerTest.php @@ -148,4 +148,19 @@ public function targetProvider(): array [WindowCommandRunner::SELECT_FRAME, 'xpath=//path/to/element', true], ]; } + + public function commandsRequireTarget(): array + { + return [ + WindowCommandRunner::OPEN, + WindowCommandRunner::SET_WINDOW_SIZE, + WindowCommandRunner::SELECT_WINDOW, + WindowCommandRunner::SELECT_FRAME, + ]; + } + + public function commandsRequireValue(): array + { + return []; + } }