File: InvalidConfigurationExceptionTest.php

package info (click to toggle)
php-league-config 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 508 kB
  • sloc: php: 482; ruby: 45; makefile: 18; javascript: 15; xml: 15
file content (42 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

declare(strict_types=1);

/*
 * This file is part of the league/config package.
 *
 * (c) Colin O'Dell <colinodell@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace League\Config\Tests\Exception;

use League\Config\Exception\InvalidConfigurationException;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class InvalidConfigurationExceptionTest extends TestCase
{
    /**
     * @param mixed $valueGiven
     */
    #[DataProvider('provideTestCases')]
    public function testForConfigOption(string $option, $valueGiven, ?string $description, string $expectedMessage): void
    {
        $ex = InvalidConfigurationException::forConfigOption($option, $valueGiven, $description);

        $this->assertSame($expectedMessage, $ex->getMessage());
    }

    /**
     * @return iterable<mixed>
     */
    public static function provideTestCases(): iterable
    {
        yield ['foo', 'bar', null, 'Invalid config option for "foo": bar'];
        yield ['foo', 'bar', 'Expected "foo"', 'Invalid config option for "foo": bar (Expected "foo")'];
        yield ['foo', new \DateTimeImmutable(), null, 'Invalid config option for "foo": DateTimeImmutable'];
    }
}