Skip to content
Permalink
Browse files

tests: Added integration test for `Version` service.

  • Loading branch information...
tarlepp committed Sep 25, 2019
1 parent e98c62a commit 1b1cf9df342877ffb44c516c5e73fdee97538e3d
Showing with 48 additions and 0 deletions.
  1. +48 −0 tests/Integration/Service/VersionTest.php
@@ -0,0 +1,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();
}
}

0 comments on commit 1b1cf9d

Please sign in to comment.
You can’t perform that action at this time.