Skip to content

Commit c34d04a

Browse files
Add tests
1 parent 10d4155 commit c34d04a

7 files changed

Lines changed: 161 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\TeamCity;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class FailingSetUpBeforeClassTest extends TestCase
15+
{
16+
public static function setUpBeforeClass(): void
17+
{
18+
self::assertTrue(false);
19+
}
20+
21+
public function testOne(): void
22+
{
23+
$this->assertTrue(true);
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\TeamCity;
11+
12+
use PHPUnit\Framework\TestCase;
13+
14+
final class FailingSetUpTest extends TestCase
15+
{
16+
protected function setUp(): void
17+
{
18+
$this->assertTrue(false);
19+
}
20+
21+
public function testOne(): void
22+
{
23+
$this->assertTrue(true);
24+
}
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of PHPUnit.
4+
*
5+
* (c) Sebastian Bergmann <sebastian@phpunit.de>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace PHPUnit\TestFixture\TeamCity;
11+
12+
use PHPUnit\Framework\Attributes\Depends;
13+
use PHPUnit\Framework\TestCase;
14+
15+
final class InvalidDependencyTest extends TestCase
16+
{
17+
#[Depends('doesNotExist')]
18+
public function testOne(): void
19+
{
20+
$this->assertTrue(true);
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
TeamCity: tests skipped/errored due to unmet/invalid dependencies
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--display-skipped';
6+
$_SERVER['argv'][] = '--do-not-cache-result';
7+
$_SERVER['argv'][] = '--no-configuration';
8+
$_SERVER['argv'][] = '--no-output';
9+
$_SERVER['argv'][] = '--log-teamcity';
10+
$_SERVER['argv'][] = 'php://stdout';
11+
$_SERVER['argv'][] = __DIR__ . '/../../../_files/dependencies/DependencyFailureTest.php';
12+
13+
require_once __DIR__ . '/../../../bootstrap.php';
14+
15+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
16+
--EXPECTF--
17+
##teamcity[testCount count='6' flowId='%d']
18+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\DependencyFailureTest' locationHint='php_qn://%sDependencyFailureTest.php::\PHPUnit\TestFixture\DependencyFailureTest' flowId='%d']
19+
##teamcity[testStarted name='testOne' locationHint='php_qn://%sDependencyFailureTest.php::\PHPUnit\TestFixture\DependencyFailureTest::testOne' flowId='%d']
20+
##teamcity[testFailed name='testOne' message='Failed asserting that false is true.' details='%s|n' duration='%d' flowId='%d']
21+
##teamcity[testFinished name='testOne' duration='%d' flowId='%d']
22+
##teamcity[testIgnored name='testTwo' message='This test depends on "PHPUnit\TestFixture\DependencyFailureTest::testOne" to pass' duration='%d' flowId='%d']
23+
##teamcity[testIgnored name='testThree' message='This test depends on "PHPUnit\TestFixture\DependencyFailureTest::testTwo" to pass' duration='%d' flowId='%d']
24+
##teamcity[testIgnored name='testFour' message='This test depends on "PHPUnit\TestFixture\DependencyFailureTest::testOne" to pass' duration='%d' flowId='%d']
25+
##teamcity[testFailed name='testHandlesDependencyOnTestMethodThatDoesNotExist' message='This test depends on "PHPUnit\TestFixture\DependencyFailureTest::doesNotExist" which does not exist' details='' duration='%d' flowId='%d']
26+
##teamcity[testFailed name='testHandlesDependencyOnTestMethodWithEmptyName' message='This test depends on "" which does not exist' details='' duration='%d' flowId='%d']
27+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\DependencyFailureTest' flowId='%d']
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
TeamCity: assertion failure in setUpBeforeClass() emits beforeFirstTestMethodFailed
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--no-output';
8+
$_SERVER['argv'][] = '--log-teamcity';
9+
$_SERVER['argv'][] = 'php://stdout';
10+
$_SERVER['argv'][] = __DIR__ . '/../_files/teamcity-failure-in-set-up-before-class/FailingSetUpBeforeClassTest.php';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
##teamcity[testCount count='1' flowId='%d']
17+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' locationHint='php_qn://%sFailingSetUpBeforeClassTest.php::\PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' flowId='%d']
18+
##teamcity[testStarted name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' flowId='%d']
19+
##teamcity[testFailed name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' message='Failed asserting that false is true.' details='%s|n' duration='%d' flowId='%d']
20+
##teamcity[testFinished name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' duration='%d' flowId='%d']
21+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' flowId='%d']
22+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\TeamCity\FailingSetUpBeforeClassTest' flowId='%d']
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
TeamCity: assertion failure in setUp() emits testPreparationFailed
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--no-output';
8+
$_SERVER['argv'][] = '--log-teamcity';
9+
$_SERVER['argv'][] = 'php://stdout';
10+
$_SERVER['argv'][] = __DIR__ . '/../_files/teamcity-failure-in-setup/FailingSetUpTest.php';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
##teamcity[testCount count='1' flowId='%d']
17+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\TeamCity\FailingSetUpTest' locationHint='php_qn://%sFailingSetUpTest.php::\PHPUnit\TestFixture\TeamCity\FailingSetUpTest' flowId='%d']
18+
##teamcity[testStarted name='testOne' locationHint='php_qn://%sFailingSetUpTest.php::\PHPUnit\TestFixture\TeamCity\FailingSetUpTest::testOne' flowId='%d']
19+
##teamcity[testFailed name='testOne' message='Failed asserting that false is true.' details='%sFailingSetUpTest.php:%d|n' duration='%d' flowId='%d']
20+
##teamcity[testFinished name='testOne' duration='%d' flowId='%d']
21+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\TeamCity\FailingSetUpTest' flowId='%d']
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
TeamCity: invalid dependency emits testErrored without prior testStarted
3+
--FILE--
4+
<?php declare(strict_types=1);
5+
$_SERVER['argv'][] = '--do-not-cache-result';
6+
$_SERVER['argv'][] = '--no-configuration';
7+
$_SERVER['argv'][] = '--no-output';
8+
$_SERVER['argv'][] = '--log-teamcity';
9+
$_SERVER['argv'][] = 'php://stdout';
10+
$_SERVER['argv'][] = __DIR__ . '/../_files/teamcity-invalid-dependency/InvalidDependencyTest.php';
11+
12+
require_once __DIR__ . '/../../../bootstrap.php';
13+
14+
(new PHPUnit\TextUI\Application)->run($_SERVER['argv']);
15+
--EXPECTF--
16+
##teamcity[testCount count='1' flowId='%d']
17+
##teamcity[testSuiteStarted name='PHPUnit\TestFixture\TeamCity\InvalidDependencyTest' locationHint='php_qn://%sInvalidDependencyTest.php::\PHPUnit\TestFixture\TeamCity\InvalidDependencyTest' flowId='%d']
18+
##teamcity[testFailed name='testOne' message='This test depends on "PHPUnit\TestFixture\TeamCity\InvalidDependencyTest::doesNotExist" which does not exist' details='' duration='%d' flowId='%d']
19+
##teamcity[testSuiteFinished name='PHPUnit\TestFixture\TeamCity\InvalidDependencyTest' flowId='%d']

0 commit comments

Comments
 (0)