Skip to content

Commit

Permalink
Added get() and method() shortcut to Factory, and --get, --post optio…
Browse files Browse the repository at this point in the history
…ns to command line
  • Loading branch information
nahime0 committed Nov 15, 2023
1 parent aec6e34 commit 623d761
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ public function method(string $method): self
return $this;
}

/**
* Force the test to use get method
*/
public function get(): self
{
return $this->method('get');
}

/**
* Force the test to use post method
*/
public function post(): self
{
return $this->method('post');
}

/**
* Specifies the payload to send for the test, if any.
* @param array<string, mixed> $payload
Expand Down
8 changes: 8 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public function handleArguments(array $arguments): array
$run->method(str_replace('--method=', '', $argument));
}

if ($argument === '--get') {
$run->get();
}

if($argument === '--post') {
$run->post();
}

if (str_starts_with($argument, '--payload=')) {
try {
$payload = json_decode(str_replace('--payload=', '', $argument),
Expand Down

0 comments on commit 623d761

Please sign in to comment.