Skip to content

Commit

Permalink
Simplify sone FQCN. (#43053)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot committed Jul 5, 2022
1 parent 01e1474 commit 57c5672
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 26 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Auth/Access/Gate.php
Expand Up @@ -4,6 +4,7 @@

use Closure;
use Exception;
use Illuminate\Auth\Access\Events\GateEvaluated;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
Expand Down Expand Up @@ -592,7 +593,7 @@ protected function dispatchGateEvaluatedEvent($user, $ability, array $arguments,
{
if ($this->container->bound(Dispatcher::class)) {
$this->container->make(Dispatcher::class)->dispatch(
new Events\GateEvaluated($user, $ability, $result, $arguments)
new GateEvaluated($user, $ability, $result, $arguments)
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Queue/CallQueuedHandler.php
Expand Up @@ -113,7 +113,7 @@ protected function getCommand(array $data)
protected function dispatchThroughMiddleware(Job $job, $command)
{
if ($command instanceof \__PHP_Incomplete_Class) {
throw new \Exception('Job is incomplete class: '.json_encode($command));
throw new Exception('Job is incomplete class: '.json_encode($command));
}

return (new Pipeline($this->container))->send($command)
Expand Down
18 changes: 10 additions & 8 deletions tests/Conditionable/ConditionableTest.php
Expand Up @@ -3,7 +3,9 @@
namespace Illuminate\Tests\Conditionable;

use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\HigherOrderWhenProxy;
use PHPUnit\Framework\TestCase;

class ConditionableTest extends TestCase
Expand All @@ -23,19 +25,19 @@ protected function setUp(): void

public function testWhen(): void
{
$this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->when(true));
$this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->when(false));
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->when(false, null));
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->when(true, function () {
$this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->when(true));
$this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->when(false));
$this->assertInstanceOf(Builder::class, TestConditionableModel::query()->when(false, null));
$this->assertInstanceOf(Builder::class, TestConditionableModel::query()->when(true, function () {
}));
}

public function testUnless(): void
{
$this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(true));
$this->assertInstanceOf(\Illuminate\Support\HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(false));
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->unless(true, null));
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, TestConditionableModel::query()->unless(false, function () {
$this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(true));
$this->assertInstanceOf(HigherOrderWhenProxy::class, TestConditionableModel::query()->unless(false));
$this->assertInstanceOf(Builder::class, TestConditionableModel::query()->unless(true, null));
$this->assertInstanceOf(Builder::class, TestConditionableModel::query()->unless(false, function () {
}));
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/Database/DatabaseEloquentFactoryTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Database;

use BadMethodCallException;
use Carbon\Carbon;
use Faker\Generator;
use Illuminate\Container\Container;
Expand All @@ -17,6 +18,7 @@
use Illuminate\Tests\Database\Fixtures\Models\Money\Price;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use ReflectionClass;

class DatabaseEloquentFactoryTest extends TestCase
{
Expand Down Expand Up @@ -443,7 +445,7 @@ public function test_counted_sequence()
['name' => 'Dayle Rees']
);

$class = new \ReflectionClass($factory);
$class = new ReflectionClass($factory);
$prop = $class->getProperty('count');
$prop->setAccessible(true);
$value = $prop->getValue($factory);
Expand Down Expand Up @@ -622,7 +624,7 @@ public function test_dynamic_trashed_state_respects_existing_state()

public function test_dynamic_trashed_state_throws_exception_when_not_a_softdeletes_model()
{
$this->expectException(\BadMethodCallException::class);
$this->expectException(BadMethodCallException::class);
FactoryTestUserFactory::new()->trashed()->create();
}

Expand Down
8 changes: 5 additions & 3 deletions tests/Database/DatabaseMySqlSchemaStateTest.php
Expand Up @@ -2,9 +2,11 @@

namespace Illuminate\Tests\Database;

use Generator;
use Illuminate\Database\MySqlConnection;
use Illuminate\Database\Schema\MySqlSchemaState;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;

class DatabaseMySqlSchemaStateTest extends TestCase
{
Expand All @@ -19,19 +21,19 @@ public function testConnectionString(string $expectedConnectionString, array $ex
$schemaState = new MySqlSchemaState($connection);

// test connectionString
$method = new \ReflectionMethod(get_class($schemaState), 'connectionString');
$method = new ReflectionMethod(get_class($schemaState), 'connectionString');
$connString = tap($method)->setAccessible(true)->invoke($schemaState);

self::assertEquals($expectedConnectionString, $connString);

// test baseVariables
$method = new \ReflectionMethod(get_class($schemaState), 'baseVariables');
$method = new ReflectionMethod(get_class($schemaState), 'baseVariables');
$variables = tap($method)->setAccessible(true)->invoke($schemaState, $dbConfig);

self::assertEquals($expectedVariables, $variables);
}

public function provider(): \Generator
public function provider(): Generator
{
yield 'default' => [
' --user="${:LARAVEL_LOAD_USER}" --password="${:LARAVEL_LOAD_PASSWORD}" --host="${:LARAVEL_LOAD_HOST}" --port="${:LARAVEL_LOAD_PORT}"', [
Expand Down
5 changes: 3 additions & 2 deletions tests/Foundation/Testing/BootTraitsTest.php
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Foundation\Testing\TestCase as FoundationTestCase;
use Orchestra\Testbench\Concerns\CreatesApplication;
use PHPUnit\Framework\TestCase;
use ReflectionMethod;

trait TestTrait
{
Expand Down Expand Up @@ -34,12 +35,12 @@ public function testSetUpAndTearDownTraits()
{
$testCase = new TestCaseWithTrait;

$method = new \ReflectionMethod($testCase, 'setUpTraits');
$method = new ReflectionMethod($testCase, 'setUpTraits');
tap($method)->setAccessible(true)->invoke($testCase);

$this->assertTrue($testCase->setUp);

$method = new \ReflectionMethod($testCase, 'callBeforeApplicationDestroyedCallbacks');
$method = new ReflectionMethod($testCase, 'callBeforeApplicationDestroyedCallbacks');
tap($method)->setAccessible(true)->invoke($testCase);

$this->assertTrue($testCase->tearDown);
Expand Down
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Integration\Database;

use Exception;
use Illuminate\Contracts\Database\Eloquent\Castable;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;
use Illuminate\Contracts\Database\Eloquent\CastsInboundAttributes;
Expand Down Expand Up @@ -392,7 +393,7 @@ public function set($model, string $key, $value, array $attributes): ?string
}

if (! $value instanceof Settings) {
throw new \Exception("Attribute `{$key}` with JsonSettingsCaster should be a Settings object");
throw new Exception("Attribute `{$key}` with JsonSettingsCaster should be a Settings object");
}

return $value->toJson();
Expand Down
5 changes: 3 additions & 2 deletions tests/Support/SupportStrTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Support;

use Exception;
use Illuminate\Support\Str;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\UuidInterface;
Expand Down Expand Up @@ -504,7 +505,7 @@ public function testItCanSpecifyASequenceOfRandomStringsToUtilise()

public function testItCanSpecifyAFallbackForARandomStringSequence()
{
Str::createRandomStringsUsingSequence([Str::random(), Str::random()], fn () => throw new \Exception('Out of random strings.'));
Str::createRandomStringsUsingSequence([Str::random(), Str::random()], fn () => throw new Exception('Out of random strings.'));
Str::random();
Str::random();

Expand Down Expand Up @@ -1015,7 +1016,7 @@ public function testItCanSpecifyASequenceOfUuidsToUtilise()

public function testItCanSpecifyAFallbackForASequence()
{
Str::createUuidsUsingSequence([Str::uuid(), Str::uuid()], fn () => throw new \Exception('Out of Uuids.'));
Str::createUuidsUsingSequence([Str::uuid(), Str::uuid()], fn () => throw new Exception('Out of Uuids.'));
Str::uuid();
Str::uuid();

Expand Down
11 changes: 6 additions & 5 deletions tests/Testing/TestResponseTest.php
Expand Up @@ -6,6 +6,7 @@
use Illuminate\Container\Container;
use Illuminate\Contracts\View\View;
use Illuminate\Cookie\CookieValuePrefix;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Encryption\Encrypter;
use Illuminate\Filesystem\Filesystem;
Expand Down Expand Up @@ -116,7 +117,7 @@ public function testAssertViewHasWithNestedValue()

public function testAssertViewHasEloquentCollection()
{
$collection = new \Illuminate\Database\Eloquent\Collection([
$collection = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
new TestModel(['id' => 3]),
Expand All @@ -132,7 +133,7 @@ public function testAssertViewHasEloquentCollection()

public function testAssertViewHasEloquentCollectionRespectsOrder()
{
$collection = new \Illuminate\Database\Eloquent\Collection([
$collection = new EloquentCollection([
new TestModel(['id' => 3]),
new TestModel(['id' => 2]),
new TestModel(['id' => 1]),
Expand All @@ -150,7 +151,7 @@ public function testAssertViewHasEloquentCollectionRespectsOrder()

public function testAssertViewHasEloquentCollectionRespectsType()
{
$actual = new \Illuminate\Database\Eloquent\Collection([
$actual = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
]);
Expand All @@ -160,7 +161,7 @@ public function testAssertViewHasEloquentCollectionRespectsType()
'gatherData' => ['foos' => $actual],
]);

$expected = new \Illuminate\Database\Eloquent\Collection([
$expected = new EloquentCollection([
new AnotherTestModel(['id' => 1]),
new AnotherTestModel(['id' => 2]),
]);
Expand All @@ -172,7 +173,7 @@ public function testAssertViewHasEloquentCollectionRespectsType()

public function testAssertViewHasEloquentCollectionRespectsSize()
{
$actual = new \Illuminate\Database\Eloquent\Collection([
$actual = new EloquentCollection([
new TestModel(['id' => 1]),
new TestModel(['id' => 2]),
]);
Expand Down
3 changes: 2 additions & 1 deletion tests/View/Blade/BladeComponentsTest.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\View\Component;
use Illuminate\View\ComponentAttributeBag;
use Illuminate\View\Factory;
use Mockery as m;

class BladeComponentsTest extends AbstractBladeTestCase
Expand Down Expand Up @@ -61,7 +62,7 @@ public function testPropsAreExtractedFromParentAttributesCorrectlyForClassCompon
$component->shouldReceive('withName', 'test');
$component->shouldReceive('shouldRender')->andReturn(false);

$__env = m::mock(\Illuminate\View\Factory::class);
$__env = m::mock(Factory::class);
$__env->shouldReceive('getContainer->make')->with('Test', ['foo' => 'bar', 'other' => 'ok'])->andReturn($component);

$template = $this->compiler->compileString('@component(\'Test::class\', \'test\', ["foo" => "bar"])');
Expand Down

0 comments on commit 57c5672

Please sign in to comment.