@@ -41,14 +41,15 @@ protected function setUp(): void
4141 public function testCreateDockerfile (): void
4242 {
4343 $ this ->setupActiveTeam ();
44- $ this ->setupValidProject ();
44+ $ this ->setupValidProject (1 , ' project ' , [ ' production ' => [ ' architecture ' => ' x86_64 ' , ' php ' => ' 8.3 ' ]] );
4545
4646 $ this ->bootApplication ([new CreateDockerfileCommand ($ this ->apiClient , $ this ->createExecutionContextFactory (), $ this ->dockerfile )]);
4747
4848 $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , [], ['no ' ]); // no configure project
4949
50- $ this ->assertStringContainsString ('Dockerfile created ' , $ tester ->getDisplay ());
50+ $ this ->assertStringContainsString ('Created Dockerfile for PHP 8.2 and arm64 architecture ' , $ tester ->getDisplay ());
5151 $ this ->assertFileExists ($ this ->tempDir .'/Dockerfile ' );
52+ $ this ->assertStringContainsString ('FROM --platform=linux/arm64 ymirapp/arm-php-runtime:php-74 ' , (string ) file_get_contents ($ this ->tempDir .'/Dockerfile ' ));
5253 }
5354
5455 public function testCreateDockerfileAndConfigureProjectWithOption (): void
@@ -60,7 +61,7 @@ public function testCreateDockerfileAndConfigureProjectWithOption(): void
6061
6162 $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , ['--configure-project ' => true ], []);
6263
63- $ this ->assertStringContainsString ('Dockerfile created ' , $ tester ->getDisplay ());
64+ $ this ->assertStringContainsString ('Created Dockerfile for PHP 8.2 and arm64 architecture ' , $ tester ->getDisplay ());
6465 $ this ->assertFileExists ($ this ->tempDir .'/Dockerfile ' );
6566
6667 $ config = $ this ->projectConfiguration ->getEnvironmentConfiguration ('staging ' );
@@ -70,7 +71,7 @@ public function testCreateDockerfileAndConfigureProjectWithOption(): void
7071 public function testCreateDockerfileForEnvironment (): void
7172 {
7273 $ this ->setupActiveTeam ();
73- $ project = $ this ->setupValidProject (1 , 'project ' , ['staging ' => []]);
74+ $ project = $ this ->setupValidProject (1 , 'project ' , ['staging ' => [' architecture ' => ' x86_64 ' , ' php ' => ' 8.1 ' ]]);
7475 $ environment = EnvironmentFactory::create (['name ' => 'staging ' , 'project ' => $ project ]);
7576
7677 $ this ->apiClient ->shouldReceive ('getEnvironments ' )->with ($ project )->andReturn (new ResourceCollection ([$ environment ]));
@@ -81,8 +82,37 @@ public function testCreateDockerfileForEnvironment(): void
8182
8283 $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , ['environment ' => 'staging ' ], ['no ' ]); // no configure project
8384
84- $ this ->assertStringContainsString ('Dockerfile created for "staging" environment ' , $ tester ->getDisplay ());
85+ $ this ->assertStringContainsString ('Created staging. Dockerfile for PHP 8.1 and x86_64 architecture ' , $ tester ->getDisplay ());
8586 $ this ->assertFileExists ($ this ->tempDir .'/staging.Dockerfile ' );
87+ $ this ->assertStringContainsString ('FROM --platform=linux/amd64 ymirapp/php-runtime:php-81 ' , (string ) file_get_contents ($ this ->tempDir .'/staging.Dockerfile ' ));
88+ }
89+
90+ public function testCreateDockerfileWithArchitectureOption (): void
91+ {
92+ $ this ->setupActiveTeam ();
93+ $ this ->setupValidProject ();
94+
95+ $ this ->bootApplication ([new CreateDockerfileCommand ($ this ->apiClient , $ this ->createExecutionContextFactory (), $ this ->dockerfile )]);
96+
97+ $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , ['--architecture ' => 'x86_64 ' ], ['no ' ]);
98+
99+ $ this ->assertStringContainsString ('Created Dockerfile for PHP 8.2 and x86_64 architecture ' , $ tester ->getDisplay ());
100+ $ this ->assertFileExists ($ this ->tempDir .'/Dockerfile ' );
101+ $ this ->assertStringContainsString ('FROM --platform=linux/amd64 ymirapp/php-runtime:php-74 ' , (string ) file_get_contents ($ this ->tempDir .'/Dockerfile ' ));
102+ }
103+
104+ public function testCreateDockerfileWithPhpOption (): void
105+ {
106+ $ this ->setupActiveTeam ();
107+ $ this ->setupValidProject ();
108+
109+ $ this ->bootApplication ([new CreateDockerfileCommand ($ this ->apiClient , $ this ->createExecutionContextFactory (), $ this ->dockerfile )]);
110+
111+ $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , ['--php ' => '8.3 ' ], ['no ' ]);
112+
113+ $ this ->assertStringContainsString ('Created Dockerfile for PHP 8.3 and arm64 architecture ' , $ tester ->getDisplay ());
114+ $ this ->assertFileExists ($ this ->tempDir .'/Dockerfile ' );
115+ $ this ->assertStringContainsString ('FROM --platform=linux/arm64 ymirapp/arm-php-runtime:php-83 ' , (string ) file_get_contents ($ this ->tempDir .'/Dockerfile ' ));
86116 }
87117
88118 public function testDoNotOverwriteExistingDockerfile (): void
@@ -111,7 +141,7 @@ public function testOverwriteExistingDockerfile(): void
111141
112142 $ tester = $ this ->executeCommand (CreateDockerfileCommand::NAME , [], ['yes ' , 'no ' ]); // overwrite yes, no configure project
113143
114- $ this ->assertStringContainsString ('Dockerfile created ' , $ tester ->getDisplay ());
144+ $ this ->assertStringContainsString ('Created Dockerfile for PHP 8.2 and arm64 architecture ' , $ tester ->getDisplay ());
115145 $ this ->assertStringNotEqualsFile ($ this ->tempDir .'/Dockerfile ' , 'old content ' );
116146 }
117147}
0 commit comments