Skip to content

Commit

Permalink
Test Improvements (#50778)
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Mar 27, 2024
1 parent efa867e commit eb94218
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions tests/Integration/Foundation/FoundationHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace Illuminate\Tests\Integration\Foundation;

use Exception;
use Illuminate\Config\Repository as ConfigRepository;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

class FoundationHelpersTest extends TestCase
Expand Down Expand Up @@ -66,10 +66,9 @@ public function testMixReportsExceptionWhenAssetIsMissingFromManifest()
unlink($manifest);
}

#[WithConfig('app.debug', false)]
public function testMixSilentlyFailsWhenAssetIsMissingFromManifestWhenNotInDebugMode()
{
$this->app['config']->set('app.debug', false);

$manifest = $this->makeManifest();

$path = mix('missing.js');
Expand All @@ -79,13 +78,12 @@ public function testMixSilentlyFailsWhenAssetIsMissingFromManifestWhenNotInDebug
unlink($manifest);
}

#[WithConfig('app.debug', true)]
public function testMixThrowsExceptionWhenAssetIsMissingFromManifestWhenInDebugMode()
{
$this->expectException(Exception::class);
$this->expectExceptionMessage('Unable to locate Mix file: /missing.js.');

$this->app['config']->set('app.debug', true);

$manifest = $this->makeManifest();

try {
Expand All @@ -97,11 +95,11 @@ public function testMixThrowsExceptionWhenAssetIsMissingFromManifestWhenInDebugM
}
}

#[WithConfig('app.debug', true)]
public function testMixOnlyThrowsAndReportsOneExceptionWhenAssetIsMissingFromManifestWhenInDebugMode()
{
$handler = new FakeHandler;
$this->app->instance(ExceptionHandler::class, $handler);
$this->app['config']->set('app.debug', true);

$manifest = $this->makeManifest();

Expand All @@ -118,20 +116,15 @@ public function testMixOnlyThrowsAndReportsOneExceptionWhenAssetIsMissingFromMan

public function testFakeReturnsSameInstance()
{
app()->instance('config', new ConfigRepository([]));

$this->assertSame(fake(), fake());
$this->assertSame(fake(), fake('en_US'));
$this->assertSame(fake('en_AU'), fake('en_AU'));
$this->assertNotSame(fake('en_US'), fake('en_AU'));

app()->flush();
}

public function testFakeUsesLocale()
{
mt_srand(12345, MT_RAND_PHP);
app()->instance('config', new ConfigRepository([]));

// Should fallback to en_US
$this->assertSame('Arkansas', fake()->state());
Expand All @@ -144,7 +137,7 @@ public function testFakeUsesLocale()
'Guadeloupe', 'Martinique', 'Guyane', 'La Réunion', 'Mayotte',
]);

app()->instance('config', new ConfigRepository(['app' => ['faker_locale' => 'en_AU']]));
config(['app.faker_locale' => 'en_AU']);
mt_srand(4, MT_RAND_PHP);

// Should fallback to en_US
Expand Down

0 comments on commit eb94218

Please sign in to comment.