Skip to content

Commit 0d755a6

Browse files
committed
Add tests for configuration
1 parent a9e61d3 commit 0d755a6

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/Objects/ConfigurationTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace BlameButton\LaravelDockerBuilder\Tests\Objects;
4+
5+
use BlameButton\LaravelDockerBuilder\Objects\Configuration;
6+
use BlameButton\LaravelDockerBuilder\Tests\TestCase;
7+
8+
/**
9+
* @uses \BlameButton\LaravelDockerBuilder\DockerServiceProvider
10+
*
11+
* @covers \BlameButton\LaravelDockerBuilder\Objects\Configuration
12+
*/
13+
class ConfigurationTest extends TestCase
14+
{
15+
public function provideCommandOptions(): array
16+
{
17+
return [
18+
[
19+
'php artisan docker:generate -n -p 8.2 -e bcmath,pdo_mysql -o -m npm -b vite',
20+
new Configuration('8.2', ['bcmath', 'pdo_mysql'], true, 'npm', 'vite')
21+
],
22+
[
23+
'php artisan docker:generate -n -p 8.1 -e bcmath,pdo_pgsql,redis -o -m yarn -b vite',
24+
new Configuration('8.1', ['bcmath', 'pdo_pgsql', 'redis'], true, 'yarn', 'vite')
25+
],
26+
[
27+
'php artisan docker:generate -n -p 8.0 -e bcmath,pdo_pgsql,apcu -m yarn -b mix',
28+
new Configuration('8.0', ['bcmath', 'pdo_pgsql', 'apcu'], false, 'yarn', 'mix')
29+
],
30+
];
31+
}
32+
33+
public function testItConstructs(): void
34+
{
35+
$config = new Configuration('8.2', ['bcmath'], true, 'npm', 'vite');
36+
37+
self::assertEquals('8.2', $config->getPhpVersion());
38+
self::assertEquals(['bcmath'], $config->getPhpExtensions());
39+
self::assertEquals(true, $config->isArtisanOptimize());
40+
self::assertEquals('npm', $config->getNodePackageManager());
41+
self::assertEquals('vite', $config->getNodeBuildTool());
42+
}
43+
44+
/** @dataProvider provideCommandOptions */
45+
public function testItGeneratesCorrectCommand(string $expected, Configuration $config): void
46+
{
47+
$output = $config->getCommand();
48+
49+
self::assertEquals($expected, implode(' ', $output));
50+
}
51+
}

0 commit comments

Comments
 (0)