-
-
Notifications
You must be signed in to change notification settings - Fork 266
/
Copy pathPublishCommandTest.php
76 lines (66 loc) · 2.59 KB
/
PublishCommandTest.php
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
declare(strict_types = 1);
namespace Rebing\GraphQL\Tests\Unit\Console;
use Illuminate\Filesystem\Filesystem;
use Rebing\GraphQL\Console\PublishCommand;
use Rebing\GraphQL\Tests\TestCase;
class PublishCommandTest extends TestCase
{
public function testCommand(): void
{
$filesystemMock = $this
->getMockBuilder(Filesystem::class)
->onlyMethods([
'copy',
'isDirectory',
'makeDirectory',
])
->getMock();
$filesystemMock
->expects(self::exactly(2))
->method('copy')
->withConsecutive(
[
self::callback(function (string $from): bool {
$this->assertMatchesRegularExpression('|/config/config.php|', $from, '1st call to copy, $from');
return true;
}),
self::callback(function (string $to): bool {
$this->assertMatchesRegularExpression(
'|laravel[/\\\\]config/graphql.php|',
$to,
'1st call to copy, $to'
);
return true;
}),
],
[
self::callback(function (string $from): bool {
$this->assertMatchesRegularExpression(
'|/resources/views/graphiql.php|',
$from,
'2nd call to copy, $from'
);
return true;
}),
self::callback(function (string $to): bool {
$this->assertMatchesRegularExpression(
'|laravel[/\\\\]resources/views/vendor/graphql/graphiql.php|',
$to,
'2nd call to copy, $to'
);
return true;
}),
]
);
$this->instance(Filesystem::class, $filesystemMock);
$command = $this->app->make(PublishCommand::class);
$tester = $this->runCommand($command);
self::assertSame(0, $tester->getStatusCode());
self::assertMatchesRegularExpression('|Copied File.*[/\\\\]config[/\\\\]config.php.* To|', $tester->getDisplay());
self::assertMatchesRegularExpression(
'|Copied File.*[/\\\\]resources[/\\\\]views[/\\\\]graphiql.php.* To|',
$tester->getDisplay()
);
}
}