mirror of
https://github.com/php-flasher/php-flasher.git
synced 2026-03-31 15:07:47 +01:00
Fix SweetAlertBuilder::question() bug and improve code quality
This commit is contained in:
@@ -194,4 +194,34 @@ final class FilterCriteriaTest extends TestCase
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame('test', $result[0]->getMessage());
|
||||
}
|
||||
|
||||
public function testApplyThrowsExceptionWhenCallbackReturnsNonArray(): void
|
||||
{
|
||||
$criteria = new FilterCriteria(fn ($e) => 'not an array');
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Filter callback must return an array, got "string".');
|
||||
|
||||
$criteria->apply([new Envelope(new Notification())]);
|
||||
}
|
||||
|
||||
public function testApplyThrowsExceptionWhenCallbackReturnsNull(): void
|
||||
{
|
||||
$criteria = new FilterCriteria(fn ($e) => null);
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Filter callback must return an array, got "null".');
|
||||
|
||||
$criteria->apply([new Envelope(new Notification())]);
|
||||
}
|
||||
|
||||
public function testApplyThrowsExceptionWhenCallbackReturnsObject(): void
|
||||
{
|
||||
$criteria = new FilterCriteria(fn ($e) => new \stdClass());
|
||||
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Filter callback must return an array, got "stdClass".');
|
||||
|
||||
$criteria->apply([new Envelope(new Notification())]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ final class SweetAlertBuilderTest extends TestCase
|
||||
$envelope = $this->sweetAlertBuilder->getEnvelope();
|
||||
$options = $envelope->getNotification()->getOptions();
|
||||
|
||||
$this->assertSame(['showCancelButton' => true, 'text' => 'Are you sure?'], $options);
|
||||
$this->assertSame(['showCancelButton' => true, 'text' => 'Are you sure?', 'option1' => 'value1'], $options);
|
||||
}
|
||||
|
||||
public function testTitle(): void
|
||||
|
||||
Reference in New Issue
Block a user