mirror of
https://github.com/ambieco/scribe.git
synced 2026-03-29 22:35:52 +08:00
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Knuckles\Scribe\Tests;
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
trait TestHelpers
|
|
{
|
|
/**
|
|
* @param string $command
|
|
* @param array $parameters
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function artisan($command, $parameters = [])
|
|
{
|
|
/** @var Kernel $kernel */
|
|
$kernel = $this->app[Kernel::class];
|
|
$kernel->call($command, $parameters);
|
|
|
|
return $kernel->output();
|
|
}
|
|
|
|
private function assertFilesHaveSameContent($pathToExpected, $pathToActual)
|
|
{
|
|
$actual = $this->getFileContents($pathToActual);
|
|
$expected = $this->getFileContents($pathToExpected);
|
|
$this->assertSame($expected, $actual);
|
|
}
|
|
|
|
/**
|
|
* Get the contents of a file in a cross-platform-compatible way.
|
|
*
|
|
* @param $path
|
|
*
|
|
* @return string
|
|
*/
|
|
private function getFileContents($path)
|
|
{
|
|
return str_replace("\r\n", "\n", file_get_contents($path));
|
|
}
|
|
|
|
/**
|
|
* Assert that a string contains another string, ignoring all whitespace.
|
|
*
|
|
* @param $needle
|
|
* @param $haystack
|
|
*/
|
|
private function assertContainsIgnoringWhitespace($needle, $haystack)
|
|
{
|
|
$haystack = preg_replace('/\s/', '', $haystack);
|
|
$needle = preg_replace('/\s/', '', $needle);
|
|
$this->assertStringContainsString($needle, $haystack);
|
|
}
|
|
}
|