|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace EcodevTests\Felix\Log\Filter; |
|
6
|
|
|
|
|
7
|
|
|
use Ecodev\Felix\Api\ExceptionWithoutMailLogging; |
|
8
|
|
|
use Ecodev\Felix\Log\Filter\NoMail; |
|
9
|
|
|
use Exception; |
|
10
|
|
|
use GraphQL\Error\Error; |
|
11
|
|
|
use PHPUnit\Framework\TestCase; |
|
12
|
|
|
|
|
13
|
|
|
class NoMailTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* @dataProvider providerFilter |
|
17
|
|
|
*/ |
|
18
|
|
|
public function testFilter(array $event, bool $expected): void |
|
19
|
|
|
{ |
|
20
|
|
|
$filter = new NoMail(); |
|
21
|
|
|
$actual = $filter->filter($event); |
|
22
|
|
|
self::assertSame($expected, $actual); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function providerFilter(): array |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
|
|
[[], true], |
|
29
|
|
|
[['extra' => []], true], |
|
30
|
|
|
[['extra' => ['exception' => null]], true], |
|
31
|
|
|
[['extra' => ['exception' => []]], true], |
|
32
|
|
|
[['extra' => ['exception' => new Exception()]], true], |
|
33
|
|
|
[['extra' => ['exception' => new Exception('', 0, new Exception())]], true], |
|
34
|
|
|
[['extra' => ['exception' => new Exception('', 0, new ExceptionWithoutMailLogging())]], true], |
|
35
|
|
|
[['extra' => ['exception' => new ExceptionWithoutMailLogging()]], false], |
|
36
|
|
|
[['extra' => ['exception' => new Error()]], true], |
|
37
|
|
|
[['extra' => ['exception' => new Error('', null, null, [], null, new Exception())]], true], |
|
38
|
|
|
[['extra' => ['exception' => new Error('', null, null, [], null, new ExceptionWithoutMailLogging())]], false], |
|
39
|
|
|
]; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|