File: TestSuiteTest.php

package info (click to toggle)
phpunit 12.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 50,160 kB
  • sloc: php: 101,772; xml: 2,084; makefile: 124; sh: 99
file content (86 lines) | stat: -rw-r--r-- 3,168 bytes parent folder | download | duplicates (2)
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php declare(strict_types=1);
/*
 * This file is part of PHPUnit.
 *
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
namespace PHPUnit\Event\TestSuite;

use PHPUnit\Event\Code\TestCollection;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\CoversClassesThatExtendClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\TestCase;

#[CoversClass(TestSuite::class)]
#[CoversClassesThatExtendClass(TestSuite::class)]
#[Small]
final class TestSuiteTest extends TestCase
{
    public function testCanBeTestSuiteForTestClass(): void
    {
        $className = 'ExampleTest';
        $size      = 0;
        $tests     = TestCollection::fromArray([]);
        $file      = 'ExampleTest.php';
        $line      = 1;

        $testSuite = new TestSuiteForTestClass($className, $size, $tests, $file, $line);

        $this->assertTrue($testSuite->isForTestClass());
        $this->assertFalse($testSuite->isForTestMethodWithDataProvider());
        $this->assertFalse($testSuite->isWithName());

        $this->assertSame($className, $testSuite->className());
        $this->assertSame($className, $testSuite->name());
        $this->assertSame($size, $testSuite->count());
        $this->assertSame($tests, $testSuite->tests());
        $this->assertSame($file, $testSuite->file());
        $this->assertSame($line, $testSuite->line());
    }

    public function testCanBeTestSuiteForTestMethodWithDataProvider(): void
    {
        $name       = 'ExampleTest::testOne';
        $className  = 'ExampleTest';
        $methodName = 'testOne';
        $size       = 0;
        $tests      = TestCollection::fromArray([]);
        $file       = 'ExampleTest.php';
        $line       = 1;

        $testSuite = new TestSuiteForTestMethodWithDataProvider($name, $size, $tests, $className, $methodName, $file, $line);

        $this->assertFalse($testSuite->isForTestClass());
        $this->assertTrue($testSuite->isForTestMethodWithDataProvider());
        $this->assertFalse($testSuite->isWithName());

        $this->assertSame($name, $testSuite->name());
        $this->assertSame($className, $testSuite->className());
        $this->assertSame($methodName, $testSuite->methodName());
        $this->assertSame($size, $testSuite->count());
        $this->assertSame($tests, $testSuite->tests());
        $this->assertSame($file, $testSuite->file());
        $this->assertSame($line, $testSuite->line());
    }

    public function testCanBeTestSuiteWithName(): void
    {
        $name  = 'the-name';
        $size  = 0;
        $tests = TestCollection::fromArray([]);

        $testSuite = new TestSuiteWithName($name, $size, $tests);

        $this->assertFalse($testSuite->isForTestClass());
        $this->assertFalse($testSuite->isForTestMethodWithDataProvider());
        $this->assertTrue($testSuite->isWithName());

        $this->assertSame($name, $testSuite->name());
        $this->assertSame($size, $testSuite->count());
        $this->assertSame($tests, $testSuite->tests());
    }
}