Skip to content

Commit 9269877

Browse files
authored
Merge pull request #8 from previousnext/add-real-tests
Add real tests
2 parents 2095e60 + bb88dee commit 9269877

File tree

4 files changed

+89
-3
lines changed

4 files changed

+89
-3
lines changed

tests/Unit/FinderTest.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use Symfony\Component\Console\Tester\CommandTester;
88

99
/**
10-
* A stub test.
10+
* A test of the command functionality
1111
*/
1212
class FinderTest extends TestCase {
1313

@@ -16,8 +16,18 @@ class FinderTest extends TestCase {
1616
*/
1717
public function testDiscovery() {
1818
$command = new CommandTester(new FinderCommand());
19-
$command->execute([]);
20-
$this->assertNotNull($command->getDisplay());
19+
$command->execute([
20+
'--config-file' => dirname(__DIR__) . '/fixtures/phpunit.xml'
21+
]);
22+
$output = $command->getDisplay();
23+
$this->assertNotNull($output);
24+
if (method_exists($this, 'assertStringContainsString')) {
25+
$this->assertStringContainsString('TestUnitTest.php', $output);
26+
$this->assertStringContainsString('TestFunctionalTest.php', $output);
27+
return;
28+
}
29+
$this->assertContains('TestUnitTest.php', $output);
30+
$this->assertContains('TestFunctionalTest.php', $output);
2131
}
2232

2333
}

tests/fixtures/phpunit.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
4+
<!-- PHPUnit expects functional tests to be run with either a privileged user
5+
or your current system user. See core/tests/README.md and
6+
https://www.drupal.org/node/2116263 for details.
7+
-->
8+
<phpunit bootstrap="tests/bootstrap.php" colors="true"
9+
beStrictAboutTestsThatDoNotTestAnything="true"
10+
beStrictAboutOutputDuringTests="true"
11+
beStrictAboutChangesToGlobalState="true">
12+
<php>
13+
<!-- Set error reporting to E_ALL. -->
14+
<ini name="error_reporting" value="32767"/>
15+
<!-- Do not limit the amount of memory tests take to run. -->
16+
<ini name="memory_limit" value="-1"/>
17+
<const name="BOOTSTRAP_IS_PHPUNIT" value="true"/>
18+
</php>
19+
<testsuites>
20+
<testsuite name="unit">
21+
<directory>./tests/Unit</directory>
22+
</testsuite>
23+
<testsuite name="functional">
24+
<directory>./tests/Functional</directory>
25+
</testsuite>
26+
</testsuites>
27+
<!-- Filter for coverage reports. -->
28+
<filter>
29+
<whitelist>
30+
<directory>./src</directory>
31+
<!-- By definition test classes have no tests. -->
32+
<exclude>
33+
<directory suffix="Test.php">./</directory>
34+
<directory suffix="TestBase.php">./</directory>
35+
</exclude>
36+
</whitelist>
37+
</filter>
38+
</phpunit>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace PhpUnitFinder\Tests\fixtures\tests\Functional;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
/**
8+
* Defines a test class.
9+
*/
10+
class TestFunctionalTest extends TestCase {
11+
12+
/**
13+
* Tests something.
14+
*/
15+
public function testSomething() {
16+
$this->addToAssertionCount(1);
17+
}
18+
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace PhpUnitFinder\Tests\fixtures\tests\Unit;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
/**
8+
* Defines a test class.
9+
*/
10+
class TestUnitTest extends TestCase {
11+
12+
/**
13+
* Tests something.
14+
*/
15+
public function testSomething() {
16+
$this->addToAssertionCount(1);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)