generated from pestphp/pest-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v1.0.0-alpha.3'
- Loading branch information
Showing
10 changed files
with
148 additions
and
45 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
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 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,34 @@ | ||
<?xml version="1.0"?> | ||
<ruleset name="Custom ruleset"> | ||
<description>RealtyBloc API</description> | ||
|
||
<!-- What to scan --> | ||
<file>.</file> | ||
|
||
<!-- Show sniff and progress --> | ||
<arg value="spn"/> | ||
<arg name="colors"/> | ||
|
||
<!-- Strip the filepaths down to the relevant bit. --> | ||
<arg name="basepath" value="./"/> | ||
|
||
<!-- Enables parallel processing when available for faster results. --> | ||
<arg name="parallel" value="8"/> | ||
|
||
<!-- Only check the PHP files. JS files are checked separately with JSCS and JSHint. --> | ||
<arg name="extensions" value="php"/> | ||
|
||
<!-- Exclude the behavioral tests data. --> | ||
<exclude-pattern>/features/*</exclude-pattern> | ||
|
||
<!-- Exclude the temporary files directory. --> | ||
<exclude-pattern>/temp/*</exclude-pattern> | ||
|
||
<!-- Exclude the Composer Vendor directory. --> | ||
<exclude-pattern>/vendor/*</exclude-pattern> | ||
|
||
<!-- Exclude the Node Modules directory. --> | ||
<exclude-pattern>/node_modules/*</exclude-pattern> | ||
|
||
<rule ref="NekofarCodingStandard"/> | ||
</ruleset> |
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 |
---|---|---|
@@ -1,10 +1,26 @@ | ||
<?php | ||
|
||
/* | ||
* (c) Milad Nekofar <milad@nekofar.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nekofar\Pest\MockClient; | ||
|
||
function client(): MockClient | ||
use Pest\Plugin; | ||
|
||
Plugin::uses(ClientTrait::class); | ||
|
||
/** | ||
* Creates a new mock client or return an existing instance. | ||
* | ||
* @return object|MockClient | ||
*/ | ||
function mockClient() | ||
{ | ||
return new MockClient(); | ||
return test()->mockClient(); | ||
} |
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,33 @@ | ||
<?php | ||
|
||
/* | ||
* (c) Milad Nekofar <milad@nekofar.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nekofar\Pest\MockClient; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait ClientTrait | ||
{ | ||
/** | ||
* @var MockClient | ||
*/ | ||
protected $mockClient; | ||
|
||
/** | ||
* Creates a new mock client or return an existing instance. | ||
* | ||
* @return object|MockClient | ||
*/ | ||
public function mockClient() | ||
{ | ||
return $this->mockClient ?? ($this->mockClient = new MockClient()); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
use function Nekofar\Pest\MockClient\client; | ||
declare(strict_types=1); | ||
|
||
client(); | ||
use function Nekofar\Pest\MockClient\mockClient; | ||
|
||
mockClient()->assertRequestCount(0); |
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,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use GuzzleHttp\Psr7\Request; | ||
|
||
use function Nekofar\Pest\MockClient\mockClient; | ||
|
||
it('can send multiple requests', function (): void { | ||
$request = new Request('GET', '/'); | ||
|
||
mockClient()->sendRequest($request); | ||
mockClient()->sendRequest($request); | ||
|
||
expect(mockClient()->getRequests())->toHaveCount(2); | ||
}); |