Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[11.x] Test Improvements
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Sep 1, 2025
commit 4a7b6f4115fb978f8f947be0591b1762d52a1759
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"league/flysystem-read-only": "^3.25.1",
"league/flysystem-sftp-v3": "^3.25.1",
"mockery/mockery": "^1.6.10",
"orchestra/testbench-core": "^9.16.0",
"orchestra/testbench-core": "^9.16.1",
"pda/pheanstalk": "^5.0.6",
"php-http/discovery": "^1.15",
"phpstan/phpstan": "^2.0",
Expand Down
22 changes: 22 additions & 0 deletions src/Illuminate/Testing/PendingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;

class PendingCommand
Expand Down Expand Up @@ -359,6 +360,27 @@ public function run()
return $exitCode;
}

/**
* Debug the command.
*
* @return never
*/
public function dd()
{
$consoleOutput = new OutputStyle(new ArrayInput($this->parameters), new ConsoleOutput());
$exitCode = $this->app->make(Kernel::class)->call($this->command, $this->parameters, $consoleOutput);

$streamOutput = $consoleOutput->getOutput()->getStream();
$output = stream_get_contents($streamOutput);

fclose($streamOutput);

dd([
'exitCode' => $exitCode,
'output' => $output,
]);
}

/**
* Determine if expected questions / choices / outputs are fulfilled.
*
Expand Down
4 changes: 3 additions & 1 deletion tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use PHPUnit\Framework\TestCase;
use SplFileInfo;

use function Orchestra\Testbench\terminate;

class FilesystemTest extends TestCase
{
private static $tempDir;
Expand Down Expand Up @@ -547,7 +549,7 @@ public function testSharedGet()
$files->put(self::$tempDir.'/file.txt', $content, true);
$read = $files->get(self::$tempDir.'/file.txt', true);

exit(strlen($read) === strlen($content) ? 1 : 0);
terminate($this, strlen($read) === strlen($content) ? 1 : 0);
}
}

Expand Down
16 changes: 5 additions & 11 deletions tests/Testing/Console/RouteListCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Illuminate\Foundation\Testing\Concerns\InteractsWithDeprecationHandling;
use Illuminate\Http\RedirectResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Facade;
use Orchestra\Testbench\TestCase;

class RouteListCommandTest extends TestCase
Expand Down Expand Up @@ -123,6 +122,10 @@ public function testRouteCanBeFilteredByAction()
{
$this->withoutDeprecationHandling();

RouteListCommand::resolveTerminalWidthUsing(function () {
return 82;
});

$this->router->get('/', function () {
//
});
Expand All @@ -135,7 +138,7 @@ public function testRouteCanBeFilteredByAction()
' GET|HEAD foo/{user} Illuminate\Tests\Testing\Console\FooController@show'
)->expectsOutput('')
->expectsOutput(
' Showing [1] routes'
' Showing [1] routes'
)
->expectsOutput('');
}
Expand All @@ -156,15 +159,6 @@ public function testDisplayRoutesExceptVendor()
->expectsOutput(' Showing [3] routes')
->expectsOutput('');
}

protected function tearDown(): void
{
parent::tearDown();

Facade::setFacadeApplication(null);

RouteListCommand::resolveTerminalWidthUsing(null);
}
}

class FooController extends Controller
Expand Down