mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat: moves visit to the core
This commit is contained in:
@ -19,7 +19,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.3.0",
|
"php": "^8.3.0",
|
||||||
"brianium/paratest": "^7.10.2",
|
"brianium/paratest": "^7.10.2",
|
||||||
"nunomaduro/collision": "^8.8.1",
|
"nunomaduro/collision": "^8.8.2",
|
||||||
"nunomaduro/termwind": "^2.3.1",
|
"nunomaduro/termwind": "^2.3.1",
|
||||||
"pestphp/pest-plugin": "^4.0.0",
|
"pestphp/pest-plugin": "^4.0.0",
|
||||||
"pestphp/pest-plugin-arch": "^4.0.0",
|
"pestphp/pest-plugin-arch": "^4.0.0",
|
||||||
@ -55,6 +55,7 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"pestphp/pest-dev-tools": "^4.0.0",
|
"pestphp/pest-dev-tools": "^4.0.0",
|
||||||
|
"pestphp/pest-plugin-browser": "^4.0.0",
|
||||||
"pestphp/pest-plugin-type-coverage": "^4.0.0",
|
"pestphp/pest-plugin-type-coverage": "^4.0.0",
|
||||||
"symfony/process": "^7.3.0"
|
"symfony/process": "^7.3.0"
|
||||||
},
|
},
|
||||||
|
|||||||
17
resources/views/installers/plugin-browser.php
Normal file
17
resources/views/installers/plugin-browser.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<div class="mx-2 mb-1">
|
||||||
|
<p>
|
||||||
|
<span>Using the <span class="text-yellow font-bold">visit()</span> function requires the Pest Plugin Browser to be installed.</span>
|
||||||
|
|
||||||
|
<span class="ml-1 text-yellow font-bold">Run:</span>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span class="text-gray mr-1">- </span>
|
||||||
|
<span>composer require pestphp/pest-plugin-browser:^4.0 --dev</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span class="text-gray mr-1">- </span>
|
||||||
|
<span>npx playwright install</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@ -102,6 +102,14 @@ final readonly class Configuration
|
|||||||
return Configuration\Project::getInstance();
|
return Configuration\Project::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the browser configuration.
|
||||||
|
*/
|
||||||
|
public function browser(): Browser\Configuration
|
||||||
|
{
|
||||||
|
return new Browser\Configuration;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Proxies calls to the uses method.
|
* Proxies calls to the uses method.
|
||||||
*
|
*
|
||||||
|
|||||||
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Pest\Browser\Api\ArrayablePendingAwaitablePage;
|
||||||
|
use Pest\Browser\Api\PendingAwaitablePage;
|
||||||
use Pest\Concerns\Expectable;
|
use Pest\Concerns\Expectable;
|
||||||
use Pest\Configuration;
|
use Pest\Configuration;
|
||||||
use Pest\Exceptions\AfterAllWithinDescribe;
|
use Pest\Exceptions\AfterAllWithinDescribe;
|
||||||
use Pest\Exceptions\BeforeAllWithinDescribe;
|
use Pest\Exceptions\BeforeAllWithinDescribe;
|
||||||
use Pest\Expectation;
|
use Pest\Expectation;
|
||||||
|
use Pest\Installers\PluginBrowser;
|
||||||
use Pest\Mutate\Contracts\MutationTestRunner;
|
use Pest\Mutate\Contracts\MutationTestRunner;
|
||||||
use Pest\Mutate\Repositories\ConfigurationRepository;
|
use Pest\Mutate\Repositories\ConfigurationRepository;
|
||||||
use Pest\PendingCalls\AfterEachCall;
|
use Pest\PendingCalls\AfterEachCall;
|
||||||
@ -303,3 +306,26 @@ if (! function_exists('fixture')) {
|
|||||||
return $fileRealPath;
|
return $fileRealPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! function_exists('visit')) {
|
||||||
|
/**
|
||||||
|
* Browse to the given URL.
|
||||||
|
*
|
||||||
|
* @template TUrl of array<int, string>|string
|
||||||
|
*
|
||||||
|
* @param TUrl $url
|
||||||
|
* @param array<string, mixed> $options
|
||||||
|
* @return (TUrl is array<int, string> ? ArrayablePendingAwaitablePage : PendingAwaitablePage)
|
||||||
|
*/
|
||||||
|
function visit(array|string $url, array $options = []): ArrayablePendingAwaitablePage|PendingAwaitablePage
|
||||||
|
{
|
||||||
|
if (! class_exists(\Pest\Browser\Configuration::class)) {
|
||||||
|
PluginBrowser::install();
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @phpstan-ignore-next-line
|
||||||
|
return test()->visit($url, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
15
src/Installers/PluginBrowser.php
Normal file
15
src/Installers/PluginBrowser.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Pest\Installers;
|
||||||
|
|
||||||
|
use Pest\Support\View;
|
||||||
|
|
||||||
|
final readonly class PluginBrowser
|
||||||
|
{
|
||||||
|
public static function install(): void
|
||||||
|
{
|
||||||
|
View::render('installers/plugin-browser');
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -6,7 +6,7 @@ namespace Pest;
|
|||||||
|
|
||||||
function version(): string
|
function version(): string
|
||||||
{
|
{
|
||||||
return '4.0.0-alpha.3';
|
return '4.0.0-alpha.4';
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDirectory(string $file = ''): string
|
function testDirectory(string $file = ''): string
|
||||||
|
|||||||
Reference in New Issue
Block a user