Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jan 13, 2025
1 parent e42dd58 commit 3b620e5
Show file tree
Hide file tree
Showing 13 changed files with 158 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../phpunit.xsd"
bootstrap="src/Foo.php">
bootstrap="src/autoload.php">
<testsuites>
<testsuite name="default">
<directory>tests</directory>
Expand Down
12 changes: 12 additions & 0 deletions tests/end-to-end/_files/attribute-based-filtering/src/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require __DIR__ . '/f.php';

require __DIR__ . '/Foo.php';
15 changes: 15 additions & 0 deletions tests/end-to-end/_files/attribute-based-filtering/src/f.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\AttributeBasedFiltering;

function f(): bool
{
return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use PHPUnit\Framework\TestCase;

#[CoversClass(Foo::class)]
final class CoversTest extends TestCase
final class CoversClassTest extends TestCase
{
public function testOne(): void
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\AttributeBasedFiltering;

use PHPUnit\Framework\Attributes\CoversFunction;
use PHPUnit\Framework\TestCase;

#[CoversFunction('PHPUnit\TestFixture\AttributeBasedFiltering\f')]
final class CoversFunctionTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php declare(strict_types=1);
/*
* This file is part of PHPUnit.
*
* (c) Sebastian Bergmann <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PHPUnit\TestFixture\AttributeBasedFiltering;

use PHPUnit\Framework\Attributes\UsesFunction;
use PHPUnit\Framework\TestCase;

#[UsesFunction('PHPUnit\TestFixture\AttributeBasedFiltering\f')]
final class UsesFunctionTest extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ PHPUnit Started (PHPUnit %s using %s)
Test Runner Triggered Warning (Using comma-separated values with --covers is deprecated and will no longer work in PHPUnit 12. You can use --covers multiple times instead.)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (3 tests)
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Test Runner Execution Started (1 test)
Test Suite Started (CLI Arguments, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest, 1 test)
Test Suite Finished (CLI Arguments, 1 test)
Test Runner Execution Finished
Test Runner Finished
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ require_once __DIR__ . '/../../../bootstrap.php';
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (3 tests)
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Test Runner Execution Started (1 test)
Test Suite Started (CLI Arguments, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversTest, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversClassTest, 1 test)
Test Suite Finished (CLI Arguments, 1 test)
Test Runner Execution Finished
Test Runner Finished
Expand Down
34 changes: 34 additions & 0 deletions tests/end-to-end/cli/group/covers-function.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
phpunit --covers PHPUnit\TestFixture\AttributeBasedFiltering\f
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--debug';
$_SERVER['argv'][] = '--covers';
$_SERVER['argv'][] = 'PHPUnit\TestFixture\AttributeBasedFiltering\f';
$_SERVER['argv'][] = __DIR__ . '/../../_files/attribute-based-filtering';

require_once __DIR__ . '/../../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Test Runner Execution Started (1 test)
Test Suite Started (CLI Arguments, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\CoversFunctionTest, 1 test)
Test Suite Finished (CLI Arguments, 1 test)
Test Runner Execution Finished
Test Runner Finished
PHPUnit Finished (Shell Exit Code: 0)
2 changes: 1 addition & 1 deletion tests/end-to-end/cli/group/requires-php-extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require_once __DIR__ . '/../../../bootstrap.php';
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (3 tests)
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PHPUnit Started (PHPUnit %s using %s)
Test Runner Triggered Warning (Using comma-separated values with --uses is deprecated and will no longer work in PHPUnit 12. You can use --uses multiple times instead.)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (3 tests)
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require_once __DIR__ . '/../../../bootstrap.php';
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (3 tests)
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Expand Down
34 changes: 34 additions & 0 deletions tests/end-to-end/cli/group/uses-function.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
phpunit --covers PHPUnit\TestFixture\AttributeBasedFiltering\f
--FILE--
<?php declare(strict_types=1);
$_SERVER['argv'][] = '--do-not-cache-result';
$_SERVER['argv'][] = '--no-configuration';
$_SERVER['argv'][] = '--debug';
$_SERVER['argv'][] = '--uses';
$_SERVER['argv'][] = 'PHPUnit\TestFixture\AttributeBasedFiltering\f';
$_SERVER['argv'][] = __DIR__ . '/../../_files/attribute-based-filtering';

require_once __DIR__ . '/../../../bootstrap.php';

(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
--EXPECTF--
PHPUnit Started (PHPUnit %s using %s)
Test Runner Configured
Event Facade Sealed
Test Suite Loaded (5 tests)
Test Runner Started
Test Suite Sorted
Test Suite Filtered (1 test)
Test Runner Execution Started (1 test)
Test Suite Started (CLI Arguments, 1 test)
Test Suite Started (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest, 1 test)
Test Preparation Started (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest::testOne)
Test Prepared (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest::testOne)
Test Passed (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest::testOne)
Test Finished (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest::testOne)
Test Suite Finished (PHPUnit\TestFixture\AttributeBasedFiltering\UsesFunctionTest, 1 test)
Test Suite Finished (CLI Arguments, 1 test)
Test Runner Execution Finished
Test Runner Finished
PHPUnit Finished (Shell Exit Code: 0)

0 comments on commit 3b620e5

Please sign in to comment.