generated from pestphp/pest-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3dd3d03
commit cd354b8
Showing
9 changed files
with
137 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,5 +50,12 @@ | |
"@test:types", | ||
"@test:unit" | ||
] | ||
}, | ||
"extra": { | ||
"pest": { | ||
"plugins": [ | ||
"Pest\\Stressless\\Plugin" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pest\Stressless; | ||
|
||
use Pest\Contracts\Plugins\HandlesArguments; | ||
use Pest\Plugins\Concerns\HandleArguments; | ||
use Pest\Support\View; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class Plugin implements HandlesArguments | ||
{ | ||
use HandleArguments; | ||
|
||
/** | ||
* Creates a new instance of the plugin. | ||
*/ | ||
public function __construct() | ||
{ | ||
// .. | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handleArguments(array $arguments): array | ||
{ | ||
if (! array_key_exists(1, $arguments)) { | ||
return $arguments; | ||
} | ||
if ($arguments[1] !== 'stress') { | ||
return $arguments; | ||
} | ||
if (! array_key_exists(2, $arguments)) { | ||
View::render('components.badge', [ | ||
'type' => 'ERROR', | ||
'content' => 'Missing stress domain. Please provide a domain to stress.', | ||
]); | ||
|
||
exit(0); | ||
} | ||
|
||
$domain = $arguments[2]; | ||
|
||
$duration = 10; | ||
|
||
foreach ($arguments as $argument) { | ||
if (str_starts_with($argument, '--duration=')) { | ||
$duration = (int) str_replace('--duration=', '', $argument); | ||
} | ||
} | ||
|
||
$concurrency = 1; | ||
|
||
foreach ($arguments as $argument) { | ||
if (str_starts_with($argument, '--concurrency=')) { | ||
$concurrency = (int) str_replace('--concurrency=', '', $argument); | ||
} | ||
} | ||
|
||
stress($domain) | ||
->with($concurrency) | ||
->concurrentRequests() | ||
->for($duration) | ||
->seconds() | ||
->dd(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.