mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 09:03:07 +03:00
Migrated CloseDbConnectionEventListenerDelegatorTest to use PHPUnit mocks
This commit is contained in:
parent
92ddd2eebe
commit
3608a6d068
1 changed files with 7 additions and 10 deletions
|
@ -4,23 +4,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace ShlinkioTest\Shlink\Core\EventDispatcher;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Prophecy\Prophecy\ObjectProphecy;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Shlinkio\Shlink\Common\Doctrine\ReopeningEntityManagerInterface;
|
||||
use Shlinkio\Shlink\Core\EventDispatcher\CloseDbConnectionEventListenerDelegator;
|
||||
|
||||
class CloseDbConnectionEventListenerDelegatorTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
private CloseDbConnectionEventListenerDelegator $delegator;
|
||||
private ObjectProphecy $container;
|
||||
private MockObject $container;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->container = $this->prophesize(ContainerInterface::class);
|
||||
$this->container = $this->createMock(ContainerInterface::class);
|
||||
$this->delegator = new CloseDbConnectionEventListenerDelegator();
|
||||
}
|
||||
|
||||
|
@ -35,12 +32,12 @@ class CloseDbConnectionEventListenerDelegatorTest extends TestCase
|
|||
};
|
||||
};
|
||||
|
||||
$em = $this->prophesize(ReopeningEntityManagerInterface::class);
|
||||
$getEm = $this->container->get('em')->willReturn($em->reveal());
|
||||
$this->container->expects($this->once())->method('get')->with($this->equalTo('em'))->willReturn(
|
||||
$this->createMock(ReopeningEntityManagerInterface::class),
|
||||
);
|
||||
|
||||
($this->delegator)($this->container->reveal(), '', $callback);
|
||||
($this->delegator)($this->container, '', $callback);
|
||||
|
||||
self::assertTrue($callbackInvoked);
|
||||
$getEm->shouldHaveBeenCalledOnce();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue