Skip to content

Commit

Permalink
Merge branch '10.x' into 11.x
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 21, 2024
2 parents 6b2de05 + a2d70b5 commit 428f86d
Show file tree
Hide file tree
Showing 39 changed files with 151 additions and 275 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"league/flysystem-sftp-v3": "^3.0",
"mockery/mockery": "^1.6",
"nyholm/psr7": "^1.2",
"orchestra/testbench-core": "^9.0",
"orchestra/testbench-core": "^9.0.6",
"pda/pheanstalk": "^5.0",
"phpstan/phpstan": "^1.4.7",
"phpunit/phpunit": "^10.5|^11.0",
Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,11 @@ public function push(...$values)
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,11 @@ public function partition($key, $operator = null, $value = null);
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source);

Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,11 @@ public function select($keys)
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source)
{
Expand Down
9 changes: 1 addition & 8 deletions tests/Integration/Auth/ApiAuthenticationWithEloquentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Illuminate\Tests\Integration\Auth;

use Illuminate\Database\QueryException;
use Illuminate\Foundation\Auth\User as FoundationUser;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase;
Expand All @@ -12,11 +11,10 @@
#[RequiresPhpExtension('pdo_mysql')]
class ApiAuthenticationWithEloquentTest extends TestCase
{
protected function getEnvironmentSetUp($app)
protected function defineEnvironment($app)
{
// Auth configuration
$app['config']->set('auth.defaults.guard', 'api');
$app['config']->set('auth.providers.users.model', User::class);

$app['config']->set('auth.guards.api', [
'driver' => 'token',
Expand Down Expand Up @@ -58,8 +56,3 @@ public function testAuthenticationViaApiWithEloquentUsingWrongDatabaseCredential
}
}
}

class User extends FoundationUser
{
//
}
50 changes: 28 additions & 22 deletions tests/Integration/Auth/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,50 @@
use Illuminate\Auth\SessionGuard;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Events\Dispatcher;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use Illuminate\Support\Testing\Fakes\EventFake;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use InvalidArgumentException;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\TestCase;

#[WithMigration]
class AuthenticationTest extends TestCase
{
protected function getEnvironmentSetUp($app)
use RefreshDatabase;

protected function defineEnvironment($app)
{
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);
$app['config']->set([
'auth.providers.users.model' => AuthenticationTestUser::class,
'hashing.driver' => 'bcrypt',
]);
}

$app['config']->set('hashing', ['driver' => 'bcrypt']);
protected function defineRoutes($router)
{
$router->get('basic', function () {
return $this->app['auth']->guard()->basic()
?: $this->app['auth']->user()->toJson();
});

$router->get('basicWithCondition', function () {
return $this->app['auth']->guard()->basic('email', ['is_active' => true])
?: $this->app['auth']->user()->toJson();
});
}

protected function setUp(): void
protected function afterRefreshingDatabase()
{
parent::setUp();

Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('email');
$table->string('username');
$table->string('password');
$table->string('remember_token')->default(null)->nullable();
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});

Schema::table('users', function (Blueprint $table) {
$table->tinyInteger('is_active')->default(0);
});

Expand All @@ -50,16 +66,6 @@ protected function setUp(): void
'password' => bcrypt('password'),
'is_active' => true,
]);

$this->app->make('router')->get('basic', function () {
return $this->app['auth']->guard()->basic()
?: $this->app['auth']->user()->toJson();
});

$this->app->make('router')->get('basicWithCondition', function () {
return $this->app['auth']->guard()->basic('email', ['is_active' => true])
?: $this->app['auth']->user()->toJson();
});
}

public function testBasicAuthProtectsRoute()
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/Auth/ForgotPasswordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
namespace Illuminate\Tests\Integration\Auth;

use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

#[WithMigration]
class ForgotPasswordTest extends TestCase
{
use RefreshDatabase;

protected function tearDown(): void
{
ResetPassword::$createUrlCallback = null;
Expand All @@ -27,11 +32,6 @@ protected function defineEnvironment($app)
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);
}

protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations();
}

protected function defineRoutes($router)
{
$router->get('password/reset/{token}', function ($token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
namespace Illuminate\Tests\Integration\Auth;

use Illuminate\Auth\Notifications\ResetPassword;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Notification;
use Illuminate\Support\Facades\Password;
use Illuminate\Support\Str;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;

#[WithMigration]
class ForgotPasswordWithoutDefaultRoutesTest extends TestCase
{
use RefreshDatabase;

protected function tearDown(): void
{
ResetPassword::$createUrlCallback = null;
Expand All @@ -27,11 +32,6 @@ protected function defineEnvironment($app)
$app['config']->set('auth.providers.users.model', AuthenticationTestUser::class);
}

protected function defineDatabaseMigrations()
{
$this->loadLaravelMigrations();
}

protected function defineRoutes($router)
{
$router->get('custom/password/reset/{token}', function ($token) {
Expand Down
11 changes: 2 additions & 9 deletions tests/Integration/Cache/DynamoDbStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@
use Illuminate\Contracts\Cache\Repository;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Str;
use Orchestra\Testbench\Attributes\RequiresEnv;
use Orchestra\Testbench\TestCase;

#[RequiresEnv('DYNAMODB_CACHE_TABLE')]
class DynamoDbStoreTest extends TestCase
{
protected function setUp(): void
{
if (! env('DYNAMODB_CACHE_TABLE')) {
$this->markTestSkipped('DynamoDB not configured.');
}

parent::setUp();
}

public function testItemsCanBeStoredAndRetrieved()
{
Cache::driver('dynamodb')->put('name', 'Taylor', 10);
Expand Down
13 changes: 2 additions & 11 deletions tests/Integration/Cache/FileCacheLockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,12 @@

use Exception;
use Illuminate\Support\Facades\Cache;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

#[WithConfig('cache.default', 'file')]
class FileCacheLockTest extends TestCase
{
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app['config']->set('cache.default', 'file');
}

public function testLocksCanBeAcquiredAndReleased()
{
Cache::lock('foo')->forceRelease();
Expand Down
20 changes: 3 additions & 17 deletions tests/Integration/Cache/NoLockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,13 @@
namespace Illuminate\Tests\Integration\Cache;

use Illuminate\Support\Facades\Cache;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;

#[WithConfig('cache.default', 'null')]
#[WithConfig('cache.stores.null', ['driver' => 'null'])]
class NoLockTest extends TestCase
{
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app['config']->set('cache.default', 'null');

$app['config']->set('cache.stores', [
'null' => [
'driver' => 'null',
],
]);
}

public function testLocksCanAlwaysBeAcquiredAndReleased()
{
Cache::lock('foo')->forceRelease();
Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Console/Scheduling/CallbackEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@

class CallbackEventTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();

m::close();
}

public function testDefaultResultIsSuccess()
{
$success = null;
Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Console/Scheduling/EventPingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@

class EventPingTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();

m::close();
}

public function testPingRescuesTransferExceptions()
{
$this->spy(ExceptionHandler::class)
Expand Down
7 changes: 0 additions & 7 deletions tests/Integration/Cookie/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,6 @@

class CookieTest extends TestCase
{
protected function tearDown(): void
{
parent::tearDown();

Carbon::setTestNow(null);
}

public function test_cookie_is_sent_back_with_proper_expire_time_when_should_expire_on_close()
{
$this->app['config']->set('session.expire_on_close', true);
Expand Down
13 changes: 2 additions & 11 deletions tests/Integration/Encryption/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,13 @@
namespace Illuminate\Tests\Integration\Encryption;

use Illuminate\Encryption\Encrypter;
use Illuminate\Encryption\EncryptionServiceProvider;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
use RuntimeException;

#[WithConfig('app.key', 'base64:IUHRqAQ99pZ0A1MPjbuv1D6ff3jxv0GIvS2qIW4JNU4=')]
class EncryptionTest extends TestCase
{
protected function getEnvironmentSetUp($app)
{
$app['config']->set('app.key', 'base64:IUHRqAQ99pZ0A1MPjbuv1D6ff3jxv0GIvS2qIW4JNU4=');
}

protected function getPackageProviders($app)
{
return [EncryptionServiceProvider::class];
}

public function testEncryptionProviderBind()
{
$this->assertInstanceOf(Encrypter::class, $this->app->make('encrypter'));
Expand Down
Loading

0 comments on commit 428f86d

Please sign in to comment.