Skip to content

Commit

Permalink
Fix #3502 missing numeric @group and @ticket annotations
Browse files Browse the repository at this point in the history
Force $group to string once before doing a faster typed array search.
  • Loading branch information
epdenouden authored and sebastianbergmann committed Feb 3, 2019
1 parent 2cb7597 commit cd71bbe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Runner/Filter/GroupFilterIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(RecursiveIterator $iterator, array $groups, TestSuit
parent::__construct($iterator);

foreach ($suite->getGroupDetails() as $group => $tests) {
if (\in_array($group, $groups, true)) {
if (\in_array((string) $group, $groups, true)) {
$testHashes = \array_map(
'spl_object_hash',
$tests
Expand Down
38 changes: 38 additions & 0 deletions tests/_files/NumericGroupAnnotationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
/*
* 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.
*/
class NumericGroupAnnotationTest extends \PHPUnit\Framework\TestCase
{
/**
* @testdox Empty test for @ticket numeric annotation values
* @ticket 3502
*
* @see https://github.com/sebastianbergmann/phpunit/issues/3502
*/
public function testTicketAnnotationSupportsNumericValue(): void
{
$this->assertTrue(true);
}

/**
* @testdox Empty test for @group numeric annotation values
* @group 3502
*
* @see https://github.com/sebastianbergmann/phpunit/issues/3502
*/
public function testGroupAnnotationSupportsNumericValue(): void
{
$this->assertTrue(true);
}

public function testDummyTestThatShouldNotRun(): void
{
$this->doesNotPerformAssertions();
}
}
15 changes: 9 additions & 6 deletions tests/end-to-end/group.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ phpunit --group balanceIsInitiallyZero BankAccountTest ../../_files/BankAccountT
--FILE--
<?php
$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--group';
$_SERVER['argv'][3] = 'balanceIsInitiallyZero';
$_SERVER['argv'][4] = 'BankAccountTest';
$_SERVER['argv'][5] = __DIR__ . '/../_files/BankAccountTest.php';
$_SERVER['argv'][2] = '--testdox';
$_SERVER['argv'][3] = '--group';
$_SERVER['argv'][4] = '3502';
$_SERVER['argv'][5] = 'NumericGroupAnnotationTest';
$_SERVER['argv'][6] = __DIR__ . '/../_files/NumericGroupAnnotationTest.php';

require __DIR__ . '/../bootstrap.php';
PHPUnit\TextUI\Command::main();
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

. 1 / 1 (100%)
NumericGroupAnnotation
Empty test for @ticket numeric annotation values
Empty test for @group numeric annotation values

Time: %s, Memory: %s

OK (1 test, 1 assertion)
OK (2 tests, 2 assertions)

0 comments on commit cd71bbe

Please sign in to comment.