55use Illuminate \Console \Command ;
66use LaravelPlus \LaravelUpdater \Console \Commands \AbstractUpstreamCommand ;
77use LaravelPlus \LaravelUpdater \Contracts \VersionControlInterface ;
8- use LaravelPlus \LaravelUpdater \Support \VersionControl ;
98
10- class TestUpstreamCommand extends AbstractUpstreamCommand
9+ final class TestUpstreamCommand extends AbstractUpstreamCommand
1110{
1211 protected $ signature = 'test:upstream-command ' ;
12+
1313 protected $ description = 'Test upstream command ' ;
1414
1515 public function handle (): int
@@ -41,27 +41,27 @@ public function getVersionControl(): VersionControlInterface
4141
4242it ('can be instantiated ' , function () {
4343 $ command = new TestUpstreamCommand ();
44-
44+
4545 expect ($ command )->toBeInstanceOf (AbstractUpstreamCommand::class);
4646 expect ($ command )->toBeInstanceOf (Command::class);
4747});
4848
4949it ('has version control instance ' , function () {
5050 $ command = new TestUpstreamCommand ();
51-
51+
5252 expect ($ command ->getVersionControl ())->toBeInstanceOf (VersionControlInterface::class);
5353});
5454
5555it ('can display logo ' , function () {
5656 $ command = new TestUpstreamCommand ();
57-
57+
5858 // Test that displayLogo doesn't throw an exception
5959 expect (fn () => $ command ->testDisplayLogo ())->not ->toThrow ();
6060});
6161
6262it ('applies default preset when no upstream URL is set ' , function () {
6363 $ command = new TestUpstreamCommand ();
64-
64+
6565 $ config = [
6666 'upstream_url ' => '' ,
6767 'default_preset ' => 'vue ' ,
@@ -73,16 +73,16 @@ public function getVersionControl(): VersionControlInterface
7373 ],
7474 ],
7575 ];
76-
76+
7777 $ result = $ command ->testApplyDefaultPreset ($ config );
78-
78+
7979 expect ($ result ['upstream_url ' ])->toBe ('https://github.com/laravel/vue-starter-kit.git ' );
8080 expect ($ result ['upstream_branch ' ])->toBe ('main ' );
8181});
8282
8383it ('does not apply default preset when upstream URL is already set ' , function () {
8484 $ command = new TestUpstreamCommand ();
85-
85+
8686 $ config = [
8787 'upstream_url ' => 'https://github.com/custom/repo.git ' ,
8888 'default_preset ' => 'vue ' ,
@@ -93,15 +93,15 @@ public function getVersionControl(): VersionControlInterface
9393 ],
9494 ],
9595 ];
96-
96+
9797 $ result = $ command ->testApplyDefaultPreset ($ config );
98-
98+
9999 expect ($ result ['upstream_url ' ])->toBe ('https://github.com/custom/repo.git ' );
100100});
101101
102102it ('does not apply default preset when no default preset is configured ' , function () {
103103 $ command = new TestUpstreamCommand ();
104-
104+
105105 $ config = [
106106 'upstream_url ' => '' ,
107107 'default_preset ' => null ,
@@ -112,15 +112,15 @@ public function getVersionControl(): VersionControlInterface
112112 ],
113113 ],
114114 ];
115-
115+
116116 $ result = $ command ->testApplyDefaultPreset ($ config );
117-
117+
118118 expect ($ result ['upstream_url ' ])->toBe ('' );
119119});
120120
121121it ('merges preset hooks with existing hooks ' , function () {
122122 $ command = new TestUpstreamCommand ();
123-
123+
124124 $ config = [
125125 'upstream_url ' => '' ,
126126 'default_preset ' => 'vue ' ,
@@ -133,16 +133,16 @@ public function getVersionControl(): VersionControlInterface
133133 ],
134134 ],
135135 ];
136-
136+
137137 $ result = $ command ->testApplyDefaultPreset ($ config );
138-
138+
139139 expect ($ result ['post_update ' ])->toContain ('composer install ' );
140140 expect ($ result ['post_update ' ])->toContain ('npm install ' );
141141});
142142
143143it ('can run tests with valid configuration ' , function () {
144144 $ command = new TestUpstreamCommand ();
145-
145+
146146 $ config = [
147147 'git_binary ' => 'git ' ,
148148 'working_dir ' => base_path (),
@@ -151,7 +151,7 @@ public function getVersionControl(): VersionControlInterface
151151 'local_branch ' => 'main ' ,
152152 'strategy ' => 'merge ' ,
153153 ];
154-
154+
155155 // Mock the version control to return successful results
156156 $ versionControl = Mockery::mock (VersionControlInterface::class);
157157 $ versionControl ->shouldReceive ('run ' )
@@ -169,21 +169,21 @@ public function getVersionControl(): VersionControlInterface
169169 $ versionControl ->shouldReceive ('run ' )
170170 ->with (['status ' , '--porcelain ' ], false )
171171 ->andReturn ('' );
172-
172+
173173 // Replace the version control instance
174174 $ reflection = new ReflectionClass ($ command );
175175 $ property = $ reflection ->getProperty ('versionControl ' );
176176 $ property ->setAccessible (true );
177177 $ property ->setValue ($ command , $ versionControl );
178-
178+
179179 $ result = $ command ->testRunTests ($ config );
180-
180+
181181 expect ($ result )->toBeTrue ();
182182});
183183
184184it ('returns false when tests fail ' , function () {
185185 $ command = new TestUpstreamCommand ();
186-
186+
187187 $ config = [
188188 'git_binary ' => 'git ' ,
189189 'working_dir ' => '/nonexistent ' ,
@@ -192,16 +192,16 @@ public function getVersionControl(): VersionControlInterface
192192 'local_branch ' => 'main ' ,
193193 'strategy ' => 'merge ' ,
194194 ];
195-
195+
196196 $ result = $ command ->testRunTests ($ config );
197-
197+
198198 expect ($ result )->toBeFalse ();
199199});
200200
201201it ('can handle command execution ' , function () {
202202 $ command = new TestUpstreamCommand ();
203-
203+
204204 $ result = $ command ->handle ();
205-
205+
206206 expect ($ result )->toBe (Command::SUCCESS );
207207});
0 commit comments