-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathTest.php
More file actions
49 lines (38 loc) · 2.06 KB
/
Test.php
File metadata and controls
49 lines (38 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace Barryvdh\LaravelIdeHelper\Tests\Console\GeneratorCommand\GenerateIdeHelper;
use Barryvdh\LaravelIdeHelper\Console\GeneratorCommand;
use Barryvdh\LaravelIdeHelper\Tests\Console\GeneratorCommand\AbstractGeneratorCommand;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
class Test extends AbstractGeneratorCommand
{
public function testGenerator(): void
{
Arr::macro('arr_custom_macro', function () {
});
DB::macro('db_custom_macro', function () {
});
$this->app['config']->set('ide-helper.include_complete_stubs', [Arr::class]);
$this->app['config']->set('ide-helper.macro_default_return_types', [Arr::class => 'Custom_Fake_Class']);
$command = $this->app->make(GeneratorCommand::class);
$tester = $this->runCommand($command);
$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('A new helper file was written to _ide_helper.php', $tester->getDisplay());
$this->assertStringContainsString('public static function configure($basePath = null)', $this->mockFilesystemOutput);
$this->assertStringContainsString('* @return \Custom_Fake_Class', $this->mockFilesystemOutput);
$this->assertStringContainsString('public static function arr_custom_macro()', $this->mockFilesystemOutput);
$this->assertStringContainsString('public static function db_custom_macro()', $this->mockFilesystemOutput);
$this->assertStringContainsString('return \Illuminate\Support\Arr::add', $this->mockFilesystemOutput);
$this->assertStringNotContainsString('return \Illuminate\Support\Str::of', $this->mockFilesystemOutput);
}
public function testFilename(): void
{
$command = $this->app->make(GeneratorCommand::class);
$tester = $this->runCommand($command, [
'filename' => 'foo.php',
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertStringContainsString('A new helper file was written to foo.php', $tester->getDisplay());
}
}