Files
php-flasher/tests/Prime/Factory/FlasherFactoryTest.php
T
2024-05-05 19:44:39 +01:00

50 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace Flasher\Tests\Prime\Factory;
use Flasher\Prime\Factory\FlasherFactory;
use Flasher\Prime\Factory\NotificationFactory;
use Flasher\Prime\Notification\NotificationBuilderInterface;
use Flasher\Prime\Storage\StorageManagerInterface;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase;
final class FlasherFactoryTest extends TestCase
{
use MockeryPHPUnitIntegration;
public function testCreateNotificationBuilder(): void
{
$storageManager = \Mockery::mock(StorageManagerInterface::class);
$factory = new FlasherFactory($storageManager);
$builder = $factory->createNotificationBuilder();
$this->assertInstanceOf(NotificationBuilderInterface::class, $builder);
}
public function testStorageManagerForwardsAnyMethodCall(): void
{
$method = 'test_method';
$arguments = ['test_argument'];
$mockedInterface = \Mockery::mock(NotificationBuilderInterface::class);
$mockedInterface->allows($method)
->withArgs($arguments)
->andReturnTrue();
$storageManager = \Mockery::mock(StorageManagerInterface::class);
$factory = \Mockery::mock(NotificationFactory::class, [$storageManager])
->makePartial()
->allows('createNotificationBuilder')
->andReturns($mockedInterface)
->getMock();
$result = $factory->__call($method, $arguments); // @phpstan-ignore-line
$this->assertTrue($result);
}
}