Skip to content

Commit

Permalink
Enhancement: Assert that duration can be specified as order-by option…
Browse files Browse the repository at this point in the history
… via CLI
  • Loading branch information
localheinz committed May 5, 2019
1 parent 1f66fc1 commit 14daebe
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
@@ -0,0 +1,28 @@
<?php
/*
* 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.
*/
use PHPUnit\Framework\TestCase;

final class TestWithDifferentDurations extends TestCase
{
public function testOne(): void
{
$this->assertTrue(true);
}

public function testTwo(): void
{
$this->assertTrue(true);
}

public function testThree(): void
{
$this->assertTrue(true);
}
}
@@ -0,0 +1 @@
C:30:"PHPUnit\Runner\TestResultCache":199:{a:2:{s:7:"defects";a:0:{}s:5:"times";a:3:{s:35:"TestWithDifferentDurations::testOne";d:1.000;s:35:"TestWithDifferentDurations::testTwo";d:0.500;s:37:"TestWithDifferentDurations::testThree";d:1.500;}}}
34 changes: 34 additions & 0 deletions tests/end-to-end/execution-order/order-by-duration-via-cli.phpt
@@ -0,0 +1,34 @@
--TEST--
phpunit --order-by=duration ./tests/end-to-end/_files/execution-order/TestWithDifferentDurations.php
--FILE--
<?php

$tmpResultCache = tempnam(sys_get_temp_dir(), __FILE__);
file_put_contents($tmpResultCache, file_get_contents(__DIR__ . '/../_files/execution-order/TestWithDifferentDurations.phpunit.result.cache.txt'));

$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--debug';
$_SERVER['argv'][3] = '--order-by=duration';
$_SERVER['argv'][4] = '--cache-result';
$_SERVER['argv'][5] = '--cache-result-file=' . $tmpResultCache;
$_SERVER['argv'][6] = 'TestWithDifferentDurations';
$_SERVER['argv'][7] = __DIR__ . '/../_files/execution-order/TestWithDifferentDurations.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit\TextUI\Command::main();

unlink($tmpResultCache);
--EXPECTF--
PHPUnit %s by Sebastian Bergmann and contributors.

Test 'TestWithDifferentDurations::testTwo' started
Test 'TestWithDifferentDurations::testTwo' ended
Test 'TestWithDifferentDurations::testOne' started
Test 'TestWithDifferentDurations::testOne' ended
Test 'TestWithDifferentDurations::testThree' started
Test 'TestWithDifferentDurations::testThree' ended


Time: %s, Memory: %s

OK (3 tests, 3 assertions)

0 comments on commit 14daebe

Please sign in to comment.