Skip to content

Commit 1b3b4ba

Browse files
authored
Test: Simplify mocks (#10)
1 parent 852677b commit 1b3b4ba

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

tests/Feature/WpOrg/Api/ClientTest.php

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Tests\Feature\WpOrg\Api;
66

7+
use Composer\Util\HttpDownloader;
78
use Mockery;
89
use TypistTech\WpOrgClosedPlugin\WpOrg\Api\Cache;
910
use TypistTech\WpOrgClosedPlugin\WpOrg\Api\Client;
@@ -48,15 +49,7 @@
4849
it('returns true if and only if the plugin is closed', function (string $slug, bool $expected): void {
4950
$loop = $this->loop();
5051
$httpDownloader = $loop->getHttpDownloader();
51-
52-
$cache = Mockery::mock(Cache::class);
53-
$cache->allows()
54-
->read()
55-
->withAnyArgs()
56-
->andReturnNull();
57-
$cache->allows()
58-
->write()
59-
->withAnyArgs();
52+
$cache = Mockery::spy(Cache::class);
6053

6154
$client = new Client($httpDownloader, $loop, $cache);
6255

@@ -80,10 +73,7 @@
8073

8174
it('reads from cache', function (string $slug, bool $expected): void {
8275
$loop = $this->loop();
83-
84-
$httpDownloader = Mockery::mock(
85-
$loop->getHttpDownloader()
86-
);
76+
$httpDownloader = Mockery::spy(HttpDownloader::class);
8777

8878
$cache = Mockery::spy(Cache::class);
8979
$cache->expects()

0 commit comments

Comments
 (0)