Skip to content

Commit

Permalink
Test commands require target and value
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Jul 15, 2022
1 parent 18d7da6 commit 47e45b3
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Command/Runner/AlertCommandRunnerTest.php
Expand Up @@ -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 [];
}
}
38 changes: 38 additions & 0 deletions tests/Command/Runner/AssertionRunnerTest.php
Expand Up @@ -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,
];
}
}
14 changes: 14 additions & 0 deletions tests/Command/Runner/CustomCommandRunnerTest.php
Expand Up @@ -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,
];
}
}
13 changes: 13 additions & 0 deletions tests/Command/Runner/KeyboardCommandRunnerTest.php
Expand Up @@ -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 [];
}
}
38 changes: 38 additions & 0 deletions tests/Command/Runner/MouseCommandRunnerTest.php
Expand Up @@ -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,
];
}
}
14 changes: 14 additions & 0 deletions tests/Command/Runner/RunnerTestCase.php
Expand Up @@ -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;
}
17 changes: 17 additions & 0 deletions tests/Command/Runner/ScriptCommandRunnerTest.php
Expand Up @@ -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,
];
}
}
26 changes: 26 additions & 0 deletions tests/Command/Runner/StoreCommandRunnerTest.php
Expand Up @@ -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,
];
}
}
24 changes: 24 additions & 0 deletions tests/Command/Runner/WaitCommandRunnerTest.php
Expand Up @@ -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,
];
}
}
15 changes: 15 additions & 0 deletions tests/Command/Runner/WindowCommandRunnerTest.php
Expand Up @@ -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 [];
}
}

0 comments on commit 47e45b3

Please sign in to comment.