File: JobIdTest.php

package info (click to toggle)
php-pda-pheanstalk 8.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 836 kB
  • sloc: php: 4,713; xml: 19; makefile: 14
file content (58 lines) | stat: -rw-r--r-- 1,273 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

declare(strict_types=1);

namespace Pheanstalk\Tests\Unit\Values;

use InvalidArgumentException;
use Pheanstalk\Values\JobId;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

#[CoversClass(JobId::class)]
final class JobIdTest extends TestCase
{
    /**
     * @return list<array{0: string|int}>
     */
    public static function validSamples(): array
    {
        return [
            ['123'],
            [123],
        ];
    }

    /**
     * @return list<array{0: string|int}>
     */
    public static function invalidSamples(): array
    {
        return [
            ['ab'],
            ['123ab'],
            ['ab123'],
            [-15],

        ];
    }

    #[DataProvider('validSamples')]
    public function testConstructor(int|string $value): void
    {
        $jobId = new JobId($value);

        self::assertSame((string) $value, $jobId->getId());

        $nested = new JobId($jobId);
        self::assertSame($jobId->getId(), $nested->getId());
    }

    #[DataProvider('invalidSamples')]
    public function testConstructorException(int|string $value): void
    {
        $this->expectException(InvalidArgumentException::class);
        new JobId($value);
    }
}