mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 23:17:47 +01:00
chore: update the doc and improve phpstan annotations
This commit is contained in:
@@ -102,12 +102,12 @@ final class NotyBuilderTest extends TestCase
|
||||
|
||||
public function testSounds(): void
|
||||
{
|
||||
$this->notyBuilder->sounds('open', 'sound.mp3');
|
||||
$this->notyBuilder->sounds('sources', 'sound.mp3');
|
||||
|
||||
$envelope = $this->notyBuilder->getEnvelope();
|
||||
$options = $envelope->getNotification()->getOptions();
|
||||
|
||||
$this->assertSame(['sounds.open' => 'sound.mp3'], $options);
|
||||
$this->assertSame(['sounds.sources' => 'sound.mp3'], $options);
|
||||
}
|
||||
|
||||
public function testDocTitle(): void
|
||||
|
||||
@@ -57,6 +57,7 @@ final class EventDispatcherTest extends TestCase
|
||||
$event = new StoppableEvent();
|
||||
$listener = new StoppableEventListener();
|
||||
|
||||
$this->dispatcher->addListener($listener);
|
||||
$this->dispatcher->addListener($listener);
|
||||
$this->dispatcher->dispatch($event);
|
||||
|
||||
|
||||
@@ -76,4 +76,21 @@ final class TranslationListenerTest extends TestCase
|
||||
|
||||
$this->assertEquals($envelopes, $event->getEnvelopes());
|
||||
}
|
||||
|
||||
public function testTranslationThrowExceptionWithInvalidParams(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$eventDispatcher = new EventDispatcher();
|
||||
|
||||
$listener = new TranslationListener(new EchoTranslator());
|
||||
$eventDispatcher->addListener($listener);
|
||||
|
||||
$envelopes[] = new Envelope(new Notification(), new PresetStamp('created', ['resource' => new Notification()]));
|
||||
|
||||
$event = new PresentationEvent($envelopes, []);
|
||||
$eventDispatcher->dispatch($event);
|
||||
|
||||
$this->assertEquals($envelopes, $event->getEnvelopes());
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -4,20 +4,21 @@ 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 NotificationFactoryTest extends TestCase
|
||||
final class FlasherFactoryTest extends TestCase
|
||||
{
|
||||
use MockeryPHPUnitIntegration;
|
||||
|
||||
public function testCreateNotificationBuilder(): void
|
||||
{
|
||||
$storageManager = \Mockery::mock(StorageManagerInterface::class);
|
||||
$factory = new NotificationFactory($storageManager);
|
||||
$factory = new FlasherFactory($storageManager);
|
||||
|
||||
$builder = $factory->createNotificationBuilder();
|
||||
|
||||
@@ -35,7 +36,7 @@ final class NotificationFactoryTest extends TestCase
|
||||
->andReturnTrue();
|
||||
|
||||
$storageManager = \Mockery::mock(StorageManagerInterface::class);
|
||||
$factory = \Mockery::mock(NotificationFactory::class, [$storageManager]) // @phpstan-ignore-line
|
||||
$factory = \Mockery::mock(NotificationFactory::class, [$storageManager])
|
||||
->makePartial()
|
||||
->allows('createNotificationBuilder')
|
||||
->andReturns($mockedInterface)
|
||||
@@ -81,7 +81,7 @@ final class FlasherTest extends MockeryTestCase
|
||||
->get('alias')
|
||||
->andReturns(\Mockery::mock(NotificationFactoryInterface::class));
|
||||
|
||||
$result = $this->flasher->create('alias');
|
||||
$result = $this->flasher->use('alias');
|
||||
|
||||
$this->assertInstanceOf(NotificationFactoryInterface::class, $result);
|
||||
}
|
||||
|
||||
+12
-11
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Flasher\Tests\Prime\Notification;
|
||||
|
||||
use Flasher\Prime\Notification\FlasherBuilder;
|
||||
use Flasher\Prime\Notification\Notification;
|
||||
use Flasher\Prime\Notification\NotificationBuilder;
|
||||
use Flasher\Prime\Notification\NotificationBuilderInterface;
|
||||
@@ -22,7 +23,7 @@ use Flasher\Prime\Storage\StorageManagerInterface;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class NotificationBuilderTest extends TestCase
|
||||
final class FlasherBuilderTest extends TestCase
|
||||
{
|
||||
public function testAddSuccessMessage(): void
|
||||
{
|
||||
@@ -323,7 +324,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('created', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testAddUpdated(): void
|
||||
@@ -339,7 +340,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('updated', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testAddSaved(): void
|
||||
@@ -355,7 +356,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('saved', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testAddDeleted(): void
|
||||
@@ -371,7 +372,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('deleted', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testPreset(): void
|
||||
@@ -397,7 +398,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('someOperation', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testCreated(): void
|
||||
@@ -410,7 +411,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('created', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testUpdated(): void
|
||||
@@ -423,7 +424,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('updated', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testSaved(): void
|
||||
@@ -435,7 +436,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('saved', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testDeleted(): void
|
||||
@@ -447,7 +448,7 @@ final class NotificationBuilderTest extends TestCase
|
||||
|
||||
$this->assertInstanceOf(PresetStamp::class, $stamp);
|
||||
$this->assertSame('deleted', $stamp->getPreset());
|
||||
$this->assertSame(['resource' => 'resource'], $stamp->getParameters());
|
||||
$this->assertSame([':resource' => 'resource'], $stamp->getParameters());
|
||||
}
|
||||
|
||||
public function testWithStamps(): void
|
||||
@@ -526,6 +527,6 @@ final class NotificationBuilderTest extends TestCase
|
||||
/** @var StorageManagerInterface $storageManager */
|
||||
$storageManager = $storageManager ?: $this->createMock(StorageManagerInterface::class);
|
||||
|
||||
return new NotificationBuilder(new Notification(), $storageManager);
|
||||
return new FlasherBuilder(new Notification(), $storageManager);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user