ClientTest.php in Little helpers 7.2
File
tests/Rest/ClientTest.php
View source
<?php
namespace Drupal\little_helpers\Rest;
use Upal\DrupalUnitTestCase;
class ClientTest extends DrupalUnitTestCase {
protected function mockClient(string $endpoint = 'https://example.com', array $options = []) {
return $this
->getMockBuilder(Client::class)
->setConstructorArgs([
$endpoint,
$options,
])
->setMethods([
'sendRequest',
])
->getMock();
}
public function testAddSlash() {
$client = $this
->mockClient();
$client
->expects($this
->once())
->method('sendRequest')
->with('https://example.com/no-slash', $this
->anything())
->willReturn((object) [
'data' => '{}',
]);
$client
->get('no-slash');
}
}