Skip to content

Commit

Permalink
Apply fixes from StyleCI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
pascualstromsnes authored Nov 17, 2019
1 parent 79073df commit 8b730c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/JokeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
class JokeFactory
{
const API_ENDPOINT = 'http://api.icndb.com/jokes/random';

protected $client;

public function __construct(Client $client = null)
{
$this->client = $client ?: new Client();
Expand All @@ -24,4 +24,3 @@ public function getRandomJoke()
return $joke->value->joke;
}
}

9 changes: 4 additions & 5 deletions tests/JokeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,25 @@
namespace Pascualstromsnes\ChuckNorrisJokes\Tests;

use GuzzleHttp\Client;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Exception\RequestException;
use PHPUnit\Framework\TestCase;
use Pascualstromsnes\ChuckNorrisJokes\JokeFactory;
use PHPUnit\Framework\TestCase;

class JokeFactoryTest extends TestCase
{
/** @test */
public function it_returns_a_random_joke()
{
$mock = new MockHandler([
new Response(200, [], '{ "type": "success", "value": { "id": 476, "joke": "Chuck Norris doesn\'t need a debugger, he just stares down the bug until the code confesses.", "categories": ["nerdy"] } }'),
new Response(200, [], '{ "type": "success", "value": { "id": 476, "joke": "Chuck Norris doesn\'t need a debugger, he just stares down the bug until the code confesses.", "categories": ["nerdy"] } }'),
]);

$handler = HandlerStack::create($mock);

$client = new Client(['handler' => $handler]);

$jokes = new JokeFactory($client);

$joke = $jokes->getRandomJoke();
Expand Down

0 comments on commit 8b730c5

Please sign in to comment.