12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?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);
- }
- }
|