prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
ate\Tests\Integration\Routing;
use Orchestra\Testbench\TestCase;
class RouteCachingTest extends TestCase
{
public function testWildcardCatchAllRoutes()
{
$this->routes(__DIR__.'/Fixtures/wildcard_catch_all_routes.php');
$this->get('/foo')->assertSee('Regular route');
$this->get('/bar'... | ar');
$this->get('/foo/1/bar')->assertSee('Redirect response');
$this->get('/foo/1')->assertRedirect('/foo/1/bar');
}
protected function routes(string $file)
{
$this->defineCacheRoutes(file_get_contents($file));
}
} | rect('/foo/1/b | {
"filepath": "tests/Integration/Routing/RouteCachingTest.php",
"language": "php",
"file_size": 807,
"cut_index": 536,
"middle_length": 14
} |
pace Illuminate\Tests\Integration\Routing;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase;
use User;
class RouteCanBackedEnumTest extends TestCase
{
public function testSimpleRouteWithStringBackedEnumCanAbilityGuestForbiddenThroughTheFramework()
{
... | $response->assertForbidden();
}
public function testSimpleRouteWithStringBackedEnumCanAbilityGuestAllowedThroughTheFramework()
{
$gate = Gate::define(AbilityBackedEnum::AccessRoute, fn (?User $user) => true);
$this->assertArra | t('/', function () {
return 'Hello World';
})->can(AbilityBackedEnum::NotAccessRoute);
$this->assertEquals(['can:not-access-route'], $route->middleware());
$response = $this->get('/');
| {
"filepath": "tests/Integration/Routing/RouteCanBackedEnumTest.php",
"language": "php",
"file_size": 1384,
"cut_index": 524,
"middle_length": 229
} |
inate\Routing\Middleware\SubstituteBindings;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class RouteRedirectTest extends TestCase
{
#[DataProvider('routeRedirectDataSets')]
public function testRouteRedirect($redirectFrom, $redirectTo, $... | '/to'],
'route redirect with one parameter' => ['from/{param}/{param2?}', 'to', '/from/value1', '/to'],
'route redirect with two parameters' => ['from/{param}/{param2?}', 'to', '/from/value1/value2', '/to'],
'route redi | onse->assertRedirect($redirectUri);
$response->assertStatus(301);
}
public static function routeRedirectDataSets()
{
return [
'route redirect with no parameters' => ['from', 'to', '/from', | {
"filepath": "tests/Integration/Routing/RouteRedirectTest.php",
"language": "php",
"file_size": 3808,
"cut_index": 614,
"middle_length": 229
} |
de());
$this->assertSame('singleton show', $response->getContent());
$this->assertSame('http://localhost/avatar/edit', route('avatar.edit'));
$response = $this->get('/avatar/edit');
$this->assertEquals(200, $response->getStatusCode());
$this->assertSame('singleton edit', $respon... | pdate', $response->getContent());
// $this->assertSame('http://localhost/avatar', route('avatar.destroy'));
// $response = $this->delete('/avatar');
// $this->assertEquals(404, $response->getStatusCode());
// $this->assertS | usCode());
$this->assertSame('singleton update', $response->getContent());
$response = $this->patch('/avatar');
$this->assertEquals(200, $response->getStatusCode());
$this->assertSame('singleton u | {
"filepath": "tests/Integration/Routing/RouteSingletonTest.php",
"language": "php",
"file_size": 22530,
"cut_index": 1331,
"middle_length": 229
} |
ng;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View;
use Orchestra\Testbench\TestCase;
class RouteViewTest extends TestCase
{
public function testRouteView()
{
Route::view('route', 'view', ['foo' => 'bar']);
View::addLocation(__DIR__.'/Fixtures');
$this->ass... | ));
$this->assertStringContainsString('Test bar', $this->get('/route/value1')->getContent());
tap($this->get('/route/value1/value2'), function ($response) {
$this->assertSame('value1', $response->viewData('param'));
| {
Route::view('route/{param}/{param2?}', 'view', ['foo' => 'bar']);
View::addLocation(__DIR__.'/Fixtures');
$this->assertStringContainsString('Test bar', $this->get('/route/value1/value2')->getContent( | {
"filepath": "tests/Integration/Routing/RouteViewTest.php",
"language": "php",
"file_size": 2357,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Route;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use... | outeServiceProvider::class,
];
}
/** {@inheritDoc} */
#[\Override]
protected function setUp(): void
{
$_ENV['APP_ROUTES_CACHE'] = realpath(join_paths(__DIR__, 'stubs', 'serializable-closure-v1', 'routes-v7.php'));
| 1CacheRouteTest extends TestCase
{
use RefreshDatabase;
/** {@inheritDoc} */
#[\Override]
protected function getPackageProviders($app)
{
return [
\Illuminate\Foundation\Support\Providers\R | {
"filepath": "tests/Integration/Routing/SerializableClosureV1CacheRouteTest.php",
"language": "php",
"file_size": 1546,
"cut_index": 537,
"middle_length": 229
} |
?php
namespace Illuminate\Tests\Integration\Routing;
use Illuminate\Support\Facades\Route;
use Orchestra\Testbench\TestCase;
class SimpleRouteTest extends TestCase
{
public function testSimpleRouteThroughTheFramework()
{
Route::get('/', function () {
return 'Hello World';
});
... | return 'Hello World';
})->name(RouteNameEnum::UserIndex);
$response = $this->get(\route(RouteNameEnum::UserIndex, ['foo' => 'bar']));
$this->assertSame('Hello World', $response->content());
$this->assertSame('ba | onse->content());
$this->assertSame('bar', $response->baseRequest->query('foo'));
}
public function testSimpleRouteWitStringBackedEnumRouteNameThroughTheFramework()
{
Route::get('/', function () {
| {
"filepath": "tests/Integration/Routing/SimpleRouteTest.php",
"language": "php",
"file_size": 1049,
"cut_index": 513,
"middle_length": 229
} |
ase;
class UrlSigningTest extends TestCase
{
protected function defineEnvironment($app): void
{
$app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']);
}
public function testSigningUrl()
{
Route::get('/foo/{id}', function (Request $request, $id) {
return... | ug()
{
Route::get('/foo/{post:slug}', function (Request $request, $slug) {
return ['slug' => $slug, 'valid' => $request->hasValidSignature() ? 'valid' : 'invalid'];
})->name('foo');
$model = new RoutableInterfaceStu | ion ($response) {
$this->assertSame('valid', $response->original);
$this->assertIsString($response->baseRequest->query('signature'));
});
}
public function testSigningUrlWithCustomRouteSl | {
"filepath": "tests/Integration/Routing/UrlSigningTest.php",
"language": "php",
"file_size": 15791,
"cut_index": 921,
"middle_length": 229
} |
1 => [
'/' => [
0 => [
0 => [
'_route' => 'generated::7CFionvE02fEbBNP',
],
1 => null,
2 => [
'GET' => 0,
... | 0 => [
'_route' => 'generated::YmZUvOCRFrqhC2sO',
],
1 => [
0 => 'user',
],
2 => [
| ],
],
],
2 => [
0 => '{^(?|/users/([^/]++)(*:22))/?$}sDu',
],
3 => [
22 => [
0 => [
| {
"filepath": "tests/Integration/Routing/stubs/serializable-closure-v1/routes-v7.php",
"language": "php",
"file_size": 4288,
"cut_index": 614,
"middle_length": 229
} |
<?php
namespace Illuminate\Tests\Integration\Console;
use Illuminate\Foundation\Console\ViewClearCommand;
use Illuminate\Support\Facades\Artisan;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\TestWith;
class CallCommandsTest extends TestCase
{
protected function setUp(): void
{
$... | });
});
parent::setUp();
}
#[TestWith(['test:a'])]
#[TestWith(['test:b'])]
#[TestWith(['test:c'])]
public function testItCanCallCommands(string $command): void
{
$this->artisan($command)->assertSuccessful( | b', function () {
$this->call(ViewClearCommand::class);
});
Artisan::command('test:c', function () {
$this->call($this->laravel->make(ViewClearCommand::class));
| {
"filepath": "tests/Integration/Console/CallCommandsTest.php",
"language": "php",
"file_size": 1008,
"cut_index": 512,
"middle_length": 229
} |
e\Cache\Repository;
use Illuminate\Console\Events\ScheduledTaskFailed;
use Illuminate\Console\Scheduling\CacheEventMutex;
use Illuminate\Console\Scheduling\CacheSchedulingMutex;
use Illuminate\Console\Scheduling\EventMutex;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Console\Scheduling\SchedulingMutex;
u... | function __construct()
{
$this->store = new Repository(new ArrayStore(true));
}
public function store($name = null)
{
return $this->store;
}
};
$ | hedulingTest extends TestCase
{
protected $log = [];
protected function setUp(): void
{
parent::setUp();
$cache = new class implements Factory
{
public $store;
public | {
"filepath": "tests/Integration/Console/CallbackSchedulingTest.php",
"language": "php",
"file_size": 4083,
"cut_index": 614,
"middle_length": 229
} |
tra\Testbench\TestCase;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\ConsoleOutput;
class CommandDurationThresholdTest extends TestCase
{
public function testItCanHandleExceedingCommandDuration(): void
{
$kernel = $this->app[Kernel::class];
$kernel->comm... | econd()->addMilliseconds(1));
$kernel->terminate($input, 21);
$this->assertTrue($called);
}
public function testItDoesntCallWhenExactlyThresholdDuration(): void
{
$kernel = $this->app[Kernel::class];
$kernel->c | lled) {
$called = true;
});
Carbon::setTestNow(Carbon::now());
$kernel->handle($input, new ConsoleOutput);
$this->assertFalse($called);
Carbon::setTestNow(Carbon::now()->addS | {
"filepath": "tests/Integration/Console/CommandDurationThresholdTest.php",
"language": "php",
"file_size": 6825,
"cut_index": 716,
"middle_length": 229
} |
el;
use Illuminate\Events\Dispatcher;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Foundation\Testing\WithConsoleEvents;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str;
use Orchestra\Testbench\Foundation\Application as Testbench;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attribut... | $this->afterApplicationCreated(function () {
$this->files = new Filesystem;
$this->logfile = storage_path(sprintf('logs/command_events_test_%s.log', (string) Str::random()));
});
$this->beforeApplicationDestroy | */
protected $logfile;
/**
* The Filesystem instance for writing stubs and logs.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
protected function setUp(): void
{
| {
"filepath": "tests/Integration/Console/CommandEventsTest.php",
"language": "php",
"file_size": 5338,
"cut_index": 716,
"middle_length": 229
} |
h\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_pgsql')]
class PostgresSchemaBuilderTest extends PostgresTestCase
{
protected function defineEnviron... | ists public.table');
DB::statement('drop table if exists private.table');
DB::statement('drop view if exists public.foo');
DB::statement('drop view if exists private.foo');
DB::statement('drop schema private');
pa | Migrations()
{
parent::defineDatabaseMigrations();
DB::statement('create schema if not exists private');
}
protected function destroyDatabaseMigrations()
{
DB::statement('drop table if ex | {
"filepath": "tests/Integration/Database/Postgres/PostgresSchemaBuilderTest.php",
"language": "php",
"file_size": 7951,
"cut_index": 716,
"middle_length": 229
} |
ttributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class DatabaseMariaDbConnectionTest extends MariaDbTestCase
{
const TABLE = 'player';
const FL... | function destroyDatabaseMigrations()
{
Schema::drop(self::TABLE);
}
#[DataProvider('floatComparisonsDataProvider')]
public function testJsonFloatComparison($value, $operator, $shouldMatch)
{
DB::table(self::TABLE)->inse | Schema::create(self::TABLE, function (Blueprint $table) {
$table->json(self::JSON_COL)->nullable();
$table->float(self::FLOAT_COL)->nullable();
});
}
}
protected | {
"filepath": "tests/Integration/Database/MariaDb/DatabaseMariaDbConnectionTest.php",
"language": "php",
"file_size": 5892,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Integration\Database\MariaDb;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class... | )
{
Schema::drop('users');
}
public function testRenameColumnOnTableWithEnum()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
$this->assertT | {
$table->integer('id');
$table->string('name');
$table->string('age');
$table->enum('color', ['red', 'blue']);
});
}
protected function destroyDatabaseMigrations( | {
"filepath": "tests/Integration/Database/MariaDb/DatabaseMariaDbSchemaBuilderAlterTableWithEnumTest.php",
"language": "php",
"file_size": 2012,
"cut_index": 537,
"middle_length": 229
} |
print;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
class JoinLateralTest extends SqlServerTestCase
{
protected function afterRefreshingDatabase()
{
Schema::create('users', function (Blueprint $table) {
$table->id('id');
$... | n setUp(): void
{
parent::setUp();
DB::table('users')->insert([
['name' => Str::random()],
['name' => Str::random()],
]);
DB::table('posts')->insert([
['title' => Str::random(), 'rat | ('rating');
$table->unsignedBigInteger('user_id');
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop('posts');
Schema::drop('users');
}
protected functio | {
"filepath": "tests/Integration/Database/SqlServer/JoinLateralTest.php",
"language": "php",
"file_size": 3082,
"cut_index": 614,
"middle_length": 229
} |
Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_pgsql')]
class DatabasePostgresConnectionTest extends PostgresTestCase
{
protected function afterRefreshin... | $key, array $value = ['value' => 123])
{
DB::table('json_table')->insert(['json_col' => json_encode($value)]);
$this->assertSame($expected, DB::table('json_table')->whereNull("json_col->$key")->exists());
}
#[DataProvider('js | });
}
}
protected function destroyDatabaseMigrations()
{
Schema::drop('json_table');
}
#[DataProvider('jsonWhereNullDataProvider')]
public function testJsonWhereNull($expected, | {
"filepath": "tests/Integration/Database/Postgres/DatabasePostgresConnectionTest.php",
"language": "php",
"file_size": 5170,
"cut_index": 716,
"middle_length": 229
} |
?php
namespace Illuminate\Tests\Integration\Database\MariaDb;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem(... | ->app['config']->get('database.connections.mariadb.database'))
->where('table_name', 'users')
->select('table_comment as table_comment')
->first();
$this->assertSame('This is a comment', $tableInfo->table_commen | 'users', function (Blueprint $table) {
$table->id();
$table->comment('This is a comment');
});
$tableInfo = DB::table('information_schema.tables')
->where('table_schema', $this | {
"filepath": "tests/Integration/Database/MariaDb/DatabaseMariaDbSchemaBuilderTest.php",
"language": "php",
"file_size": 1042,
"cut_index": 513,
"middle_length": 229
} |
ase\MariaDb;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql... | 'articles');
}
protected function setUp(): void
{
parent::setUp();
DB::table('articles')->insert([
['title' => 'MariaDB Tutorial', 'body' => 'DBMS stands for DataBase ...'],
['title' => 'How To Use Mari | 'id');
$table->string('title', 200);
$table->text('body');
$table->fulltext(['title', 'body']);
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop( | {
"filepath": "tests/Integration/Database/MariaDb/FulltextTest.php",
"language": "php",
"file_size": 2579,
"cut_index": 563,
"middle_length": 229
} |
ase\MariaDb;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql... | KE queries work correctly with emojis in JSON fields
// This verifies that json_value() handles emojis correctly (unlike json_unquote)
DB::table('tasks')->insert([
['data' => '{"status":"Building started 🔨"}'],
['dat | $table->json('data');
});
}
protected function destroyDatabaseMigrations()
{
Schema::dropIfExists('tasks');
}
public function testJsonLikeWithEmoji()
{
// Test that LI | {
"filepath": "tests/Integration/Database/MariaDb/JsonLikeTest.php",
"language": "php",
"file_size": 2230,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Database\MySql;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class D... | {
Schema::drop('users');
}
public function testRenameColumnOnTableWithEnum()
{
Schema::table('users', function (Blueprint $table) {
$table->renameColumn('name', 'username');
});
$this->assertTrue(Sc | $table->integer('id');
$table->string('name');
$table->string('age');
$table->enum('color', ['red', 'blue']);
});
}
protected function destroyDatabaseMigrations()
| {
"filepath": "tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderAlterTableWithEnumTest.php",
"language": "php",
"file_size": 2006,
"cut_index": 537,
"middle_length": 229
} |
t\Model;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Schema;
class EloquentCastTest extends MySqlTestCase
{
protected $driver = 'mysql';
protected function afterRefreshingDatabase()
{
Schema::create('users', function ($table) {
$table->increments('id');
$t... |
protected function destroyDatabaseMigrations()
{
Schema::drop('users');
}
public function testItCastTimestampsCreatedByTheBuilderWhenTimeHasNotPassed()
{
Carbon::setTestNow(Carbon::now());
$createdAt = Carbon:: | ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->timestamp('created_at')->nullable();
$table->timestamp('updated_at')->nullable();
});
}
| {
"filepath": "tests/Integration/Database/MySql/EloquentCastTest.php",
"language": "php",
"file_size": 7922,
"cut_index": 716,
"middle_length": 229
} |
ase\MySql;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')... | icles');
}
protected function setUp(): void
{
parent::setUp();
DB::table('articles')->insert([
['title' => 'MySQL Tutorial', 'body' => 'DBMS stands for DataBase ...'],
['title' => 'How To Use MySQL Well | );
$table->string('title', 200);
$table->text('body');
$table->fulltext(['title', 'body']);
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop('art | {
"filepath": "tests/Integration/Database/MySql/FulltextTest.php",
"language": "php",
"file_size": 2538,
"cut_index": 563,
"middle_length": 229
} |
ase\Queue;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\DB;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Fra... | tUp();
if ($this->usesSqliteInMemoryDatabaseConnection()) {
$this->markTestSkipped('Test does not support using :memory: database connection');
}
}
#[DataProvider('timeoutJobs')]
public function testItCanHandleTime | l')]
#[WithMigration('laravel', 'queue')]
#[WithConfig('queue.default', 'database')]
class QueueTransactionTest extends DatabaseTestCase
{
use DatabaseMigrations;
protected function setUp(): void
{
parent::se | {
"filepath": "tests/Integration/Database/Queue/QueueTransactionTest.php",
"language": "php",
"file_size": 2131,
"cut_index": 563,
"middle_length": 229
} |
t;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresPhpExtension('pdo_mysql')]
#[RequiresOperatingSystem('Linux|Darwin')]
class JoinLateralTest... | nteger('user_id');
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop('posts');
Schema::drop('users');
}
protected function setUp(): void
{
parent::setUp();
$this->checkMyS | string('name');
});
Schema::create('posts', function (Blueprint $table) {
$table->id('id');
$table->string('title');
$table->integer('rating');
$table->unsignedBigI | {
"filepath": "tests/Integration/Database/MySql/JoinLateralTest.php",
"language": "php",
"file_size": 3737,
"cut_index": 614,
"middle_length": 229
} |
use Illuminate\Mail\Attachment;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Storage;
use Orchestra\Testbench\TestCase;
class AttachingFromStorageTest extends TestCase
{
public function testItCanAttachFromStorage()
{
Storage::disk('lo... | 'text/css',
],
], $mail->rawAttachments[0]);
Storage::disk('local')->delete('/dir/foo.png');
}
public function testItCanAttachFromStorageAndFallbackToStorageNameAndMime()
{
Storage::disk()->put('/dir/foo.p | ->withMime('text/css');
$attachment->attachTo($mail);
$this->assertSame([
'data' => 'expected body contents',
'name' => 'bar',
'options' => [
'mime' => | {
"filepath": "tests/Integration/Mail/AttachingFromStorageTest.php",
"language": "php",
"file_size": 2554,
"cut_index": 563,
"middle_length": 229
} |
te\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Markdown;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use PHPUnit\Framework\Attributes\DataProvider;
class MailableWithSecuredEncodingTest extends MailableTestCase
{
u... | ->create([
'name' => $given,
]);
$mailable = new class($user) extends Mailable
{
public $theme = 'taylor';
public function __construct(public User $user)
{
//
| dEncoding();
}
#[WithMigration]
#[DataProvider('markdownEncodedTemplateDataProvider')]
public function testItCanAssertMarkdownEncodedStringUsingTemplate($given, $expected)
{
$user = UserFactory::new() | {
"filepath": "tests/Integration/Mail/MailableWithSecuredEncodingTest.php",
"language": "php",
"file_size": 3457,
"cut_index": 614,
"middle_length": 229
} |
ase\Postgres;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSys... | destroyDatabaseMigrations()
{
Schema::drop('articles');
}
protected function setUp(): void
{
parent::setUp();
DB::table('articles')->insert([
['title' => 'PostgreSQL Tutorial', 'body' => 'DBMS stands fo | , function (Blueprint $table) {
$table->id('id');
$table->string('title', 200);
$table->text('body');
$table->fulltext(['title', 'body']);
});
}
protected function | {
"filepath": "tests/Integration/Database/Postgres/FulltextTest.php",
"language": "php",
"file_size": 2688,
"cut_index": 563,
"middle_length": 229
} |
rint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Str;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresPhpExtension('pdo_pgsql')]
#[RequiresOperatingSystem('Linux|Darwin')]
class JoinLateralT... | edBigInteger('user_id');
});
}
protected function destroyDatabaseMigrations()
{
Schema::drop('posts');
Schema::drop('users');
}
protected function setUp(): void
{
parent::setUp();
DB::table | able->string('name');
});
Schema::create('posts', function (Blueprint $table) {
$table->id('id');
$table->string('title');
$table->integer('rating');
$table->unsign | {
"filepath": "tests/Integration/Database/Postgres/JoinLateralTest.php",
"language": "php",
"file_size": 3249,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Database\SqlServer;
use RuntimeException;
class EscapeTest extends SqlServerTestCase
{
public function testEscapeInt()
{
$this->assertSame('42', $this->app['db']->escape(42));
$this->assertSame('-6', $this->app['db']->escape(-6));
}
public function testEscapeFloat... | this->app['db']->escape(null));
$this->assertSame('null', $this->app['db']->escape(null, true));
}
public function testEscapeBinary()
{
$this->assertSame('0xdead00beef', $this->app['db']->escape(hex2bin('dead00beef'), true));
| peBool()
{
$this->assertSame('1', $this->app['db']->escape(true));
$this->assertSame('0', $this->app['db']->escape(false));
}
public function testEscapeNull()
{
$this->assertSame('null', $ | {
"filepath": "tests/Integration/Database/SqlServer/EscapeTest.php",
"language": "php",
"file_size": 2008,
"cut_index": 537,
"middle_length": 229
} |
ent\Model;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Schema;
class EloquentCastTest extends MariaDbTestCase
{
protected $driver = 'mariadb';
protected function afterRefreshingDatabase()
{
Schema::create('users', function ($table) {
$table->increments('id');
... | }
protected function destroyDatabaseMigrations()
{
Schema::drop('users');
}
public function testItCastTimestampsCreatedByTheBuilderWhenTimeHasNotPassed()
{
Carbon::setTestNow(Carbon::now());
$createdAt = Ca | nction ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->timestamp('created_at')->nullable();
$table->timestamp('updated_at')->nullable();
});
| {
"filepath": "tests/Integration/Database/MariaDb/EloquentCastTest.php",
"language": "php",
"file_size": 7928,
"cut_index": 716,
"middle_length": 229
} |
port\Facades\Schema;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class DatabaseMySqlConnectionTest extends MySqlTestCase
{
... | });
}
}
protected function destroyDatabaseMigrations()
{
Schema::drop(self::TABLE);
}
#[DataProvider('floatComparisonsDataProvider')]
public function testJsonFloatComparison($value, $operator, $shouldMatch)
| Schema::hasTable(self::TABLE)) {
Schema::create(self::TABLE, function (Blueprint $table) {
$table->json(self::JSON_COL)->nullable();
$table->float(self::FLOAT_COL)->nullable();
| {
"filepath": "tests/Integration/Database/MySql/DatabaseMySqlConnectionTest.php",
"language": "php",
"file_size": 6694,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Integration\Database\MySql;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attributes\RequiresDatabase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
... | e('table_schema', $this->app['config']->get('database.connections.mysql.database'))
->where('table_name', 'users')
->select('table_comment as table_comment')
->first();
$this->assertSame('This is a comment', $ta | Schema::create('users', function (Blueprint $table) {
$table->id();
$table->comment('This is a comment');
});
$tableInfo = DB::table('information_schema.tables')
->wher | {
"filepath": "tests/Integration/Database/MySql/DatabaseMySqlSchemaBuilderTest.php",
"language": "php",
"file_size": 1538,
"cut_index": 537,
"middle_length": 229
} |
ase\Queue;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\DB;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\Attributes\WithMigration;
use PHPUnit\Framework\Attr... |
if ($this->usesSqliteInMemoryDatabaseConnection()) {
$this->markTestSkipped('Test does not support using :memory: database connection');
}
}
public function testItCanHandleTimeoutJob()
{
Bus::batch([new Fix | Migration('laravel', 'queue')]
#[WithConfig('queue.default', 'database')]
class BatchableTransactionTest extends DatabaseTestCase
{
use DatabaseMigrations;
protected function setUp(): void
{
parent::setUp();
| {
"filepath": "tests/Integration/Database/Queue/BatchableTransactionTest.php",
"language": "php",
"file_size": 2146,
"cut_index": 563,
"middle_length": 229
} |
iner;
use Illuminate\Container\Attributes\Config;
use Illuminate\Contracts\Container\SelfBuilding;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
use Orchestra\Testbench\TestCase;
class BuildableIntegrationTest extends TestCase
{
public function test_build_method_can_reso... | ssertEquals(500, $config->awayMessageDuration);
$this->assertSame('sad emo lyrics', $config->awayMessage);
$this->assertSame('api-key', $config->apiKey);
$this->assertSame('cosmastech', $config->userName);
config(['aim.away | e' => [
'duration' => 500,
'body' => 'sad emo lyrics',
],
],
]);
$config = $this->app->make(AolInstantMessengerConfig::class);
$this->a | {
"filepath": "tests/Integration/Container/BuildableIntegrationTest.php",
"language": "php",
"file_size": 2222,
"cut_index": 563,
"middle_length": 229
} |
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
abstract class MailableTestCase extends TestCase
{
/** {@inheritdoc} */
#[\Override]
protected function defineEnvir... | nvelope()
{
return new Envelope(
subject: 'My basic title',
);
}
public function content()
{
return new Content(
markdo | iven, $expected)
{
$mailable = new class($given) extends Mailable
{
public function __construct(public string $message)
{
//
}
public function e | {
"filepath": "tests/Integration/Mail/MailableTestCase.php",
"language": "php",
"file_size": 2187,
"cut_index": 563,
"middle_length": 229
} |
ase\SqlServer;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class DatabaseSqlServerSchemaBuilderTest extends SqlServerTestCase
{
protected function afterRefreshingDatabase()
{
Schema::create('users', function (Blueprint $table) {
... | B::statement('create view users_view AS select name, age from users');
$rows = Schema::getTables();
$this->assertGreaterThanOrEqual(2, count($rows));
$this->assertTrue(
collect($rows)->contains('name', 'migrations'),
| nction destroyDatabaseMigrations()
{
Schema::drop('users');
Schema::dropIfExists('computed');
DB::statement('drop view if exists users_view');
}
public function testGetTables()
{
D | {
"filepath": "tests/Integration/Database/SqlServer/DatabaseSqlServerSchemaBuilderTest.php",
"language": "php",
"file_size": 2841,
"cut_index": 563,
"middle_length": 229
} |
ase\MariaDb;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use RuntimeException;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class EscapeTest extends MariaDbTestCase
{
public function testEscapeInt()
{
... | cape(true));
$this->assertSame('0', $this->app['db']->escape(false));
}
public function testEscapeNull()
{
$this->assertSame('null', $this->app['db']->escape(null));
$this->assertSame('null', $this->app['db']->escape(nu | tSame('3.14159', $this->app['db']->escape(3.14159));
$this->assertSame('-3.14159', $this->app['db']->escape(-3.14159));
}
public function testEscapeBool()
{
$this->assertSame('1', $this->app['db']->es | {
"filepath": "tests/Integration/Database/MariaDb/EscapeTest.php",
"language": "php",
"file_size": 2198,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Container;
use Illuminate\Container\Attributes\Log;
use Illuminate\Support\Collection;
use Monolog\Handler\TestHandler;
use Monolog\LogRecord;
use Orchestra\Testbench\TestCase;
use Psr\Log\LoggerInterface;
class ContextualAttributesBindingIntegrationTest extends TestCase
{
public function tes... | AttributeTester::class);
$tester->log('hello');
$tester->logWithName('bye');
$records = new Collection($testHandler->getRecords());
$this->assertCount(2, $records);
$this->assertSame('hello', $records->firstWhere(f | 'handler' => TestHandler::class,
],
]]);
/** @var TestHandler $testHandler */
$testHandler = resolve('log')->driver()->getLogger()->getHandlers()[0];
$tester = resolve(Log | {
"filepath": "tests/Integration/Container/ContextualAttributesBindingIntegrationTest.php",
"language": "php",
"file_size": 1738,
"cut_index": 537,
"middle_length": 229
} |
ase\Postgres;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class DatabaseEloquentPostgresIntegrationTest extends PostgresTestCase
{
protected function afterRefreshingDatabase()
{
if (! Schema... |
{
Schema::drop('database_eloquent_postgres_integration_users');
}
public function testCreateOrFirst()
{
$user1 = DatabaseEloquentPostgresIntegrationUser::createOrFirst(['email' => 'taylorotwell@gmail.com']);
$this | d();
$table->string('name')->nullable();
$table->string('email')->unique();
$table->timestamps();
});
}
}
protected function destroyDatabaseMigrations() | {
"filepath": "tests/Integration/Database/Postgres/DatabaseEloquentPostgresIntegrationTest.php",
"language": "php",
"file_size": 2863,
"cut_index": 563,
"middle_length": 229
} |
ase\MySql;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
use RuntimeException;
#[RequiresOperatingSystem('Linux|Darwin')]
#[RequiresPhpExtension('pdo_mysql')]
class EscapeTest extends MySqlTestCase
{
public function testEscapeInt()
{
$... | (true));
$this->assertSame('0', $this->app['db']->escape(false));
}
public function testEscapeNull()
{
$this->assertSame('null', $this->app['db']->escape(null));
$this->assertSame('null', $this->app['db']->escape(null, | e('3.14159', $this->app['db']->escape(3.14159));
$this->assertSame('-3.14159', $this->app['db']->escape(-3.14159));
}
public function testEscapeBool()
{
$this->assertSame('1', $this->app['db']->escape | {
"filepath": "tests/Integration/Database/MySql/EscapeTest.php",
"language": "php",
"file_size": 2194,
"cut_index": 563,
"middle_length": 229
} |
ase\MariaDb;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class DatabaseEloquentMariaDbIntegrationTest extends MariaDbTestCase
{
protected function afterRefreshingDatabase()
{
if (! Schema::h... | {
Schema::drop('database_eloquent_mariadb_integration_users');
}
public function testCreateOrFirst()
{
$user1 = DatabaseEloquentMariaDbIntegrationUser::createOrFirst(['email' => 'taylorotwell@gmail.com']);
$this->asser | $table->string('name')->nullable();
$table->string('email')->unique();
$table->timestamps();
});
}
}
protected function destroyDatabaseMigrations()
| {
"filepath": "tests/Integration/Database/MariaDb/DatabaseEloquentMariaDbIntegrationTest.php",
"language": "php",
"file_size": 2856,
"cut_index": 563,
"middle_length": 229
} |
n Laravel\Prompts\select;
use function Laravel\Prompts\suggest;
use function Laravel\Prompts\text;
use function Laravel\Prompts\textarea;
class PromptsAssertionTest extends TestCase
{
public function testAssertionForTextPrompt(): void
{
$this->app[Kernel::class]->registerCommand(
new class ... | Output('Jane');
}
public function testAssertionForPausePrompt(): void
{
$this->app[Kernel::class]->registerCommand(
new class($this) extends Command
{
protected $signature = 'test:pause';
| e?', 'John');
$this->line($name);
}
}
);
$this
->artisan('test:text')
->expectsQuestion('What is your name?', 'Jane')
->expects | {
"filepath": "tests/Integration/Console/PromptsAssertionTest.php",
"language": "php",
"file_size": 12730,
"cut_index": 921,
"middle_length": 229
} |
ystem;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
#[WithConfig('filesystems.disks.local.serve', true)]
class ServeFileTest extends TestCase
{
prote... | rve-file-test.txt',
'serve-file-test.txt?pad=x',
'nested/folder/serve-file-test.txt',
]);
});
parent::setUp();
}
public function testItCanServeAnExistingFile()
{
$url = Stora | .txt?pad=x', 'Hello Question');
Storage::put('nested/folder/serve-file-test.txt', 'Hello Nested');
});
$this->beforeApplicationDestroyed(function () {
Storage::delete([
'se | {
"filepath": "tests/Integration/Filesystem/ServeFileTest.php",
"language": "php",
"file_size": 2806,
"cut_index": 563,
"middle_length": 229
} |
luminate\Support\Facades\Storage;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
use Symfony\Component\Process\Process;
#[RequiresOperatingSystem('Linux|Darwin')]
class StorageTest extends TestCase
{
protected $stubFile;
protected function setUp(): void
{
... | etUp();
}
public function testItCanDeleteViaStorage()
{
Storage::disk('public')->assertExists('StardewTaylor.png');
$this->assertTrue(Storage::disk('public')->exists('StardewTaylor.png'));
Storage::disk('public')->dele | ->stubFile = $file;
});
$this->beforeApplicationDestroyed(function () {
if (File::exists($this->stubFile)) {
File::delete($this->stubFile);
}
});
parent::s | {
"filepath": "tests/Integration/Filesystem/StorageTest.php",
"language": "php",
"file_size": 3431,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Session;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Str;
use Orchestra\Testbench\TestCase;
class CookieSessionHandlerTest extends TestCase
{
public function testCookieSessionDriverCookiesCanExpireOnClose()
{
Route::get('/', fn () => '')->middleware('web');
... | /', fn () => '')->middleware('web');
$unsecureResponse = $this->get('/');
$unsecureSessionIdCookie = $unsecureResponse->getCookie('laravel_session');
$unsecureSessionValueCookie = $unsecureResponse->getCookie($unsecureSessionIdCook | this->assertEquals(0, $sessionIdCookie->getExpiresTime());
$this->assertEquals(0, $sessionValueCookie->getExpiresTime());
}
public function testCookieSessionInheritsRequestSecureState()
{
Route::get(' | {
"filepath": "tests/Integration/Session/CookieSessionHandlerTest.php",
"language": "php",
"file_size": 1790,
"cut_index": 537,
"middle_length": 229
} |
use Illuminate\Support\Carbon;
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
use Orchestra\Testbench\Attributes\WithMigration;
#[WithMigration('session')]
class DatabaseSessionHandlerTest extends DatabaseTestCase
{
public function test_basic_read_write_functionality()
{
$connection = $th... | this->assertTrue($handler->write('valid_session_id_2425', json_encode(['foo' => 'bar'])));
$this->assertEquals(['foo' => 'bar'], json_decode($handler->read('valid_session_id_2425'), true));
$this->assertEquals(1, $connection->table('session | $this->assertSame('', $handler->read('invalid_session_id'));
// open and close:
$this->assertTrue($handler->open('', ''));
$this->assertTrue($handler->close());
// write and read:
$ | {
"filepath": "tests/Integration/Session/DatabaseSessionHandlerTest.php",
"language": "php",
"file_size": 4653,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Session;
use Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Http\Response;
use Illuminate\Session\NullSessionHandler;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use Mockery as... | throw new TokenMismatchException;
})->middleware('web');
$this->get('/');
$this->assertTrue($handler->written);
}
protected function defineEnvironment($app)
{
$app->instance(
ExceptionHandler::cla | FakeNullSessionHandler;
$this->assertFalse($handler->written);
Session::extend('fake-null', function () use ($handler) {
return $handler;
});
Route::get('/', function () {
| {
"filepath": "tests/Integration/Session/SessionPersistenceTest.php",
"language": "php",
"file_size": 1580,
"cut_index": 537,
"middle_length": 229
} |
parent::setUp();
Artisan::command('survey', function () {
$name = $this->ask('What is your name?');
$language = $this->choice('Which language do you prefer?', [
'PHP',
'Ruby',
'Python',
]);
$this->line("Your name... | anguage do you prefer?', [
'PHP',
'PHP',
'PHP',
]);
$this->table(['Name', 'Email'], [
['Taylor Otwell', 'taylor@laravel.com'],
]);
$this->conf | $this->line($this->ask('Huh?'));
});
Artisan::command('interactions', function () {
/** @var Command $this */
$this->ask('What is your name?');
$this->choice('Which l | {
"filepath": "tests/Integration/Testing/ArtisanCommandTest.php",
"language": "php",
"file_size": 11166,
"cut_index": 921,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Testing;
use Illuminate\Support\Facades\ParallelTesting;
use Illuminate\Testing\ParallelTestingServiceProvider;
use Orchestra\Testbench\TestCase;
class TestWithoutDatabaseParallelTest extends TestCase
{
protected function getPackageProviders($app)
{
return [ParallelTe... | s` option
$_SERVER['LARAVEL_PARALLEL_TESTING'] = 1;
$_SERVER['LARAVEL_PARALLEL_TESTING_WITHOUT_DATABASES'] = 1;
$_SERVER['TEST_TOKEN'] = '1';
$this->beforeApplicationDestroyed(function () {
unset(
| on defineEnvironment($app)
{
// Given an application that does not use database connections at all
$app['config']->set('database.default', null);
// When we run parallel testing with `without-database | {
"filepath": "tests/Integration/Testing/TestWithoutDatabaseParallelTest.php",
"language": "php",
"file_size": 1443,
"cut_index": 524,
"middle_length": 229
} |
te\Tests\Integration\View;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use InvalidArgumentException;
use Orchestra\Testbench\TestCase;
class BladeAnonymousComponentTest extends TestCase
{
public function test_anonymous_components_with_custom_paths_can_be_rendered()
{
Bla... | c function test_anonymous_components_with_custom_paths_cant_be_rendered_as_normal_views()
{
$this->expectException(InvalidArgumentException::class);
Blade::anonymousComponentPath(__DIR__.'/anonymous-components-1', 'layouts');
B | );
$this->assertTrue(str_contains($view, 'Panel content.'));
$this->assertTrue(str_contains($view, 'class="app-layout"'));
$this->assertTrue(str_contains($view, 'class="danger-button"'));
}
publi | {
"filepath": "tests/Integration/View/BladeAnonymousComponentTest.php",
"language": "php",
"file_size": 1703,
"cut_index": 537,
"middle_length": 229
} |
ystem\join_paths;
use function Orchestra\Testbench\artisan;
use function Orchestra\Testbench\phpunit_version_compare;
class BladeTest extends TestCase
{
/** {@inheritdoc} */
#[\Override]
protected function tearDown(): void
{
artisan($this, 'view:clear');
parent::tearDown();
}
... | }
#[RunInSeparateProcess]
public function test_rendering_blade_long_maxpathlen_string_with_exact_length()
{
// The PHP_MAXPATHLEN restriction is only active, if
// open_basedir is set and active. Otherwise, the check
| ng_blade_long_maxpathlen_string()
{
$longString = str_repeat('a', PHP_MAXPATHLEN);
$result = Blade::render($longString.'{{ $name }}', ['name' => 'a']);
$this->assertSame($longString.'a', $result);
| {
"filepath": "tests/Integration/View/BladeTest.php",
"language": "php",
"file_size": 9480,
"cut_index": 921,
"middle_length": 229
} |
nate\Tests\Integration\View;
use Exception;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\View;
use Orchestra\Testbench\TestCase;
class RenderableViewExceptionTest extends TestCase
{
public function testRenderMethodOfExceptionThrownInViewGetsHandled()
{
... | vironment($app)
{
$app['config']->set('view.paths', [__DIR__.'/templates']);
}
}
class RenderableException extends Exception
{
public function render($request)
{
return new Response('This is a renderable exception.');
} | exception.');
}
protected function defineEn | {
"filepath": "tests/Integration/View/RenderableViewExceptionTest.php",
"language": "php",
"file_size": 846,
"cut_index": 535,
"middle_length": 52
} |
rovider;
class TranslatorTest extends TestCase
{
/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function defineEnvironment($app)
{
$app['translator']->addNamespace('tests', __DIR__.'/lang');
$app['tra... | on()
{
$this->assertTrue($this->app['translator']->has('1 Day'));
$this->assertTrue($this->app['translator']->hasForLocale('1 Day'));
$this->assertTrue($this->app['translator']->hasForLocale('30 Days'));
$this->app->set | app['translator']->get('30 Days'));
$this->app->setLocale('fr');
$this->assertSame('30 jours', $this->app['translator']->get('30 Days'));
}
public function testItCanCheckLanguageExistsHasFromLocaleForJs | {
"filepath": "tests/Integration/Translation/TranslatorTest.php",
"language": "php",
"file_size": 5401,
"cut_index": 716,
"middle_length": 229
} |
te\Queue\Events\JobFailed;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Event;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class CallQueuedHandlerTest extends TestCase
{
public function testJobCanBeDispatched()
{
CallQueuedHandlerTestJob::$handled = false;
$i... | tance->call($job, [
'command' => serialize(new CallQueuedHandlerTestJob),
]);
$this->assertTrue(CallQueuedHandlerTestJob::$handled);
}
public function testJobCanBeDispatchedThroughMiddleware()
{
CallQueuedH | ceive('isDeleted')->andReturn(false);
$job->shouldReceive('isReleased')->andReturn(false);
$job->shouldReceive('isDeletedOrReleased')->andReturn(false);
$job->shouldReceive('delete')->once();
$ins | {
"filepath": "tests/Integration/Queue/CallQueuedHandlerTest.php",
"language": "php",
"file_size": 9270,
"cut_index": 921,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Queue;
use Illuminate\Contracts\Bus\QueueingDispatcher;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Testing\TestCase;
use Illuminate\Queue\Queue;
use Illuminate\Support\ServiceProvider;
use Orchestra\Testbench\Concerns\CreatesApplication;
use PHPUnit\Framewor... | data_provider(string $websites)
{
$dispatcher = $this->app->make(QueueingDispatcher::class);
$dispatcher->dispatchToQueue(new MyJob);
}
}
class QueueServiceProvider extends ServiceProvider
{
public function register()
{
| :class];
}
public static function websites()
{
yield ['laravel.com'];
yield ['blog.laravel.com'];
}
#[DataProvider('websites')]
public function test_custom_payload_gets_cleared_for_each_ | {
"filepath": "tests/Integration/Queue/CustomPayloadTest.php",
"language": "php",
"file_size": 1481,
"cut_index": 524,
"middle_length": 229
} |
Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache as CacheFacade;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Queue;
use LogicException;
use Orchestra\Testbench\Attributes\WithMigration;
#[WithMigration]
#[WithMigration('cache')]
#[WithMi... | h(new DebouncedTestJob('entity-1'));
$this->travelTo(Carbon::now()->addSeconds(31));
$this->runQueueWorkerCommand(['--once' => true]);
$this->assertTrue(DebouncedTestJob::$handled);
}
public function testSupersededDebounce | he.default', 'database');
}
public function testDebouncedJobDispatchesAndExecutes()
{
$this->markTestSkippedWhenUsingQueueDrivers(['beanstalkd']);
DebouncedTestJob::$handled = false;
dispatc | {
"filepath": "tests/Integration/Queue/DebouncedJobTest.php",
"language": "php",
"file_size": 14079,
"cut_index": 921,
"middle_length": 229
} |
;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Schema;
use Orchestra\Testbench\Attr... | elete_model_test_models', function (Blueprint $table) {
$table->id();
$table->string('name');
});
}
protected function destroyDatabaseMigrations()
{
Schema::dropIfExists('delete_model_test_models');
| defineEnvironment($app);
$app['config']->set('queue.default', 'database');
$this->driver = 'database';
}
protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
{
Schema::create('d | {
"filepath": "tests/Integration/Queue/DeleteModelWhenMissingTest.php",
"language": "php",
"file_size": 2276,
"cut_index": 563,
"middle_length": 229
} |
;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Notifications\Notifiable;
use Illuminate\Notifications\Notification;
use Illuminate\Queue\Attributes\DeleteWhenMissingModels;
use Illuminate\Queue... | ult', 'database');
$this->driver = 'database';
}
protected function defineDatabaseMigrationsAfterDatabaseRefreshed()
{
Schema::create('delete_notification_test_models', function (Blueprint $table) {
$table->id();
|
#[WithMigration('queue')]
class DeleteNotificationWhenMissingModelTest extends QueueTestCase
{
protected function defineEnvironment($app)
{
parent::defineEnvironment($app);
$app['config']->set('queue.defa | {
"filepath": "tests/Integration/Queue/DeleteNotificationWhenMissingModelTest.php",
"language": "php",
"file_size": 2617,
"cut_index": 563,
"middle_length": 229
} |
Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Carbon;
use Illuminate\Support\Env;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Str;
use Orchestra\Testbench\Attributes\RequiresEnv;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\R... | app(DynamoBatchRepository::class)->deleteAwsDynamoTable();
});
parent::setUp();
}
protected function defineEnvironment($app)
{
$app['config']->set('queue.batching', [
'driver' => 'dynamodb',
| $this->afterApplicationCreated(function () {
BatchRunRecorder::reset();
app(DynamoBatchRepository::class)->createAwsDynamoTable();
});
$this->beforeApplicationDestroyed(function () {
| {
"filepath": "tests/Integration/Queue/DynamoBatchTest.php",
"language": "php",
"file_size": 5790,
"cut_index": 716,
"middle_length": 229
} |
'queue.connections.sync1' => ['driver' => 'sync'],
'queue.connections.sync2' => ['driver' => 'sync'],
]);
}
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
JobRunRecorder::reset();
});
$this->beforeApplicat... | Job,
]);
$this->runQueueWorkerCommand(['--stop-when-empty' => true]);
$this->assertTrue(JobChainingTestFirstJob::$ran);
$this->assertTrue(JobChainingTestSecondJob::$ran);
}
public function testJobsCanBeChainedOnSu | static::$catchCallbackRan = false;
});
parent::setUp();
}
public function testJobsCanBeChainedOnSuccess()
{
JobChainingTestFirstJob::dispatch()->chain([
new JobChainingTestSecond | {
"filepath": "tests/Integration/Queue/JobChainingTest.php",
"language": "php",
"file_size": 30273,
"cut_index": 1331,
"middle_length": 229
} |
\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Attributes\Queue as QueueAttribute;
use Illuminate\Queue\Events\JobQueued;
use Illuminate\Queue\Events\JobQueueing;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Config;
use Orche... | :dispatch('test')->replaceValue('new-test');
$this->runQueueWorkerCommand(['--stop-when-empty' => true]);
$this->assertTrue(Job::$ran);
$this->assertSame('new-test', Job::$value);
}
public function testDispatchesCondition | beforeApplicationDestroyed(function () {
Job::$ran = false;
Job::$value = null;
});
parent::setUp();
}
public function testJobCanUseCustomMethodsAfterDispatch()
{
Job: | {
"filepath": "tests/Integration/Queue/JobDispatchingTest.php",
"language": "php",
"file_size": 8776,
"cut_index": 716,
"middle_length": 229
} |
;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Bus;
use I... | );
$app['config']->set('app.key', Str::random(32));
$app['config']->set('queue.default', 'database');
}
protected function tearDown(): void
{
JobEncryptionTestEncryptedJob::$ran = false;
JobEncryptionTestNonEnc | ithMigration;
#[WithMigration]
#[WithMigration('queue')]
class JobEncryptionTest extends DatabaseTestCase
{
use DatabaseMigrations;
protected function defineEnvironment($app)
{
parent::defineEnvironment($app | {
"filepath": "tests/Integration/Queue/JobEncryptionTest.php",
"language": "php",
"file_size": 2760,
"cut_index": 563,
"middle_length": 229
} |
{
$app['config']->set('database.connections.custom', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
}
protected function setUp(): void
{
parent::setUp();
Model::preventLazyLoading(false);
Schema::create('u... | hema::create('lines', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('order_id');
$table->unsignedInteger('product_id');
});
Schema::create('products', function (Blueprin | eprint $table) {
$table->increments('id');
$table->string('email');
});
Schema::create('orders', function (Blueprint $table) {
$table->increments('id');
});
Sc | {
"filepath": "tests/Integration/Queue/ModelSerializationTest.php",
"language": "php",
"file_size": 27750,
"cut_index": 1331,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Queue;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\PreparesForDispatch;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Queue;
use Orchestra\Testbench\TestCase;
class PreparesForDispatchTest exten... | :dispatch();
$this->assertTrue(PreparesForDispatchVoidJob::$ran);
Queue::assertPushed(PreparesForDispatchVoidJob::class);
}
}
class PreparesForDispatchFalseJob implements PreparesForDispatch, ShouldQueue
{
use Dispatchable, Queuea | shed(PreparesForDispatchFalseJob::class);
}
public function test_dispatches_when_prepare_returns_void()
{
Queue::fake();
PreparesForDispatchVoidJob::$ran = false;
PreparesForDispatchVoidJob: | {
"filepath": "tests/Integration/Queue/PreparesForDispatchTest.php",
"language": "php",
"file_size": 1436,
"cut_index": 524,
"middle_length": 229
} |
tracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Database\DatabaseTransactionsManager;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Bus;
use Mockery as m;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
use Throwable;
... | n('db.transactions', function () {
$transactionManager = m::mock(DatabaseTransactionsManager::class);
$transactionManager->shouldReceive('addCallback')->once()->andReturn(null);
$transactionManager->shouldNotReceive('add | QueueConnectionTestJob::$ran = false;
QueueConnectionTestUniqueJob::$ran = false;
parent::tearDown();
}
public function testJobWontGetDispatchedInsideATransaction()
{
$this->app->singleto | {
"filepath": "tests/Integration/Queue/QueueConnectionTest.php",
"language": "php",
"file_size": 4900,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Queue;
use Illuminate\Bus\Queueable;
use Illuminate\Support\Facades\Queue;
use Illuminate\Support\Testing\Fakes\QueueFake;
use Orchestra\Testbench\TestCase;
class QueueFakeTest extends TestCase
{
protected function defineEnvironment($app)
{
$app['config']->set('queue.default', 'sy... | Queue::assertPushed(OtherTestJob::class);
}, [TestJob::class]);
}
public function testFakeExcept()
{
$fake = Queue::fakeExcept([TestJob::class]);
$this->assertInstanceOf(QueueFake::class, $fake);
}
p | }
public function testFakeExceptFor()
{
Queue::fakeExceptFor(function () {
Queue::push(new TestJob);
Queue::push(new OtherTestJob);
Queue::assertNotPushed(TestJob::class);
| {
"filepath": "tests/Integration/Queue/QueueFakeTest.php",
"language": "php",
"file_size": 1623,
"cut_index": 537,
"middle_length": 229
} |
;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Orchestra\Testbench\TestCase;
abstract class QueueTestCase extends TestCase
{
use DatabaseMigrations, InteractsWithRedis;
/**
* The current database driver.
*
* @var strin... | if ($this->getQueueDriver() === 'redis') {
$this->setUpRedis();
}
});
$this->beforeApplicationDestroyed(function () {
if ($this->getQueueDriver() === 'redis') {
$this->tearDownRedi | defineEnvironment($app)
{
$this->driver = $app['config']->get('queue.default', 'sync');
}
#[\Override]
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
| {
"filepath": "tests/Integration/Queue/QueueTestCase.php",
"language": "php",
"file_size": 2551,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Queue;
use Event;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Events\CallQueuedListener;
use Orchestra\Testbench\TestCase;
use Queue;
class QueuedListenersTest extends TestCase
{
public function testListenersCanBeQueuedOptionally()
{
Queue::fake();
Event::l... | ass;
});
$this->assertCount(1, Queue::listenersPushed(QueuedListenersTestListenerShouldQueue::class));
$this->assertCount(
0,
Queue::listenersPushed(
QueuedListenersTestListenerShouldQueue::c |
Event::dispatch(
new QueuedListenersTestEvent
);
Queue::assertPushed(CallQueuedListener::class, function ($job) {
return $job->class == QueuedListenersTestListenerShouldQueue::cl | {
"filepath": "tests/Integration/Queue/QueuedListenersTest.php",
"language": "php",
"file_size": 2019,
"cut_index": 537,
"middle_length": 229
} |
edHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\RateLimited;
use Illuminate\Support\Carbon;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class RateLimitedTest extends TestCase
{
public function testUnlimitedJobsAreExecuted()
{
$rateLimiter = $this->app->make(R... | r(BackedEnumNamedRateLimited::FOO, function ($job) {
return Limit::none();
});
$this->assertJobRanSuccessfully(RateLimitedTestJobUsingBackedEnum::class);
$this->assertJobRanSuccessfully(RateLimitedTestJobUsingBackedEnum | $this->assertJobRanSuccessfully(RateLimitedTestJob::class);
}
public function testUnlimitedJobsAreExecutedUsingBackedEnum()
{
$rateLimiter = $this->app->make(RateLimiter::class);
$rateLimiter->fo | {
"filepath": "tests/Integration/Queue/RateLimitedTest.php",
"language": "php",
"file_size": 12730,
"cut_index": 921,
"middle_length": 229
} |
\Contracts\Queue\Job;
use Illuminate\Contracts\Redis\Connection;
use Illuminate\Foundation\Testing\Concerns\InteractsWithRedis;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\RateLimitedWithRedis;
use Illuminate\Support\Str;
use Mockery as m;
use Orchest... | $this->tearDownRedis();
parent::tearDown();
}
public function testUnlimitedJobsAreExecuted()
{
$rateLimiter = $this->app->make(RateLimiter::class);
$testJob = new RedisRateLimitedTestJob;
$rateLimiter | lass RateLimitedWithRedisTest extends TestCase
{
use InteractsWithRedis;
protected function setUp(): void
{
parent::setUp();
$this->setUpRedis();
}
protected function tearDown(): void
{
| {
"filepath": "tests/Integration/Queue/RateLimitedWithRedisTest.php",
"language": "php",
"file_size": 6492,
"cut_index": 716,
"middle_length": 229
} |
$queue;
/**
* @var \Mockery\MockInterface|\Mockery\LegacyMockInterface
*/
private $container;
/** {@inheritdoc} */
#[\Override]
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
$this->setUpRedis();
});
$this->before... | {
$this->queue = new RedisQueue($this->redis[$driver], $default, $connection, $retryAfter, $blockFor);
$this->container = m::spy(Container::class);
$this->queue->setContainer($this->container);
}
private function getQueue | * @param string|null $connection
* @param int $retryAfter
* @param int|null $blockFor
*/
private function setQueue($driver, $default = 'default', $connection = null, $retryAfter = 60, $blockFor = null)
| {
"filepath": "tests/Integration/Queue/RedisQueueTest.php",
"language": "php",
"file_size": 28810,
"cut_index": 1331,
"middle_length": 229
} |
e;
use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
#[WithMigration]
class SerializableClosureV1QueueTest extends TestCase
{
use RefreshDatabase;
/** {@inheritDoc} */
#[\Override]
prote... | c} */
protected function afterRefreshingDatabase()
{
UserFactory::new()->create([
'id' => 100,
'name' => 'Taylor Otwell',
'email' => 'taylor@laravel.com',
'password' => '$2y$10$92IXUNpkjO0rOQ5 | ake('config'), function ($config) {
$config->set([
'app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF',
'queue.default' => 'database',
]);
});
}
/** {@inheritDo | {
"filepath": "tests/Integration/Queue/SerializableClosureV1QueueTest.php",
"language": "php",
"file_size": 4270,
"cut_index": 614,
"middle_length": 229
} |
;
use Illuminate\Bus\Batchable;
use Illuminate\Bus\Dispatcher;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\SkipIfBatchCancelled;
use Mockery as m;
use Orchestra\Testbench\TestCase;
cl... | s->assertJobWasSkipped($afterCancelled);
}
protected function assertJobRanSuccessfully($class)
{
$this->assertJobHandled($class, true);
}
protected function assertJobWasSkipped($class)
{
$this->assertJobHandled($cl | atch();
[$afterCancelled] = (new SkipCancelledBatchableTestJob())->withFakeBatch(
cancelledAt: \Carbon\CarbonImmutable::now()
);
$this->assertJobRanSuccessfully($beforeCancelled);
$thi | {
"filepath": "tests/Integration/Queue/SkipIfBatchCancelledTest.php",
"language": "php",
"file_size": 2101,
"cut_index": 563,
"middle_length": 229
} |
s\Queueable;
use Illuminate\Contracts\Queue\Job;
use Illuminate\Queue\CallQueuedHandler;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\Middleware\Skip;
use Laravel\SerializableClosure\SerializableClosure;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class SkipMiddlewareTest extends TestCase
{
... |
{
$job = new SkipTestJob(skip: false);
$this->assertJobRanSuccessfully($job);
}
public function testJobIsNotSkippedWhenConditionIsFalseUsingClosure()
{
$job = new SkipTestJob(skip: new SerializableClosure(fn () => | WhenConditionIsTrueUsingClosure()
{
$job = new SkipTestJob(skip: new SerializableClosure(fn () => true));
$this->assertJobWasSkipped($job);
}
public function testJobIsNotSkippedWhenConditionIsFalse() | {
"filepath": "tests/Integration/Queue/SkipMiddlewareTest.php",
"language": "php",
"file_size": 3603,
"cut_index": 614,
"middle_length": 229
} |
le\Scheduling\CallbackEvent;
use Illuminate\Console\Scheduling\EventMutex;
use Illuminate\Support\Stringable;
use Mockery as m;
use Orchestra\Testbench\TestCase;
class CallbackEventTest extends TestCase
{
public function testDefaultResultIsSuccess()
{
$success = null;
$event = (new CallbackEve... | ock(EventMutex::class), function () {
return false;
}))->onSuccess(function () use (&$success) {
$success = true;
})->onFailure(function () use (&$success) {
$success = false;
});
$event- | success = false;
});
$event->run($this->app);
$this->assertTrue($success);
}
public function testFalseResponseIsFailure()
{
$success = null;
$event = (new CallbackEvent(m::m | {
"filepath": "tests/Integration/Console/Scheduling/CallbackEventTest.php",
"language": "php",
"file_size": 3294,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Tests\Integration\Console\Scheduling;
use GuzzleHttp\Client as HttpClient;
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Illuminate\Console\Scheduling\Event;
use Illuminate\Console\Scheduling\... | $httpMock = new HttpClient([
'handler' => HandlerStack::create(
new MockHandler([new Psr7Response(500)])
),
]);
$this->swap(HttpClient::class, $httpMock);
$event = new Event(m::mock(Eve | Case
{
public function testPingRescuesTransferExceptions()
{
$this->spy(ExceptionHandler::class)
->shouldReceive('report')
->once()
->with(m::type(ServerException::class));
| {
"filepath": "tests/Integration/Console/Scheduling/EventPingTest.php",
"language": "php",
"file_size": 1421,
"cut_index": 524,
"middle_length": 229
} |
le\Scheduling;
use Illuminate\Console\Application;
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Console\Scheduling\ScheduleTestCommand;
use Illuminate\Support\Carbon;
use Orchestra\Testbench\TestCase;
class ScheduleTestCommandTest extends TestCase
{
public $schedule;
... |
public function testRunNoMatchingCommand()
{
$this->schedule->command(BarCommandStub::class);
$this->artisan(ScheduleTestCommand::class, ['--name' => 'missing:command'])
->assertSuccessful()
->expectsOutpu | }
public function testRunNoDefinedCommands()
{
$this->artisan(ScheduleTestCommand::class)
->assertSuccessful()
->expectsOutputToContain('No scheduled commands have been defined.');
} | {
"filepath": "tests/Integration/Console/Scheduling/ScheduleTestCommandTest.php",
"language": "php",
"file_size": 2907,
"cut_index": 563,
"middle_length": 229
} |
minate\Foundation\Console\EventListCommand;
use Illuminate\Support\Facades\Artisan;
use Orchestra\Testbench\TestCase;
class EventListCommandTest extends TestCase
{
public $dispatcher;
protected function setUp(): void
{
parent::setUp();
$this->dispatcher = new Dispatcher();
EventLi... | );
$this->dispatcher->listen(ExampleEvent::class, ExampleListener::class);
$this->dispatcher->listen(ExampleEvent::class, ExampleQueueListener::class);
$this->dispatcher->listen(ExampleBroadcastEvent::class, ExampleBroadcastListener | l()
->expectsOutputToContain("Your application doesn't have any events matching the given criteria.");
}
public function testDisplayEvents()
{
$this->dispatcher->subscribe(ExampleSubscriber::class | {
"filepath": "tests/Integration/Console/Events/EventListCommandTest.php",
"language": "php",
"file_size": 5792,
"cut_index": 716,
"middle_length": 229
} |
inate\Process\Factory as ProcessFactory;
use Illuminate\Support\Facades\Concurrency;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
#[RequiresOperatingSystem('Linux|Darwin')]
class ConcurrencyTest extends TestCase
{
protect... | rrency')
->assertOk();
[$first, $second] = $response->original;
$this->assertEquals(2, $first);
$this->assertEquals(4, $second);
}
public function testRunHandlerProcessErrorCode()
{
$this->expectEx | tion () {
return Concurrency::run([
fn () => 1 + 1,
fn () => 2 + 2,
]);
});
PHP);
parent::setUp();
}
public function testWorkCanBeDistributed()
{
$response = $this->get('concu | {
"filepath": "tests/Integration/Concurrency/ConcurrencyTest.php",
"language": "php",
"file_size": 5937,
"cut_index": 716,
"middle_length": 229
} |
nt\Collection as EloquentCollection;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\LazilyRefreshDatabase;
use Illuminate\Support\Facades\Context;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCase;
use RuntimeExcepti... | ber', 55);
$dehydrated = Context::dehydrate();
$this->assertSame([
'data' => [
'model' => 'O:45:"Illuminate\Contracts\Database\ModelIdentifier":5:{s:5:"class";s:31:"Illuminate\Foundation\Auth\User";s:2:"id";i:1; | $this->assertSame([], Context::all());
}
public function test_it_handles_eloquent()
{
$user = UserFactory::new()->create(['name' => 'Tim']);
Context::add('model', $user);
Context::add('num | {
"filepath": "tests/Integration/Log/ContextIntegrationTest.php",
"language": "php",
"file_size": 4733,
"cut_index": 614,
"middle_length": 229
} |
test 2'));
Exceptions::assertReported(RuntimeException::class);
Exceptions::assertReported(fn (RuntimeException $e) => $e->getMessage() === 'test 1');
Exceptions::assertReported(fn (RuntimeException $e) => $e->getMessage() === 'test 2');
Exceptions::assertReportedCount(2);
$rep... | portedCountMayFail()
{
Exceptions::fake();
Exceptions::report(new RuntimeException('test 1'));
report(new RuntimeException('test 2'));
$this->expectException(ExpectationFailedException::class);
$this->expectExc | {
Exceptions::fake();
Exceptions::report(new RuntimeException('test 1'));
report(new RuntimeException('test 2'));
Exceptions::assertReportedCount(2);
}
public function testFakeAssertRe | {
"filepath": "tests/Integration/Support/ExceptionsFacadeTest.php",
"language": "php",
"file_size": 19591,
"cut_index": 1331,
"middle_length": 229
} |
rt;
use Illuminate\Tests\Integration\Support\Fixtures\NullableManager;
use InvalidArgumentException;
use Orchestra\Testbench\TestCase;
use stdClass;
class ManagerTest extends TestCase
{
public function testDefaultDriverCannotBeNull()
{
$this->expectException(InvalidArgumentException::class);
... | driver = new stdClass;
$manager->extend(__CLASS__, static fn () => $driver);
$this->assertSame($driver, $manager->driver(__CLASS__));
}
public function testInvokableObjectDriverClosure()
{
$manager = new NullableManage | ->extend(__CLASS__, fn () => $this);
$this->assertSame($manager, $manager->driver(__CLASS__));
}
public function testCustomDriverStaticClosure()
{
$manager = new NullableManager($this->app);
$ | {
"filepath": "tests/Integration/Support/ManagerTest.php",
"language": "php",
"file_size": 2875,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Support;
use Illuminate\Tests\Integration\Support\Fixtures\MultipleInstanceManager;
use Orchestra\Testbench\TestCase;
use RuntimeException;
class MultipleInstanceManagerTest extends TestCase
{
public function test_configurable_instances_can_be_resolved()
{
$manager = new MultipleI... | config['mysql_database-connection-option']);
$duplicateFooInstance = $manager->instance('foo');
$duplicateBarInstance = $manager->instance('bar');
$duplicateMysqlInstance = $manager->instance('mysql_database-connection');
$ | instance('bar');
$this->assertSame('option-value', $barInstance->config['bar-option']);
$mysqlInstance = $manager->instance('mysql_database-connection');
$this->assertSame('option-value', $mysqlInstance-> | {
"filepath": "tests/Integration/Support/MultipleInstanceManagerTest.php",
"language": "php",
"file_size": 1854,
"cut_index": 537,
"middle_length": 229
} |
rt\Fixtures;
use Illuminate\Support\MultipleInstanceManager as BaseMultipleInstanceManager;
class MultipleInstanceManager extends BaseMultipleInstanceManager
{
protected $defaultInstance = 'foo';
protected function createFooDriver(array $config)
{
return new class($config)
{
p... | protected function createMysqlDatabaseConnectionDriver(array $config)
{
return new class($config)
{
public function __construct(public $config)
{
}
};
}
/**
* Get the default | rray $config)
{
return new class($config)
{
public $config;
public function __construct($config)
{
$this->config = $config;
}
};
}
| {
"filepath": "tests/Integration/Support/Fixtures/MultipleInstanceManager.php",
"language": "php",
"file_size": 2322,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Integration\Filesystem;
use Illuminate\Filesystem\FilesystemServiceProvider;
use InvalidArgumentException;
use Orchestra\Testbench\TestCase;
class FilesystemServiceProviderTest extends TestCase
{
public function test_it_throws_when_served_disks_have_conflicting_uris(): void
{
$this->expectExc... | 'driver' => 'local',
'root' => storage_path('other'),
'serve' => true,
],
]]);
(new FilesystemServiceProvider($this->app))->boot();
}
public function test_served_disks_with_unique | config(['filesystems.disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
'serve' => true,
],
'other' => [
| {
"filepath": "tests/Integration/Filesystem/FilesystemServiceProviderTest.php",
"language": "php",
"file_size": 1656,
"cut_index": 537,
"middle_length": 229
} |
PHPUnit\Framework\Attributes\DataProvider;
class CommandSchedulingTest extends TestCase
{
/**
* Each run of this test is assigned a random ID to ensure that separate runs
* do not interfere with each other.
*
* @var string
*/
protected $id;
/**
* The path to the file that exe... | rotected function setUp(): void
{
parent::setUp();
$this->fs = new Filesystem;
$this->id = Str::random();
$this->logfile = storage_path("logs/command_scheduling_test_{$this->id}.log");
$this->writeArtisanScrip | up.
*
* @var string|null
*/
protected $originalArtisan;
/**
* The Filesystem instance for writing stubs and logs.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $fs;
p | {
"filepath": "tests/Integration/Console/CommandSchedulingTest.php",
"language": "php",
"file_size": 6082,
"cut_index": 716,
"middle_length": 229
} |
use Illuminate\Console\Command;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Console\QueuedCommand;
use Illuminate\Support\Facades\Queue;
use Orchestra\Testbench\TestCase;
use Symfony\Component\Console\Attribute\AsCommand;
class ConsoleApplicationTest ... | ])->assertExitCode(0);
}
public function testArtisanCallUsingCommandNameAliases(): void
{
$this->artisan('app:foobar', [
'id' => 1,
])->assertExitCode(0);
}
public function testArtisanCallUsingCommandCla | ZondaCommandStub::class,
]);
});
parent::setUp();
}
public function testArtisanCallUsingCommandName(): void
{
$this->artisan('foo:bar', [
'id' => 1,
| {
"filepath": "tests/Integration/Console/ConsoleApplicationTest.php",
"language": "php",
"file_size": 3399,
"cut_index": 614,
"middle_length": 229
} |
ilesystem::class);
$this->filesystem->shouldReceive('put')
->andReturn(true);
File::swap($this->filesystem);
}
public function testItFailsWithInvalidCipherFails(): void
{
$this->filesystem->shouldReceive('exists')
->once()
->andReturn(true)
... | ()
->andReturn(true)
->shouldReceive('exists')
->once()
->andReturn(false);
$this->artisan('env:decrypt', ['--cipher' => 'aes-128-cbc', '--key' => 'invalid'])
->expectsOutputToContain('in | ->expectsOutputToContain('Unsupported cipher')
->assertExitCode(1);
}
public function testItFailsUsingCipherWithInvalidKey(): void
{
$this->filesystem->shouldReceive('exists')
->once | {
"filepath": "tests/Integration/Console/EnvironmentDecryptCommandTest.php",
"language": "php",
"file_size": 15165,
"cut_index": 921,
"middle_length": 229
} |
WithQueue;
use Illuminate\Support\Facades\Queue;
use Orchestra\Testbench\TestCase;
class JobSchedulingTest extends TestCase
{
public function testJobQueuingRespectsJobQueue(): void
{
Queue::fake();
/** @var \Illuminate\Console\Scheduling\Schedule $scheduler */
$scheduler = $this->app->... | ig service (which is needed in order to resolve the cache store for the mutex that is being cleared)
$scheduler->job(JobWithDefaultQueue::class)->name('')->everyMinute();
$scheduler->job(JobWithDefaultQueueTwo::class, 'another-queue')->name | environment fire after everything was run, including the tearDown method
// (which flushes the entire container) which would then result in a ReflectionException when the container would try
// to resolve the conf | {
"filepath": "tests/Integration/Console/JobSchedulingTest.php",
"language": "php",
"file_size": 5986,
"cut_index": 716,
"middle_length": 229
} |
te\Tests\Integration\Console;
use Illuminate\Bus\Queueable;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Queue;
u... | {
Queue::fake();
$this->dispatch(
UniqueTestJob::class,
UniqueTestJob::class,
UniqueTestJob::class,
UniqueTestJob::class
);
Queue::assertPushed(UniqueTestJob::class, 1);
| TestJob::class,
TestJob::class,
TestJob::class,
TestJob::class
);
Queue::assertPushed(TestJob::class, 4);
}
public function testUniqueJobsPushedToQueue(): void
| {
"filepath": "tests/Integration/Console/UniqueJobSchedulingTest.php",
"language": "php",
"file_size": 1600,
"cut_index": 537,
"middle_length": 229
} |
gResolutionException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Event;
use Orchestra\Testbench\TestCase;
use ReflectionMethod;
use ReflectionProperty;
class ScheduleRunCommandTest extends TestCase
{
protected function setUp(): void
{
parent::setUp();
Carbon::setTestNow(Carbo... | );
// Create a schedule and add the command
$schedule = $this->app->make(Schedule::class);
$task = $schedule->exec('exit 1')
->everyMinute();
// Make sure it will run regardless of schedule
$task->when( | public function test_failing_command_in_foreground_triggers_event()
{
Event::fake([
ScheduledTaskStarting::class,
ScheduledTaskFinished::class,
ScheduledTaskFailed::class,
] | {
"filepath": "tests/Integration/Console/Scheduling/ScheduleRunCommandTest.php",
"language": "php",
"file_size": 9461,
"cut_index": 921,
"middle_length": 229
} |
ule;
protected function setUp(): void
{
parent::setUp();
$this->schedule = $this->app->make(Schedule::class);
}
public function test_it_doesnt_wait_for_sub_minute_events_when_nothing_is_scheduled()
{
Carbon::setTestNow(Carbon::now()->startOfMinute());
Sleep::fake()... | ::fake();
$this->artisan('schedule:run')
->expectsOutputToContain('Running [Callback]');
Sleep::assertNeverSlept();
}
#[DataProvider('frequencyProvider')]
public function test_it_runs_sub_minute_callbacks($frequen | t_doesnt_wait_for_sub_minute_events_when_none_are_scheduled()
{
$this->schedule
->call(fn () => true)
->everyMinute();
Carbon::setTestNow(Carbon::now()->startOfMinute());
Sleep | {
"filepath": "tests/Integration/Console/Scheduling/SubMinuteSchedulingTest.php",
"language": "php",
"file_size": 9635,
"cut_index": 921,
"middle_length": 229
} |
n(ScheduleListCommand::class)
->assertSuccessful()
->expectsOutputToContain('No scheduled tasks have been defined.');
}
public function testDisplayEmptyScheduleAsJson()
{
$this->withoutMockingConsoleOutput()->artisan(ScheduleListCommand::class, ['--json' => true]);
$... | ob::class)->everyMinute();
$this->schedule->job(new FooParamJob('test'))->everyMinute();
$this->schedule->job(FooJob::class)->name('foo-named-job')->everyMinute();
$this->schedule->job(new FooParamJob('test'))->name('foo-named-param | $this->schedule->command(FooCommand::class)->quarterly();
$this->schedule->command('inspire')->twiceDaily(14, 18);
$this->schedule->command('foobar', ['a' => 'b'])->everyMinute();
$this->schedule->job(FooJ | {
"filepath": "tests/Integration/Console/Scheduling/ScheduleListCommandTest.php",
"language": "php",
"file_size": 25233,
"cut_index": 1331,
"middle_length": 229
} |
rt;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\Factories\UserFactory;
use Orchestra\Testbench\TestCas... | $unverifiedUsers = User::unverified();
$this->assertCount(3, $verifiedUsers);
$this->assertCount(2, $unverifiedUsers);
$this->assertCount(2, DB::getQueryLog());
$verifiedUsers2 = User::verified();
$this->as | serFactory::times(2)->unverified()->create();
}
public function testItCanCacheStaticMethodWithoutParameters()
{
DB::enableQueryLog();
DB::flushQueryLog();
$verifiedUsers = User::verified();
| {
"filepath": "tests/Integration/Support/OnceHelperTest.php",
"language": "php",
"file_size": 2435,
"cut_index": 563,
"middle_length": 229
} |
uiresOperatingSystem;
use Symfony\Component\Process\Process;
#[RequiresOperatingSystem('Linux|Darwin')]
class FilesystemTest extends TestCase
{
protected $stubFile;
protected function setUp(): void
{
$this->afterApplicationCreated(function () {
File::put($file = storage_path('app/publi... | $this->assertTrue(File::exists($this->stubFile));
$this->assertTrue(File::isFile($this->stubFile));
File::delete($this->stubFile);
$this->assertFalse(File::exists($this->stubFile));
}
public function testItCanDeleteViaF | if (File::exists($this->stubFile)) {
File::delete($this->stubFile);
}
});
parent::setUp();
}
public function testItCanDeleteViaFilesystemShouldUpdatesFileExists()
{
| {
"filepath": "tests/Integration/Filesystem/FilesystemTest.php",
"language": "php",
"file_size": 5191,
"cut_index": 716,
"middle_length": 229
} |
te\Support\Facades\Storage;
use Orchestra\Testbench\Attributes\WithConfig;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\RequiresOperatingSystem;
#[WithConfig('filesystems.disks.local.serve', true)]
class ReceiveFileTest extends TestCase
{
protected function setUp(): void
{
$this->... | ));
$response = $this->call('PUT', $result['url'], [], [], [], [], 'Hello World');
$response->assertNoContent();
Storage::assertExists('receive-file-test.txt', 'Hello World');
}
public function testItWill403OnWrongSignatu | ceive-file-test.txt',
]);
});
parent::setUp();
}
public function testItCanReceiveAFile()
{
$result = Storage::temporaryUploadUrl('receive-file-test.txt', Carbon::now()->addMinute( | {
"filepath": "tests/Integration/Filesystem/ReceiveFileTest.php",
"language": "php",
"file_size": 3911,
"cut_index": 614,
"middle_length": 229
} |
te\Tests\Integration\Console;
use Illuminate\Console\Application as Artisan;
use Illuminate\Console\Command;
use Illuminate\Console\ManuallyFailedException;
use Orchestra\Testbench\TestCase;
class CommandManualFailTest extends TestCase
{
protected function setUp(): void
{
Artisan::starting(function ($... | is->expectExceptionMessage('Whoops!');
$command = new Command;
$command->fail('Whoops!');
}
public function testCreatesAnExceptionFromNull(): void
{
$this->expectException(ManuallyFailedException::class);
$this- | mmandManually(): void
{
$this->artisan('app:fail')->assertFailed();
}
public function testCreatesAnExceptionFromString(): void
{
$this->expectException(ManuallyFailedException::class);
$th | {
"filepath": "tests/Integration/Console/CommandManualFailTest.php",
"language": "php",
"file_size": 1866,
"cut_index": 537,
"middle_length": 229
} |
n);
}
public function testGroupedScheduleCanOverrideGroupCronExpression()
{
Schedule::daily()->group(function () {
Schedule::command('inspire');
Schedule::command('inspire')
->twiceDaily();
});
$events = Schedule::events();
$this->ass... | nts[0]->repeatSeconds);
$this->assertSame('* * * * *', $events[0]->expression);
}
public function testGroupedScheduleCanOverrideGroupRepeatSeconds()
{
Schedule::everyMinute()
->everyThirtySeconds()
->gro | Schedule::everyMinute()
->everyThirtySeconds()
->group(function () {
Schedule::command('inspire');
});
$events = Schedule::events();
$this->assertSame(30, $eve | {
"filepath": "tests/Integration/Console/Scheduling/ScheduleGroupTest.php",
"language": "php",
"file_size": 20161,
"cut_index": 1331,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.