-
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.
- Loading branch information
1 parent
fa8bcdf
commit d85a3b8
Showing
4 changed files
with
42 additions
and
3 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 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,39 @@ | ||
<?php | ||
|
||
namespace ProgrammatorDev\OpenWeatherMap\Test\Integration; | ||
|
||
use ProgrammatorDev\Api\Builder\CacheBuilder; | ||
use ProgrammatorDev\OpenWeatherMap\Resource\Resource; | ||
use ProgrammatorDev\OpenWeatherMap\Resource\Util\CacheTrait; | ||
use ProgrammatorDev\OpenWeatherMap\Test\AbstractTest; | ||
use Psr\Cache\CacheItemPoolInterface; | ||
|
||
class CacheTraitTest extends AbstractTest | ||
{ | ||
private Resource $resource; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$pool = $this->createMock(CacheItemPoolInterface::class); | ||
$cacheBuilder = new CacheBuilder($pool); | ||
|
||
$this->api->setCacheBuilder($cacheBuilder); | ||
|
||
$this->resource = new class($this->api) extends Resource { | ||
use CacheTrait; | ||
|
||
public function getCacheTtl(): ?int | ||
{ | ||
return $this->api->getCacheBuilder()?->getTtl(); | ||
} | ||
}; | ||
} | ||
|
||
public function testMethods(): void | ||
{ | ||
$this->assertSame(600, $this->resource->withCacheTtl(600)->getCacheTtl()); | ||
$this->assertSame(60, $this->resource->getCacheTtl()); // back to default value | ||
} | ||
} |