1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Integration; |
4
|
|
|
|
5
|
|
|
use Tests\TestCase; |
6
|
|
|
use Tests\FakeExtraCommand; |
7
|
|
|
use Tests\FakeDefaultCommand; |
8
|
|
|
use Illuminate\Container\Container; |
9
|
|
|
use Illuminate\Contracts\Config\Repository; |
10
|
|
|
use LaravelZero\Framework\Contracts\Application as ApplicationContract; |
11
|
|
|
|
12
|
|
|
class ApplicationTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
/** @test */ |
15
|
|
|
public function it_binds_core_alias(): void |
16
|
|
|
{ |
17
|
|
|
$container = ($application = $this->createApplication()) |
18
|
|
|
->getContainer(); |
19
|
|
|
|
20
|
|
|
$this->assertTrue(Container::getInstance() === $container); |
21
|
|
|
$this->assertTrue($container->make('app') === $container); |
22
|
|
|
$this->assertTrue($container->make(Container::class) === $container); |
23
|
|
|
$this->assertTrue($container->make(ApplicationContract::class) === $application); |
24
|
|
|
$this->assertInstanceOf(Repository::class, $container->make('config')); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
/** @test */ |
28
|
|
|
public function it_configures_using_configuration() |
29
|
|
|
{ |
30
|
|
|
// @todo Test production config. |
31
|
|
|
$app = $this->createApplication(); |
32
|
|
|
|
33
|
|
|
$this->assertTrue($app->getName() === 'Test name'); |
34
|
|
|
$this->assertTrue($app->getVersion() === 'Test version'); |
35
|
|
|
|
36
|
|
|
$commands = [ |
37
|
|
|
FakeDefaultCommand::class, |
38
|
|
|
FakeExtraCommand::class, |
39
|
|
|
]; |
40
|
|
|
|
41
|
|
|
$appCommands = collect($app->all()) |
42
|
|
|
->map( |
43
|
|
|
function ($command) { |
44
|
|
|
return get_class($command); |
45
|
|
|
} |
46
|
|
|
) |
47
|
|
|
->toArray(); |
48
|
|
|
|
49
|
|
|
foreach ($commands as $command) { |
50
|
|
|
$this->assertTrue(in_array($command, $appCommands)); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** @test */ |
55
|
|
|
public function it_register_service_providers() |
56
|
|
|
{ |
57
|
|
|
$app = $this->createApplication(); |
58
|
|
|
|
59
|
|
|
$this->assertTrue( |
60
|
|
|
$app->getContainer() |
61
|
|
|
->make('foo') === 'bar' |
62
|
|
|
); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|