/
VersionTest.php
48 lines (42 loc) · 1.32 KB
/
VersionTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types = 1);
/**
* /tests/Integration/Service/VersionTest.php
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@protacon.com>
*/
namespace App\Tests\Integration\Service;
use App\Service\Version;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Contracts\Cache\CacheInterface;
/**
* Class VersionTest
*
* @package App\Tests\Integration\Service
* @author TLe, Tarmo Leppänen <tarmo.leppanen@protacon.com>
*/
class VersionTest extends KernelTestCase
{
public function testThatLoggerIsCalledWhenCacheThrowsAnException(): void
{
/**
* @var MockObject|CacheInterface $cache
* @var MockObject|LoggerInterface $logger
*/
$cache = $this->getMockBuilder(CacheInterface::class)->getMock();
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$exception = new Exception('test exception');
$cache
->expects(static::once())
->method('get')
->willThrowException($exception);
$logger
->expects(static::once())
->method('error')
->with($exception->getMessage(), $exception->getTrace());
(new Version('', $cache))->setLogger($logger)->get();
}
}