TestHelpers.php 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Knuckles\Scribe\Tests;
  3. use Illuminate\Contracts\Console\Kernel;
  4. trait TestHelpers
  5. {
  6. /**
  7. * @param string $command
  8. * @param array $parameters
  9. *
  10. * @return mixed
  11. */
  12. public function artisan($command, $parameters = [])
  13. {
  14. /** @var Kernel $kernel */
  15. $kernel = $this->app[Kernel::class];
  16. $kernel->call($command, $parameters);
  17. return $kernel->output();
  18. }
  19. protected function generate(array $flags = []): mixed
  20. {
  21. return $this->artisan(
  22. 'scribe:generate', array_merge(['--no-upgrade-check' => true], $flags)
  23. );
  24. }
  25. protected function assertFileContainsString(string $filePath, string $string)
  26. {
  27. $this->assertFileExists($filePath);
  28. $fileContents = file_get_contents($filePath);
  29. $this->assertStringContainsString($string, $fileContents);
  30. }
  31. }