Skip to content

Commit 98435c8

Browse files
Fix tests
1 parent 566214c commit 98435c8

2 files changed

Lines changed: 29 additions & 33 deletions

File tree

tests/Console/ConfigureCmsCommandTest.php

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
config(['ozu-client.website_key' => 'test']);
1515
Http::fake();
1616

17-
Schema::swap(new class {
17+
Schema::swap(new class
18+
{
1819
public function getColumnListing($table): array
1920
{
2021
return ['dummy-text', 'dummy-check', 'dummy-image', 'dummy-date', 'dummy-select'];
2122
}
23+
2224
public function getColumnType($table, $column): string
2325
{
24-
return match($column) {
26+
return match ($column) {
2527
'dummy-check' => 'tinyint',
2628
'dummy-date' => 'date',
2729
default => 'string',
@@ -48,7 +50,7 @@ public function ozuCollectionKey(): string
4850
},
4951
]]);
5052

51-
$this->artisan('ozu:configure-cms')
53+
$this->artisan('ozu:configure')
5254
->expectsOutput('CMS configuration sent to Ozu.')
5355
->assertExitCode(Command::SUCCESS);
5456

@@ -93,7 +95,7 @@ public static function configureOzuCollection(OzuCollectionConfig $config): OzuC
9395
},
9496
]]);
9597

96-
$this->artisan('ozu:configure-cms')
98+
$this->artisan('ozu:configure')
9799
->expectsOutput('CMS configuration sent to Ozu.')
98100
->assertExitCode(Command::SUCCESS);
99101

@@ -136,7 +138,7 @@ public static function configureOzuCollectionList(OzuCollectionListConfig $confi
136138
},
137139
]]);
138140

139-
$this->artisan('ozu:configure-cms')
141+
$this->artisan('ozu:configure')
140142
->expectsOutput('CMS configuration sent to Ozu.')
141143
->assertExitCode(Command::SUCCESS);
142144

@@ -207,7 +209,7 @@ public static function configureOzuCollectionForm(OzuCollectionFormConfig $confi
207209
},
208210
]]);
209211

210-
$this->artisan('ozu:configure-cms')
212+
$this->artisan('ozu:configure')
211213
->expectsOutput('CMS configuration sent to Ozu.')
212214
->assertExitCode(Command::SUCCESS);
213215

@@ -241,11 +243,13 @@ public static function configureOzuCollectionForm(OzuCollectionFormConfig $confi
241243
});
242244

243245
it('sends custom fields configuration to Ozu', function () {
244-
Schema::swap(new class {
246+
Schema::swap(new class
247+
{
245248
public function getColumnListing($table): array
246249
{
247250
return ['dummy-text'];
248251
}
252+
249253
public function getColumnType($table, $column): string
250254
{
251255
return 'string';
@@ -262,7 +266,7 @@ public function ozuCollectionKey(): string
262266
},
263267
]]);
264268

265-
$this->artisan('ozu:configure-cms')
269+
$this->artisan('ozu:configure')
266270
->expectsOutput('CMS configuration sent to Ozu.')
267271
->assertExitCode(Command::SUCCESS);
268272

@@ -290,7 +294,7 @@ public function ozuCollectionKey(): string
290294
},
291295
]]);
292296

293-
$this->artisan('ozu:configure-cms')
297+
$this->artisan('ozu:configure')
294298
->expectsOutput('CMS configuration sent to Ozu.')
295299
->assertExitCode(Command::SUCCESS);
296300

@@ -329,7 +333,7 @@ public static function configureOzuCollection(OzuCollectionConfig $config): OzuC
329333

330334
config(['ozu-client.collections' => [$parentCollectionClass]]);
331335

332-
$this->artisan('ozu:configure-cms')
336+
$this->artisan('ozu:configure')
333337
->expectsOutput('CMS configuration sent to Ozu.')
334338
->assertExitCode(Command::SUCCESS);
335339

@@ -370,10 +374,10 @@ public static function configureOzuCollectionList(OzuCollectionListConfig $confi
370374
->addColumn(OzuColumn::makeText('dummy-text'))
371375
->addColumn(OzuColumn::makeCheck('dummy-another-check'));
372376
}
373-
}
377+
},
374378
]]);
375379

376-
$this->artisan('ozu:configure-cms')
380+
$this->artisan('ozu:configure')
377381
->expectsOutputToContain('The keys [dummy-another-check] are defined either in the list or in the form but are not custom fields of the model')
378382
->assertExitCode(Command::SUCCESS);
379383
});
@@ -394,10 +398,10 @@ public static function configureOzuCollectionForm(OzuCollectionFormConfig $confi
394398
OzuField::makeText('dummy-another-text')
395399
);
396400
}
397-
}
401+
},
398402
]]);
399403

400-
$this->artisan('ozu:configure-cms')
404+
$this->artisan('ozu:configure')
401405
->expectsOutputToContain('The keys [dummy-another-text] are defined either in the list or in the form but are not custom fields of the model')
402406
->assertExitCode(Command::SUCCESS);
403407
});

tests/Console/FetchSettingsFromOzuTest.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
11
<?php
22

33
use Code16\OzuClient\Client as OzuClient;
4-
use Code16\OzuClient\Console\FetchSettingsFromOzu;
4+
use Code16\OzuClient\Console\FetchDataFromOzu;
55
use Code16\OzuClient\Tests\Fixtures\DummySettings;
66
use Illuminate\Support\Facades\Cache;
77
use Mockery as m;
88

9-
it('fails when no settings class is configured', function () {
9+
it('succeeds when settings are not configured', function () {
1010
config(['ozu-client.settings' => null, 'cache.default' => 'array']);
1111

12-
$this->artisan('ozu:fetch-settings')
13-
->expectsOutput('OZU settings are not configured.')
14-
->assertExitCode(FetchSettingsFromOzu::FAILURE);
15-
});
16-
17-
it('succeeds with dontFailIfNoSettingsClass option when settings are not configured', function () {
18-
config(['ozu-client.settings' => null, 'cache.default' => 'array']);
19-
20-
$this->artisan('ozu:fetch-settings --dontFailIfNoSettingsClass')
21-
->expectsOutput('OZU settings are not configured.')
22-
->assertExitCode(FetchSettingsFromOzu::SUCCESS);
12+
$this->artisan('ozu:import --settings')
13+
->expectsOutput('❌ OZU settings are not configured.')
14+
->assertExitCode(FetchDataFromOzu::SUCCESS);
2315
});
2416

2517
it('fails when the Ozu client returns null (unsuccessful response)', function () {
@@ -29,9 +21,9 @@
2921
$mock->shouldReceive('fetchSettings')->once()->andReturn(null);
3022
$this->app->instance(OzuClient::class, $mock);
3123

32-
$this->artisan('ozu:fetch-settings')
33-
->expectsOutput('Ozu’s response was not successful.')
34-
->assertExitCode(FetchSettingsFromOzu::FAILURE);
24+
$this->artisan('ozu:import --settings')
25+
->expectsOutput('Ozu’s response was not successful.')
26+
->assertExitCode(FetchDataFromOzu::FAILURE);
3527
});
3628

3729
it('caches fetched settings with class-based prefix and decodes JSON values', function () {
@@ -46,9 +38,9 @@
4638
]);
4739
$this->app->instance(OzuClient::class, $mock);
4840

49-
$this->artisan('ozu:fetch-settings')
50-
->expectsOutput('Settings fetched successfully')
51-
->assertExitCode(FetchSettingsFromOzu::SUCCESS);
41+
$this->artisan('ozu:import --settings')
42+
->expectsOutput('Settings fetched successfully')
43+
->assertExitCode(FetchDataFromOzu::SUCCESS);
5244

5345
expect(Cache::get('DummySettings_foo'))->toBe('value-foo');
5446
expect(Cache::get('DummySettings_bar'))->toBe(['nested' => true]);

0 commit comments

Comments
 (0)