Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F120836333
MollieMocksTrait.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
MollieMocksTrait.php
View Options
<?php
namespace
Tests
;
use
GuzzleHttp\Client
;
use
GuzzleHttp\Handler\MockHandler
;
use
GuzzleHttp\HandlerStack
;
use
GuzzleHttp\Middleware
;
use
Mollie\Api\MollieApiClient
;
trait
MollieMocksTrait
{
public
$mollieRequestHistory
=
[];
/**
* Make Mollie's Guzzle instance use a mock handler.
*
* @see http://docs.guzzlephp.org/en/stable/testing.html
*
* @return \GuzzleHttp\Handler\MockHandler
*/
public
function
mockMollie
()
{
$handler
=
HandlerStack
::
create
(
$mockHandler
=
new
MockHandler
()
);
$handler
->
push
(
Middleware
::
history
(
$this
->
mollieRequestHistory
)
);
$guzzle
=
new
Client
([
'handler'
=>
$handler
]);
$this
->
app
->
forgetInstance
(
'mollie.api.client'
);
$this
->
app
->
forgetInstance
(
'mollie.api'
);
$this
->
app
->
forgetInstance
(
'mollie'
);
$this
->
app
->
singleton
(
'mollie.api.client'
,
function
()
use
(
$guzzle
)
{
return
new
MollieApiClient
(
$guzzle
);
});
return
$mockHandler
;
}
public
function
unmockMollie
()
{
$this
->
app
->
forgetInstance
(
'mollie.api.client'
);
$this
->
app
->
forgetInstance
(
'mollie.api'
);
$this
->
app
->
forgetInstance
(
'mollie'
);
$guzzle
=
new
Client
();
$this
->
app
->
singleton
(
'mollie.api.client'
,
function
()
use
(
$guzzle
)
{
return
new
MollieApiClient
(
$guzzle
);
});
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Apr 24, 1:29 PM (9 h, 50 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f0/0f/61b46fdef5f00ed1ff6711c6a530
Default Alt Text
MollieMocksTrait.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline