prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
<?php namespace Illuminate\Tests\Integration\Database; use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\Fixtures\User; class EloquentCollectionFreshTest extends DatabaseTestCas...
m'], ]); $collection = User::all(); $collection->first()->delete(); $freshCollection = $collection->fresh(); $this->assertCount(1, $freshCollection); $this->assertInstanceOf(EloquentCollection::class, $fr
'); $table->timestamps(); }); } public function testEloquentCollectionFresh() { User::insert([ ['email' => 'laravel@framework.com'], ['email' => 'laravel@laravel.co
{ "filepath": "tests/Integration/Database/EloquentCollectionFreshTest.php", "language": "php", "file_size": 1021, "cut_index": 512, "middle_length": 229 }
Schema::create('users', function (Blueprint $table) { $table->increments('id'); }); Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('user_id'); }); Schema::create('comments', function (Bluepri...
$table->increments('id'); $table->unsignedInteger('post_id'); }); Schema::create('post_sub_relations', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_relation_i
eate('revisions', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('comment_id'); }); Schema::create('post_relations', function (Blueprint $table) {
{ "filepath": "tests/Integration/Database/EloquentCollectionLoadMissingTest.php", "language": "php", "file_size": 10171, "cut_index": 921, "middle_length": 229 }
}); Schema::create('teams', function (Blueprint $table) { $table->increments('id'); $table->integer('owner_id')->nullable(); $table->string('owner_slug')->nullable(); }); Schema::create('categories', function (Blueprint $table) { $table->incr...
$table->string('title')->unique(); $table->timestamps(); }); } public function testBasicCreateAndRetrieve() { $user = User::create(['name' => Str::random()]); $team1 = Team::create(['owner_id' => $user->id]
$table->increments('id'); $table->integer('category_id'); }); Schema::create('articles', function (Blueprint $table) { $table->id(); $table->foreignId('user_id');
{ "filepath": "tests/Integration/Database/EloquentHasManyThroughTest.php", "language": "php", "file_size": 17788, "cut_index": 1331, "middle_length": 229 }
amespace Illuminate\Tests\Integration\Generators; class ProviderMakeCommandTest extends TestCase { protected $files = [ 'app/Providers/FooServiceProvider.php', ]; public function testItCanGenerateServiceProviderFile() { $this->artisan('make:provider', ['name' => 'FooServiceProvider']) ...
blic function register()', 'public function boot()', ], 'app/Providers/FooServiceProvider.php'); $this->assertEquals([ 'App\Providers\FooServiceProvider', ], require $this->app->getBootstrapProvidersPath());
ceProvider extends ServiceProvider', 'pu
{ "filepath": "tests/Integration/Generators/ProviderMakeCommandTest.php", "language": "php", "file_size": 837, "cut_index": 520, "middle_length": 52 }
te\Tests\Integration\Generators; class TestMakeCommandTest extends TestCase { protected $files = [ 'tests/Feature/FooTest.php', 'tests/Unit/FooTest.php', ]; public function testItCanGenerateFeatureTest() { $this->artisan('make:test', ['name' => 'FooTest']) ->assertE...
'make:test', ['name' => 'FooTest', '--unit' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace Tests\Unit;', 'use PHPUnit\Framework\TestCase;', 'class FooTest extends TestCase',
n\Testing\WithFaker;', 'use Tests\TestCase;', 'class FooTest extends TestCase', ], 'tests/Feature/FooTest.php'); } public function testItCanGenerateUnitTest() { $this->artisan(
{ "filepath": "tests/Integration/Generators/TestMakeCommandTest.php", "language": "php", "file_size": 1825, "cut_index": 537, "middle_length": 229 }
gumentException; use PHPUnit\Framework\Attributes\DataProvider; use RuntimeException; class DatabaseConnectionsTest extends DatabaseTestCase { public function testBuildDatabaseConnection() { /** @var \Illuminate\Database\DatabaseManager $manager */ $manager = $this->app->make(DatabaseManager::c...
$manager->connectUsing('my-phpunit-connection', [ 'driver' => 'sqlite', 'database' => ':memory:', ]); $connection->statement('CREATE TABLE test_1 (id INTEGER PRIMARY KEY)'); $connection->statement('INSERT I
onnection); } public function testEstablishDatabaseConnection() { /** @var \Illuminate\Database\DatabaseManager $manager */ $manager = $this->app->make(DatabaseManager::class); $connection =
{ "filepath": "tests/Integration/Database/DatabaseConnectionsTest.php", "language": "php", "file_size": 13547, "cut_index": 921, "middle_length": 229 }
cted function afterRefreshingDatabase() { Schema::create('test_eloquent_model_with_custom_casts', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); }); } public function testBasicCustomCasting() { $model = new TestEloquentModel...
R', $unserializedModel->getAttributes()['uppercase']); $this->assertSame('TAYLOR', $unserializedModel->toArray()['uppercase']); $model->syncOriginal(); $model->uppercase = 'dries'; $this->assertSame('TAYLOR', $model->getOri
$this->assertSame('TAYLOR', $model->toArray()['uppercase']); $unserializedModel = unserialize(serialize($model)); $this->assertSame('TAYLOR', $unserializedModel->uppercase); $this->assertSame('TAYLO
{ "filepath": "tests/Integration/Database/DatabaseEloquentModelAttributeCastingTest.php", "language": "php", "file_size": 16326, "cut_index": 921, "middle_length": 229 }
abaseTransactionsTest extends DatabaseTestCase { protected function defineEnvironment($app) { parent::defineEnvironment($app); $app['config']->set([ 'database.connections.second_connection' => [ 'driver' => 'sqlite', 'database' => ':memory:', ...
DB::transaction(function () use ($secondObject) { DB::afterCommit(fn () => $secondObject->handle()); }); }); $this->assertTrue($firstObject->ran); $this->assertTrue($secondObject->ran); $
new TestObjectForTransactions(), new TestObjectForTransactions(), ]; DB::transaction(function () use ($secondObject, $firstObject) { DB::afterCommit(fn () => $firstObject->handle());
{ "filepath": "tests/Integration/Database/DatabaseTransactionsTest.php", "language": "php", "file_size": 5002, "cut_index": 614, "middle_length": 229 }
Support\Facades\Schema; class EloquentCustomPivotCastTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email'); }); Schema::create('proje...
CastTestUser::forceCreate([ 'email' => 'taylor@laravel.com', ]); $project = CustomPivotCastTestProject::forceCreate([ 'name' => 'Test Project', ]); $project->collaborators()->attach($user, ['permiss
$table->integer('user_id'); $table->integer('project_id'); $table->text('permissions'); }); } public function testCastsAreRespectedOnAttach() { $user = CustomPivot
{ "filepath": "tests/Integration/Database/EloquentCustomPivotCastTest.php", "language": "php", "file_size": 5621, "cut_index": 716, "middle_length": 229 }
namespace Illuminate\Tests\Integration\Generators; class ResourceMakeCommandTest extends TestCase { protected $files = [ 'app/Http/Resources/FooResource.php', 'app/Http/Resources/FooResourceCollection.php', ]; public function testItCanGenerateResourceFile() { $this->artisan('m...
n('make:resource', ['name' => 'FooResourceCollection', '--collection' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Http\Resources;', 'use Illuminate\Http\Resources\Json\ResourceColle
sources\Json\JsonResource;', 'class FooResource extends JsonResource', ], 'app/Http/Resources/FooResource.php'); } public function testItCanGenerateResourceCollectionFile() { $this->artisa
{ "filepath": "tests/Integration/Generators/ResourceMakeCommandTest.php", "language": "php", "file_size": 1150, "cut_index": 518, "middle_length": 229 }
n; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; use Mockery as m; use Orchestra\Testbench\Attributes\WithMigration; use PDOException; use PHPUnit\Framework\Attributes\TestWith; #[WithMigration('cache')] class DatabaseLockTest extends DatabaseTestCase { pub...
$lock = Cache::driver('database')->lock('foo'); $this->assertTrue($lock->get()); $otherLock = Cache::driver('database')->lock('foo'); $this->assertFalse($otherLock->get()); $lock->release(); $otherLock = Cache::
ons.test', $this->app['config']->get('database.connections.mysql')); $this->assertSame('test', Cache::driver('database')->lock('foo')->getConnectionName()); } public function testLockCanBeAcquired() {
{ "filepath": "tests/Integration/Database/DatabaseLockTest.php", "language": "php", "file_size": 5879, "cut_index": 716, "middle_length": 229 }
lder; use Illuminate\Support\Facades\Facade; use PHPUnit\Framework\TestCase; class DatabaseSchemaBuilderIntegrationTest extends TestCase { protected $db; /** * Bootstrap database. * * @return void */ protected function setUp(): void { $this->db = $db = new DB; $db-...
parent::tearDown(); } public function testHasColumnWithTablePrefix() { $this->db::connection()->setTablePrefix('test_'); $this->db::connection()->getSchemaBuilder()->create('table1', function (Blueprint $table) {
nce('db', $db->getDatabaseManager()); Facade::setFacadeApplication($container); } protected function tearDown(): void { Facade::clearResolvedInstances(); Facade::setFacadeApplication(null);
{ "filepath": "tests/Database/DatabaseSchemaBuilderIntegrationTest.php", "language": "php", "file_size": 5112, "cut_index": 716, "middle_length": 229 }
space Illuminate\Tests\Integration\Generators; class ViewMakeCommandTest extends TestCase { protected $files = [ 'resources/views/foo.blade.php', 'tests/Feature/View/FooTest.php', ]; public function testItCanGenerateViewFile() { $this->artisan('make:view', ['name' => 'foo']) ...
$this->artisan('make:view', ['name' => 'foo', '--test' => true]) ->assertExitCode(0); $this->assertFilenameExists('resources/views/foo.blade.php'); $this->assertFilenameExists('tests/Feature/View/FooTest.php'); } }
c function testItCanGenerateViewFileWithTest() {
{ "filepath": "tests/Integration/Generators/ViewMakeCommandTest.php", "language": "php", "file_size": 832, "cut_index": 523, "middle_length": 52 }
sStringable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Fluent; use Illuminate\Support\Stringable; class DatabaseCustomCastsTest extends DatabaseT...
table->timestamps(); }); Schema::create('test_eloquent_model_with_custom_casts_nullables', function (Blueprint $table) { $table->increments('id'); $table->text('array_object')->nullable(); $table->json('
d'); $table->text('array_object'); $table->json('array_object_json'); $table->text('collection'); $table->string('stringable'); $table->string('password'); $
{ "filepath": "tests/Integration/Database/DatabaseCustomCastsTest.php", "language": "php", "file_size": 8696, "cut_index": 716, "middle_length": 229 }
Blueprint $table) { $table->increments('id'); $table->string('user_uuid'); $table->string('post_uuid'); $table->tinyInteger('is_draft')->default(1); $table->timestamps(); }); Schema::create('posts_tags', function (Blueprint $table) { ...
('post_id'); $table->integer('tag_id')->default(0); $table->string('tag_name')->default('')->nullable(); $table->string('flag')->default('')->nullable(); $table->timestamps(); }); } public fu
')->nullable(); $table->string('isActive')->default('')->nullable(); $table->timestamps(); }); Schema::create('posts_unique_tags', function (Blueprint $table) { $table->integer
{ "filepath": "tests/Integration/Database/EloquentBelongsToManyTest.php", "language": "php", "file_size": 57115, "cut_index": 2151, "middle_length": 229 }
ase; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use stdClass; class EloquentModelStringCastingTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('casting_table', functio...
s $model */ $model = StringCasts::create([ 'array_attributes' => ['key1' => 'value1'], 'json_attributes' => ['json_key' => 'json_value'], 'object_attributes' => ['json_key' => 'json_value'], ]); $
ttributes'); $table->timestamps(); }); } /** * Tests... */ public function testSavingCastedAttributesToDatabase() { /** @var \Illuminate\Tests\Integration\Database\StringCast
{ "filepath": "tests/Integration/Database/EloquentModelStringCastingTest.php", "language": "php", "file_size": 2821, "cut_index": 563, "middle_length": 229 }
te\Tests\Integration\Database\EloquentMorphLazyEagerLoadingTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphLazyEagerLoadingTest extends DatabaseTestCase { p...
nts('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $user = User::create(); $post = tap((new Post)->user()->associate($user))->save(); (new Comment)->commentable()
', function (Blueprint $table) { $table->increments('post_id'); $table->unsignedInteger('user_id'); }); Schema::create('comments', function (Blueprint $table) { $table->increme
{ "filepath": "tests/Integration/Database/EloquentMorphLazyEagerLoadingTest.php", "language": "php", "file_size": 1783, "cut_index": 537, "middle_length": 229 }
te\Tests\Integration\Database\EloquentMorphCountLazyEagerLoadingTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphCountLazyEagerLoadingTest extends DatabaseTestCa...
crements('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $post = Post::create(); tap((new Like)->post()->associate($post))->save(); tap((new Like)->post()->associat
ger('post_id'); }); Schema::create('posts', function (Blueprint $table) { $table->increments('id'); }); Schema::create('comments', function (Blueprint $table) { $table->in
{ "filepath": "tests/Integration/Database/EloquentMorphCountLazyEagerLoadingTest.php", "language": "php", "file_size": 1885, "cut_index": 537, "middle_length": 229 }
ontracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphToEagerLoadTest extends DatabaseTestCase { protected function afterRefr...
tion (Blueprint $table) { $table->increments('id'); $table->string('commentable_type'); $table->string('commentable_id'); }); $post = Post::create(); $article = Article::create(['slug' => Article
table) { $table->string('slug')->primary(); }); Schema::create('videos', function (Blueprint $table) { $table->string('id')->primary(); }); Schema::create('comments', func
{ "filepath": "tests/Integration/Database/EloquentMorphToEagerLoadTest.php", "language": "php", "file_size": 4011, "cut_index": 614, "middle_length": 229 }
lluminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; class EloquentModelTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('test_model1', function (Blueprint $table) { ...
=> null, ]); $user->fill([ 'nullable_date' => $now = Carbon::now(), ]); $this->assertTrue($user->isDirty('nullable_date')); $user->save(); $this->assertEquals($now->toDateString(), $user->nulla
rements('id'); $table->string('name'); $table->string('title'); }); } public function testUserCanUpdateNullableDate() { $user = TestModel1::create([ 'nullable_date'
{ "filepath": "tests/Integration/Database/EloquentModelTest.php", "language": "php", "file_size": 4862, "cut_index": 614, "middle_length": 229 }
ase\EloquentMorphConstrainTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphConstrainTest extends DatabaseTest...
on (Blueprint $table) { $table->increments('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $post1 = Post::create(['post_visible' => true]); (new Comment)->commen
ost_visible'); }); Schema::create('videos', function (Blueprint $table) { $table->increments('id'); $table->boolean('video_visible'); }); Schema::create('comments', functi
{ "filepath": "tests/Integration/Database/EloquentMorphConstrainTest.php", "language": "php", "file_size": 2720, "cut_index": 563, "middle_length": 229 }
Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphEager...
a::create('videos', function (Blueprint $table) { $table->increments('video_id'); }); Schema::create('actions', function (Blueprint $table) { $table->increments('id'); $table->string('target_type');
; $table->softDeletes(); }); Schema::create('posts', function (Blueprint $table) { $table->increments('post_id'); $table->unsignedInteger('user_id'); }); Schem
{ "filepath": "tests/Integration/Database/EloquentMorphEagerLoadingTest.php", "language": "php", "file_size": 4617, "cut_index": 614, "middle_length": 229 }
\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphOne; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphManyTest extends DatabaseTestC...
ble_id'); $table->string('commentable_type'); $table->timestamps(); }); } public function testUpdateModelWithDefaultWithCount() { $post = Post::create(['title' => Str::random()]); $post->update(
le'); $table->timestamps(); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->integer('commenta
{ "filepath": "tests/Integration/Database/EloquentMorphManyTest.php", "language": "php", "file_size": 3285, "cut_index": 614, "middle_length": 229 }
nate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\MorphTo; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphCountEagerLoadingTest extends DatabaseTestCase { protected function after...
$table->increments('id'); }); Schema::create('videos', function (Blueprint $table) { $table->increments('id'); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'
Schema::create('views', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('video_id'); }); Schema::create('posts', function (Blueprint $table) {
{ "filepath": "tests/Integration/Database/EloquentMorphCountEagerLoadingTest.php", "language": "php", "file_size": 3322, "cut_index": 614, "middle_length": 229 }
hp namespace Illuminate\Tests\Integration\Database; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class EloquentModelWithoutEventsTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('a...
); $this->assertSame('Laravel', $model->project); } } class AutoFilledModel extends Model { public $table = 'auto_filled_models'; public $timestamps = false; protected $guarded = []; public static function boot() {
sRegistersBootedListenersForLater() { $model = AutoFilledModel::withoutEvents(function () { return AutoFilledModel::create(); }); $this->assertNull($model->project); $model->save(
{ "filepath": "tests/Integration/Database/EloquentModelWithoutEventsTest.php", "language": "php", "file_size": 1123, "cut_index": 515, "middle_length": 229 }
ase\EloquentMorphOneIsTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphOneIsTest extends DatabaseTestCase { protected function afterRefreshingDatabase() ...
$post->attachment()->create(); } public function testChildIsNotNull() { $parent = Post::first(); $child = null; $this->assertFalse($parent->attachment()->is($child)); $this->assertTrue($parent->attachment()
ion (Blueprint $table) { $table->increments('id'); $table->string('attachable_type')->nullable(); $table->integer('attachable_id')->nullable(); }); $post = Post::create();
{ "filepath": "tests/Integration/Database/EloquentMorphOneIsTest.php", "language": "php", "file_size": 2770, "cut_index": 563, "middle_length": 229 }
ase\EloquentMorphToGlobalScopesTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; cl...
$table->integer('commentable_id'); }); $post = Post::create(); (new Comment)->commentable()->associate($post)->save(); $post = tap(Post::create())->delete(); (new Comment)->commentable()->associate($post)->
$table->increments('id'); $table->softDeletes(); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('commentable_type');
{ "filepath": "tests/Integration/Database/EloquentMorphToGlobalScopesTest.php", "language": "php", "file_size": 2374, "cut_index": 563, "middle_length": 229 }
ase\EloquentMorphToLazyEagerLoadingTest; use DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphToLazyEagerLoadingTest extends DatabaseTestCase { protected funct...
}); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $user = User::create();
lueprint $table) { $table->increments('post_id'); $table->unsignedInteger('user_id'); }); Schema::create('videos', function (Blueprint $table) { $table->increments('video_id');
{ "filepath": "tests/Integration/Database/EloquentMorphToLazyEagerLoadingTest.php", "language": "php", "file_size": 2256, "cut_index": 563, "middle_length": 229 }
Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Orchestra\Testbench\Attributes\RequiresDatabase; use PHPUnit\Framework\Attributes\DataProvider; require_once 'Enums.php'; class QueryBuilderUpdateTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Sc...
) { $table->increments('id'); $table->unsignedBigInteger('example_id'); $table->integer('credits'); }); } #[DataProvider('jsonValuesDataProvider')] #[RequiresDatabase(['sqlite', 'mysql', 'mariadb'])]
$table->string('status')->nullable(); $table->integer('credits')->nullable(); $table->json('payload')->nullable(); }); Schema::create('example_credits', function (Blueprint $table
{ "filepath": "tests/Integration/Database/QueryBuilderUpdateTest.php", "language": "php", "file_size": 3139, "cut_index": 614, "middle_length": 229 }
Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; class QueryBuilderWhereLikeTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->id('id'); $table->string('name', 200); ...
le doe', 'email' => 'Dale.Doe@example.com'], ['name' => 'Earl Smith', 'email' => 'Earl.Smith@example.com'], ['name' => 'tim smith', 'email' => 'tim.smith@example.com'], ]); } public function testWhereLike() {
parent::setUp(); DB::table('users')->insert([ ['name' => 'John Doe', 'email' => 'John.Doe@example.com'], ['name' => 'Jane Doe', 'email' => 'janedoe@example.com'], ['name' => 'Da
{ "filepath": "tests/Integration/Database/QueryBuilderWhereLikeTest.php", "language": "php", "file_size": 4266, "cut_index": 614, "middle_length": 229 }
ase; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; include_once 'Enums.php'; class QueryingWithEnumsTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('enum_casts', function (Blueprint $ta...
'non_backed_status' => 'pending', ]); $record = DB::table('enum_casts')->where('string_status', StringStatus::pending)->first(); $record2 = DB::table('enum_casts')->where('integer_status', IntegerStatus::pending)->first(
('non_backed_status', 100)->nullable(); }); } public function testCanQueryWithEnums() { DB::table('enum_casts')->insert([ 'string_status' => 'pending', 'integer_status' => 1,
{ "filepath": "tests/Integration/Database/QueryingWithEnumsTest.php", "language": "php", "file_size": 2227, "cut_index": 563, "middle_length": 229 }
pace Illuminate\Tests\Integration\Database; use Illuminate\Support\Facades\DB; use Orchestra\Testbench\TestCase; class RefreshCommandTest extends TestCase { public function testRefreshWithoutRealpath() { $this->app->setBasePath(__DIR__); $options = [ '--path' => 'stubs/', ...
$this->artisan('db:wipe', ['--drop-views' => true]); } $this->beforeApplicationDestroyed(function () use ($options) { $this->artisan('migrate:rollback', $options); }); $this->artisan('migrate:refresh',
'--realpath' => true, ]; $this->migrateRefreshWith($options); } private function migrateRefreshWith(array $options) { if ($this->app['config']->get('database.default') !== 'testing') {
{ "filepath": "tests/Integration/Database/RefreshCommandTest.php", "language": "php", "file_size": 1311, "cut_index": 524, "middle_length": 229 }
Database('my_schema'); } elseif ($this->driver === 'sqlite') { DB::connection('without-prefix')->statement("attach database ':memory:' as my_schema"); DB::connection('with-prefix')->statement("attach database ':memory:' as my_schema"); } elseif ($this->driver === 'pgsql') { ...
if ($this->driver === 'sqlite') { DB::connection('without-prefix')->statement('detach database my_schema'); DB::connection('with-prefix')->statement('detach database my_schema'); } elseif ($this->driver === 'pgsql') {
chema my_schema') end"); } } protected function destroyDatabaseMigrations() { if (in_array($this->driver, ['mariadb', 'mysql'])) { Schema::dropDatabaseIfExists('my_schema'); } else
{ "filepath": "tests/Integration/Database/SchemaBuilderSchemaNameTest.php", "language": "php", "file_size": 25918, "cut_index": 1331, "middle_length": 229 }
public function testDropAllViews() { $this->expectNotToPerformAssertions(); DB::statement('create view foo (id) as select 1'); Schema::dropAllViews(); DB::statement('create view foo (id) as select 1'); } #[RequiresDatabase('sqlite')] public function testChangeToT...
} #[RequiresDatabase(['mysql', 'mariadb'])] public function testChangeToTextColumn() { Schema::create('test', function (Blueprint $table) { $table->integer('test_column'); }); foreach (['tinyText', 'text',
), 'test', function (Blueprint $table) { $table->tinyInteger('test_column')->change(); }); $blueprint->build(); $this->assertSame('integer', Schema::getColumnType('test', 'test_column'));
{ "filepath": "tests/Integration/Database/SchemaBuilderTest.php", "language": "php", "file_size": 33514, "cut_index": 1331, "middle_length": 229 }
ase; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Orchestra\Testbench\Attributes\RequiresDatabase; class TimestampTypeTest extends DatabaseTestCase { public function testChangeDatetimeColumnToTimestampColumn() { Schema::create('test', function (Blueprint $table)...
match ($this->driver) { 'mysql', 'mariadb', 'pgsql' => 'timestamp', default => 'datetime', }, Schema::getColumnType('test', 'datetime_to_timestamp') ); } public function tes
tamp')->nullable()->change(); }); $this->assertTrue(Schema::hasColumn('test', 'datetime_to_timestamp')); // Only MySQL, MariaDB, and PostgreSQL actually have a timestamp type $this->assertSame(
{ "filepath": "tests/Integration/Database/TimestampTypeTest.php", "language": "php", "file_size": 2328, "cut_index": 563, "middle_length": 229 }
lluminate\Database\Schema\Blueprint; use Illuminate\Database\UniqueConstraintViolationException; use Illuminate\Support\Facades\Schema; use Orchestra\Testbench\Attributes\RequiresDatabase; class UniqueConstraintViolationTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Sche...
e'], 'unique_composite_idx'); }); } private function createUniqueModel(): UniqueConstraintViolationException { UniqueSingleModel::query()->create(['name' => 'test']); try { UniqueSingleModel::query()->create
e('test_unique_constraint_composite', function (Blueprint $table) { $table->id(); $table->string('first_name'); $table->string('last_name'); $table->unique(['first_name', 'last_nam
{ "filepath": "tests/Integration/Database/UniqueConstraintViolationTest.php", "language": "php", "file_size": 4076, "cut_index": 614, "middle_length": 229 }
ase\Sqlite; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use Orchestra\Testbench\Attributes\RequiresDatabase; #[RequiresDatabase('sqlite')] class ConnectorTest extends DatabaseTestCase { private string $databasePath; pro...
ry:', ])->getSchemaBuilder(); $this->assertSame(0, $schema->pragma('foreign_keys')); $this->assertSame(60000, $schema->pragma('busy_timeout')); $this->assertSame('memory', $schema->pragma('journal_mode')); $this->as
s() { Schema::dropDatabaseIfExists($this->databasePath); } public function testConnectionConfigurations() { $schema = DB::build([ 'driver' => 'sqlite', 'database' => ':memo
{ "filepath": "tests/Integration/Database/Sqlite/ConnectorTest.php", "language": "php", "file_size": 2256, "cut_index": 563, "middle_length": 229 }
', function ($table) { $table->renameColumn('name', 'first_name'); $table->integer('age')->change(); }); $queries = $blueprint->toSql(); $expected = [ 'alter table "users" rename column "name" to "first_name"', 'create table "__temp__users" ("fir...
uilder(); $schema->create('test', function (Blueprint $table) { $table->string('foo'); $table->string('baz'); }); $schema->table('test', function (Blueprint $table) { $table->renameColumn('foo',
'alter table "__temp__users" rename to "users"', ]; $this->assertEquals($expected, $queries); } public function testRenamingColumnsWorks() { $schema = DB::connection()->getSchemaB
{ "filepath": "tests/Integration/Database/Sqlite/DatabaseSchemaBlueprintTest.php", "language": "php", "file_size": 20274, "cut_index": 1331, "middle_length": 229 }
on; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Orchestra\Testbench\Attributes\RequiresDatabase; use Orchestra\Testbench\TestCase; #[RequiresDatabase('sqlite')] class DatabaseSchemaBuilderTest extends TestCase { protected function defineEn...
=> ':memory:', 'prefix' => 'example_', 'prefix_indexes' => true, ], ]); } public function testDropAllTablesWorksWithForeignKeys() { Schema::create('table1', function (Blueprint $table
'prefix' => 'example_', 'prefix_indexes' => false, ], 'database.connections.sqlite-with-indexed-prefix' => [ 'driver' => 'sqlite', 'database'
{ "filepath": "tests/Integration/Database/Sqlite/DatabaseSchemaBuilderTest.php", "language": "php", "file_size": 4780, "cut_index": 614, "middle_length": 229 }
ase\Sqlite; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use Orchestra\Testbench\Attributes\RequiresDatabase; use PHPUnit\Framework\Attributes\DataProvider; #[RequiresDatabase('sqlite')] ...
erRefreshingDatabase() { if (! Schema::hasTable('json_table')) { Schema::create('json_table', function (Blueprint $table) { $table->json('json_col')->nullable(); }); } } protected functio
se.default', 'conn1'); $app['config']->set('database.connections.conn1', [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ]); } protected function aft
{ "filepath": "tests/Integration/Database/Sqlite/DatabaseSqliteConnectionTest.php", "language": "php", "file_size": 2258, "cut_index": 563, "middle_length": 229 }
ase\Sqlite; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use Orchestra\Testbench\Attributes\RequiresDatabase; #[RequiresDatabase('sqlite')] class DatabaseSqliteSchemaBuilderTest extends D...
:create('users', function (Blueprint $table) { $table->integer('id'); $table->string('name'); $table->string('age'); $table->enum('color', ['red', 'blue']); }); } protected function destroyDa
']->set('database.connections.conn1', [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ]); } protected function afterRefreshingDatabase() { Schema:
{ "filepath": "tests/Integration/Database/Sqlite/DatabaseSqliteSchemaBuilderTest.php", "language": "php", "file_size": 2647, "cut_index": 563, "middle_length": 229 }
; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Orchestra\Testbench\Attributes\RequiresDatabase; use Orchestra\Testbench\TestCase; #[RequiresDatabase('sqlite')] class EloquentModelConnectionsTest extends TestCase { protected function defineEnvironm...
} protected function defineDatabaseMigrations() { Schema::create('parent', function (Blueprint $table) { $table->increments('id'); $table->string('name'); }); Schema::create('child', function (Bl
=> ':memory:', 'prefix' => '', ]); $app['config']->set('database.connections.conn2', [ 'driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '', ]);
{ "filepath": "tests/Integration/Database/Sqlite/EloquentModelConnectionsTest.php", "language": "php", "file_size": 4761, "cut_index": 614, "middle_length": 229 }
ase\Sqlite; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use Orchestra\Testbench\Attributes\RequiresDatabase; use RuntimeException; #[RequiresDatabase('sqlite')] class EscapeTest extends DatabaseTestCase { protected function defineEnvironment($app) { parent::defineEnvironment($app); ...
function testEscapeFloat() { $this->assertSame('3.14159', $this->app['db']->escape(3.14159)); $this->assertSame('-3.14159', $this->app['db']->escape(-3.14159)); } public function testEscapeBool() { $this->assertSam
'prefix' => '', ]); } public function testEscapeInt() { $this->assertSame('42', $this->app['db']->escape(42)); $this->assertSame('-6', $this->app['db']->escape(-6)); } public
{ "filepath": "tests/Integration/Database/Sqlite/EscapeTest.php", "language": "php", "file_size": 2481, "cut_index": 563, "middle_length": 229 }
ase\Sqlite; use Illuminate\Support\Facades\DB; use Orchestra\Testbench\Attributes\RequiresDatabase; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use function Orchestra\Testbench\remote; #[RequiresDatabase('sq...
')] public function testSchemaDumpOnSqlite() { if ($this->usesSqliteInMemoryDatabaseConnection()) { $this->markTestSkipped('Test cannot be run using :in-memory: database connection'); } $connection = DB::connect
parent::setUp(); remote('migrate:install'); } protected function tearDown(): void { remote('db:wipe')->mustRun(); parent::tearDown(); } #[RequiresOperatingSystem('Linux|Darwin
{ "filepath": "tests/Integration/Database/Sqlite/SchemaStateTest.php", "language": "php", "file_size": 2131, "cut_index": 563, "middle_length": 229 }
hp namespace Illuminate\Tests\Integration\Database; use Illuminate\Foundation\Testing\DatabaseTransactions; use Orchestra\Testbench\TestCase; class EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest extends TestCase { use EloquentTransactionWithAfterCommitTests; use DatabaseTransactions; /*...
Connection()) { $this->markTestSkipped('Test cannot be used with in-memory SQLite connection.'); } } protected function defineEnvironment($app) { $connection = $app->make('config')->get('database.default');
{ foreach (array_keys($this->app['db']->getConnections()) as $name) { $this->app['db']->purge($name); } }); parent::setUp(); if ($this->usesSqliteInMemoryDatabase
{ "filepath": "tests/Integration/Database/EloquentTransactionWithAfterCommitUsingDatabaseTransactionsTest.php", "language": "php", "file_size": 1089, "cut_index": 515, "middle_length": 229 }
pace Illuminate\Tests\Integration\Database\Sqlite\Console; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use Orchestra\Testbench\Attributes\RequiresDatabase; use Orchestra\Testbench\Attributes\WithConfig; use function Illuminat...
stem; $files->copy( join_paths(__DIR__, 'stubs', 'database-journal-mode-wal.sqlite'), join_paths(default_skeleton_path(), 'database', 'database.sqlite') ); $this->beforeApplicationDestroyed(function () use
connections.sqlite.journal_mode', 'wal')] class MigrateFreshCommandWithJournalModeWalTest extends DatabaseTestCase { /** {@inheritDoc} */ #[\Override] protected function setUp(): void { $files = new Filesy
{ "filepath": "tests/Integration/Database/Sqlite/Console/MigrateFreshCommandWithJournalModeWalTest.php", "language": "php", "file_size": 1412, "cut_index": 524, "middle_length": 229 }
namespace Illuminate\Tests\Integration\Database\Fixtures; use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Builder; class NamedScopeUser extends User { /** {@inheritdoc} */ #[\Override] protected function casts(): array { return [ 'email_verified...
dWithoutReturn(Builder $builder, bool $email = true) { $this->verified($builder, $email); } public function scopeVerifiedUser(Builder $builder, bool $email = true) { return $builder->when( $email === true,
( $email === true, fn ($query) => $query->whereNotNull('email_verified_at'), fn ($query) => $query->whereNull('email_verified_at'), ); } #[Scope] protected function verifie
{ "filepath": "tests/Integration/Database/Fixtures/NamedScopeUser.php", "language": "php", "file_size": 1154, "cut_index": 518, "middle_length": 229 }
ase\SqlServer; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; class DatabaseEloquentSqlServerIntegrationTest extends SqlServerTestCase { protected function afterRefreshingDatabase() { if (! Sch...
tions() { Schema::drop('database_eloquent_sql_server_integration_users'); } public function testCreateOrFirst() { $user1 = DatabaseEloquentSqlServerIntegrationUser::createOrFirst(['email' => 'taylorotwell@gmail.com']);
able->id(); $table->string('name')->nullable(); $table->string('email')->unique(); $table->timestamps(); }); } } protected function destroyDatabaseMigra
{ "filepath": "tests/Integration/Database/SqlServer/DatabaseEloquentSqlServerIntegrationTest.php", "language": "php", "file_size": 2888, "cut_index": 563, "middle_length": 229 }
te\Tests\Integration\Database\SqlServer; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\Attributes\RequiresPhpExtension; #...
function destroyDatabaseMigrations() { Schema::drop('json_table'); } #[DataProvider('jsonContainsKeyDataProvider')] public function testWhereJsonContainsKey($count, $column) { DB::table('json_table')->insert([
() { if (! Schema::hasTable('json_table')) { Schema::create('json_table', function (Blueprint $table) { $table->json('json_col')->nullable(); }); } } protected
{ "filepath": "tests/Integration/Database/SqlServer/DatabaseSqlServerConnectionTest.php", "language": "php", "file_size": 1983, "cut_index": 537, "middle_length": 229 }
lueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('title')->nullable(); }); Schema::create('test_model2', function (Blueprint $table) { $table->increments('id'); $table->string('name'); ...
$table->increments('id'); $table->integer('views')->default(0); $table->integer('likes')->default(0); $table->string('name')->nullable(); $table->softDeletes(); $table->timestamps();
$table->increments('id'); $table->unsignedInteger('counter'); $table->softDeletes(); $table->timestamps(); }); Schema::create('test_model4', function (Blueprint $table) {
{ "filepath": "tests/Integration/Database/EloquentUpdateTest.php", "language": "php", "file_size": 9806, "cut_index": 921, "middle_length": 229 }
Case { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email'); $table->string('address'); }); } public function testWhe...
'name' => 'test-name1', 'email' => 'test-email1', 'address' => 'test-address1', ]); $this->assertTrue($firstUser->is(UserWhereTest::where('name', '=', $firstUser->name)->first())); $this->assertTrue($f
'email' => 'test-email', 'address' => 'test-address', ]); /** @var \Illuminate\Tests\Integration\Database\UserWhereTest $secondUser */ $secondUser = UserWhereTest::create([
{ "filepath": "tests/Integration/Database/EloquentWhereTest.php", "language": "php", "file_size": 12234, "cut_index": 921, "middle_length": 229 }
hp namespace Illuminate\Tests\Integration\Database; use Illuminate\Support\Facades\Schema; use Orchestra\Testbench\TestCase; class MigrateWithRealpathTest extends TestCase { protected function setUp(): void { parent::setUp(); if ($this->app['config']->get('database.default') !== 'testing') {...
thMigrationHasProperlyExecuted() { $this->assertTrue(Schema::hasTable('members')); } public function testMigrationsHasTheMigratedTable() { $this->assertDatabaseHas('migrations', [ 'id' => 1, 'migrati
]; $this->artisan('migrate', $options); $this->beforeApplicationDestroyed(function () use ($options) { $this->artisan('migrate:rollback', $options); }); } public function testRealpa
{ "filepath": "tests/Integration/Database/MigrateWithRealpathTest.php", "language": "php", "file_size": 1095, "cut_index": 515, "middle_length": 229 }
ntegration\Database; use Illuminate\Contracts\Support\Arrayable; enum StringStatus: string { case draft = 'draft'; case pending = 'pending'; case done = 'done'; } enum IntegerStatus: int { case draft = 0; case pending = 1; case done = 2; } enum NonBackedStatus { case draft; case pend...
ng status description', self::done => 'done status description' }; } public function toArray() { return [ 'name' => $this->name, 'value' => $this->value, 'description' => $this->d
match ($this) { self::pending => 'pendi
{ "filepath": "tests/Integration/Database/Enums.php", "language": "php", "file_size": 888, "cut_index": 547, "middle_length": 52 }
ttributes\UseResource; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\ModelInfo; use Illuminate\Database\Eloquent\ModelInspector; use Illuminate\Database\E...
Schema::create('model_info_extractor_test_model', function (Blueprint $table) { $table->increments('id'); $table->uuid(); $table->string('name'); $table->boolean('a_bool'); $table->foreignI
chema; class ModelInspectorTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('parent_test_models', function (Blueprint $table) { $table->id(); });
{ "filepath": "tests/Integration/Database/ModelInspectorTest.php", "language": "php", "file_size": 7962, "cut_index": 716, "middle_length": 229 }
ase\EloquentMorphToIsTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphToIsTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { ...
ble()->associate($post)->save(); } public function testParentIsNotNull() { $child = Comment::first(); $parent = null; $this->assertFalse($child->commentable()->is($parent)); $this->assertTrue($child->commentabl
Blueprint $table) { $table->increments('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $post = Post::create(); (new Comment)->commenta
{ "filepath": "tests/Integration/Database/EloquentMorphToIsTest.php", "language": "php", "file_size": 2718, "cut_index": 563, "middle_length": 229 }
ase\EloquentMorphToSelectTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphToSelectTest extends DatabaseTestCase { protected function afterRefreshingDatabase(...
commentable()->associate($post)->save(); } public function testSelect() { $comments = Comment::with('commentable:id')->get(); $this->assertEquals(['id' => 1], $comments[0]->commentable->getAttributes()); } public func
nction (Blueprint $table) { $table->increments('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $post = Post::create(); (new Comment)->
{ "filepath": "tests/Integration/Database/EloquentMorphToSelectTest.php", "language": "php", "file_size": 2303, "cut_index": 563, "middle_length": 229 }
pace Illuminate\Tests\Integration\Database; use Orchestra\Testbench\Attributes\WithMigration; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\DataProvider; #[WithMigration] class EloquentNamedScopeAttributeTest extends TestCase { protected $query = 'select * from "named_scope_users" where "emai...
ry = Fixtures\NamedScopeUser::query()->{$methodName}(true); $this->assertSame($this->query, $query->toRawSql()); } #[DataProvider('scopeDataProvider')] public function test_it_can_query_named_scoped_from_static_query(string $methodNam
(), 'Requires in-memory database connection', ); } #[DataProvider('scopeDataProvider')] public function test_it_can_query_named_scoped_from_the_query_builder(string $methodName) { $que
{ "filepath": "tests/Integration/Database/EloquentNamedScopeAttributeTest.php", "language": "php", "file_size": 1360, "cut_index": 524, "middle_length": 229 }
// clear event log between requests PivotEventsTestCollaborator::$eventsCalled = []; } protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email'); $table-...
ate('equipmentables', function (Blueprint $table) { $table->increments('id'); $table->morphs('equipmentable'); $table->foreignId('equipment_id'); }); Schema::create('project_users', function (Blueprint $
tamps(); }); Schema::create('equipments', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); }); Schema::cre
{ "filepath": "tests/Integration/Database/EloquentPivotEventsTest.php", "language": "php", "file_size": 12610, "cut_index": 921, "middle_length": 229 }
Support\Facades\Schema; class EloquentPivotTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email'); $table->timestamps(); }); ...
e('contributors', function (Blueprint $table) { $table->id(); $table->integer('user_id'); $table->integer('project_id'); $table->text('permissions')->nullable(); }); Schema::create('subscript
ema::create('collaborators', function (Blueprint $table) { $table->integer('user_id'); $table->integer('project_id'); $table->text('permissions')->nullable(); }); Schema::creat
{ "filepath": "tests/Integration/Database/EloquentPivotTest.php", "language": "php", "file_size": 5099, "cut_index": 716, "middle_length": 229 }
?php namespace Illuminate\Tests\Integration\Database; use Illuminate\Tests\Integration\Database\EloquentPivotWithoutTimestampTest as App; use Orchestra\Testbench\Attributes\WithConfig; use Orchestra\Testbench\Attributes\WithMigration; use Orchestra\Testbench\Concerns\WithFixtures; #[WithConfig('auth.providers.users....
$user->roles()->attach($role->getKey(), ['notes' => 'Laravel']); $this->assertDatabaseHas('role_user', [ 'user_id' => $user->getKey(), 'role_id' => $role->getKey(), 'notes' => 'Laravel', 'created_
App\migrate(); } public function testAttachingModelWithoutTimestamps() { $now = $this->freezeSecond(); $user = App\User::factory()->create(); $role = App\Role::factory()->create();
{ "filepath": "tests/Integration/Database/EloquentPivotWithoutTimestampTest.php", "language": "php", "file_size": 1031, "cut_index": 513, "middle_length": 229 }
ase; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class EloquentPushTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->incre...
>unsignedInteger('post_id'); }); } public function testPushMethodSavesTheRelationshipsRecursively() { $user = new UserX; $user->name = 'Test'; $user->save(); $user->posts()->create(['title' => 'Test titl
tle'); $table->unsignedInteger('user_id'); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('comment'); $table-
{ "filepath": "tests/Integration/Database/EloquentPushTest.php", "language": "php", "file_size": 2306, "cut_index": 563, "middle_length": 229 }
uminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Schema; use RuntimeException; class EloquentStrictLoadingTest extends DatabaseTestCase { protected function setUp(): void { parent::setUp(); Model::preventLazyLoading(); } protected...
n (Blueprint $table) { $table->increments('id'); $table->foreignId('model_2_id'); }); } public function testStrictModeThrowsAnExceptionOnLazyLoading() { $this->expectException(LazyLoadingViolationExcepti
lt(1); }); Schema::create('test_model2', function (Blueprint $table) { $table->increments('id'); $table->foreignId('model_1_id'); }); Schema::create('test_model3', functio
{ "filepath": "tests/Integration/Database/EloquentStrictLoadingTest.php", "language": "php", "file_size": 6896, "cut_index": 716, "middle_length": 229 }
UserFactory; trait EloquentTransactionWithAfterCommitTests { use WithLaravelMigrations; protected function setUpEloquentTransactionWithAfterCommitTests(): void { User::unguard(); } protected function tearDownEloquentTransactionWithAfterCommitTests(): void { User::reguard(); ...
erverCalledWithAfterCommitWhenInsideTransaction() { User::observe($observer = EloquentTransactionWithAfterCommitTestsUserObserver::resetting()); $user1 = DB::transaction(fn () => User::create(UserFactory::new()->raw())); $this
= User::create(UserFactory::new()->raw()); $this->assertTrue($user1->exists); $this->assertEquals(1, $observer::$calledTimes, 'Failed to assert the observer was called once.'); } public function testObs
{ "filepath": "tests/Integration/Database/EloquentTransactionWithAfterCommitTests.php", "language": "php", "file_size": 10905, "cut_index": 921, "middle_length": 229 }
te\Tests\Integration\Database; use Illuminate\Support\Facades\DB; use Orchestra\Testbench\Attributes\WithConfig; use function Orchestra\Testbench\artisan; #[WithConfig('database.connections.second', ['driver' => 'sqlite', 'database' => ':memory:', 'foreign_key_constraints' => false])] class EloquentTransactionWithAf...
CommitCallbacksAreCalledCorrectlyWhenNoAppTransaction() { $called = false; DB::afterCommit(function () use (&$called) { $called = true; }); $this->assertTrue($called); } public function testAfterCo
t() { return [null, 'second']; } /** {@inheritDoc} */ protected function afterRefreshingDatabase() { artisan($this, 'migrate', ['--database' => 'second']); } public function testAfter
{ "filepath": "tests/Integration/Database/EloquentTransactionWithAfterCommitUsingRefreshDatabaseOnMultipleConnectionsTest.php", "language": "php", "file_size": 1704, "cut_index": 537, "middle_length": 229 }
e\Foundation\Testing\RefreshDatabase; use Orchestra\Testbench\TestCase; class EloquentTransactionWithAfterCommitUsingRefreshDatabaseTest extends TestCase { use EloquentTransactionWithAfterCommitTests; use RefreshDatabase; /** * The current database driver. * * @var string */ protec...
['db']->purge($name); } }); parent::setUp(); } /** {@inheritDoc} */ protected function defineEnvironment($app) { $connection = $app['config']->get('database.default'); $this->driver = $app['con
onnections()) as $name) { $this->app
{ "filepath": "tests/Integration/Database/EloquentTransactionWithAfterCommitUsingRefreshDatabaseTest.php", "language": "php", "file_size": 953, "cut_index": 582, "middle_length": 52 }
ss EloquentWhereHasMorphTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->softDeletes(); }); Schema::create('...
(['title' => 'foo']); $models[] = Post::create(['title' => 'bar']); $models[] = Post::create(['title' => 'baz']); end($models)->delete(); $models[] = Video::create(['title' => 'foo']); $models[] = Video::create(['ti
$table->increments('id'); $table->string('title'); $table->nullableMorphs('commentable'); $table->softDeletes(); }); $models = []; $models[] = Post::create
{ "filepath": "tests/Integration/Database/EloquentWhereHasMorphTest.php", "language": "php", "file_size": 10580, "cut_index": 921, "middle_length": 229 }
\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentWithCountTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('one', function (Blueprint $...
{ $table->increments('id'); $table->integer('one_id'); }); } public function testItBasic() { $one = Model1::create(); $two = $one->twos()->Create(); $two->threes()->Create(); $re
d'); }); Schema::create('three', function (Blueprint $table) { $table->increments('id'); $table->integer('two_id'); }); Schema::create('four', function (Blueprint $table)
{ "filepath": "tests/Integration/Database/EloquentWithCountTest.php", "language": "php", "file_size": 3465, "cut_index": 614, "middle_length": 229 }
}); DB::table('posts')->insert([ ['title' => 'Foo Post', 'content' => 'Lorem Ipsum.', 'created_at' => new Carbon('2017-11-12 13:14:15')], ['title' => 'Bar Post', 'content' => 'Lorem Ipsum.', 'created_at' => new Carbon('2018-01-02 03:04:05')], ]); } public function t...
, 'user_id' => 1, 'name' => 'Taylor', ], [ 'wallet_1' => 15, 'wallet_2' => 300, 'user_id' => 2, 'name' => 'Otwell', ],
wallet_2'); $table->integer('user_id'); $table->string('name', 20); }); DB::table('accounting')->insert([ [ 'wallet_1' => 100, 'wallet_2' => 200
{ "filepath": "tests/Integration/Database/QueryBuilderTest.php", "language": "php", "file_size": 24430, "cut_index": 1331, "middle_length": 229 }
ort\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMultiDimensionalArrayEagerLoadingTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { ...
er_id'); }); Schema::create('images', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_id'); }); Schema::create('comments', function (Blueprint $table) {
}); Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->string('content'); $table->unsignedInteger('us
{ "filepath": "tests/Integration/Database/EloquentMultiDimensionalArrayEagerLoadingTest.php", "language": "php", "file_size": 8763, "cut_index": 716, "middle_length": 229 }
ns\MorphPivot; use Illuminate\Database\Eloquent\Relations\Pivot; use Illuminate\Database\Schema\Blueprint; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Schema; class EloquentPivotSerializationTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema:...
) { $table->integer('user_id'); $table->integer('project_id'); }); Schema::create('tags', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->t
'projects', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->timestamps(); }); Schema::create('project_users', function (Blueprint $table
{ "filepath": "tests/Integration/Database/EloquentPivotSerializationTest.php", "language": "php", "file_size": 6614, "cut_index": 716, "middle_length": 229 }
Illuminate\Database\Events\ModelsPruned; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Exceptions; use Illuminate\Support\Facades\Schema; use LogicException; class EloquentPrunableTest extends DatabaseTestCase { protec...
$table->increments('id'); $table->string('name')->nullable(); $table->softDeletes(); $table->boolean('pruned')->default(false); $table->timestamps(); }); }); }
able_methods', 'prunable_with_custom_prune_method_test_models', 'prunable_with_exceptions', ])->each(function ($table) { Schema::create($table, function (Blueprint $table) {
{ "filepath": "tests/Integration/Database/EloquentPrunableTest.php", "language": "php", "file_size": 5124, "cut_index": 716, "middle_length": 229 }
ase\EloquentThroughTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentThroughTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { ...
'); $table->integer('commentable_id'); }); Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('comment_id'); }); $post = tap(new Post
function (Blueprint $table) { $table->increments('id'); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->string('commentable_type
{ "filepath": "tests/Integration/Database/EloquentThroughTest.php", "language": "php", "file_size": 2862, "cut_index": 563, "middle_length": 229 }
loquent; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; class EloquentUniqueStringPrimaryKeysTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $ta...
rint $table) { $table->ulid('id')->primary(); $table->ulid('foo'); $table->ulid('bar'); $table->timestamps(); }); Schema::create('songs', function (Blueprint $table) { $table->id(
table) { $table->uuid('id')->primary(); $table->string('email')->unique(); $table->string('name'); $table->timestamps(); }); Schema::create('posts', function (Bluep
{ "filepath": "tests/Integration/Database/EloquentUniqueStringPrimaryKeysTest.php", "language": "php", "file_size": 5231, "cut_index": 716, "middle_length": 229 }
Illuminate\Database\Events\MigrationsStarted; use Illuminate\Database\Events\MigrationStarted; use Illuminate\Database\Events\NoPendingMigrations; use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\Event; use Orchestra\Testbench\TestCase; class MigratorEventsTest extends TestCase { prote...
lass, 2); Event::assertDispatched(MigrationsEnded::class, 2); Event::assertDispatched(MigrationStarted::class, 2); Event::assertDispatched(MigrationEnded::class, 2); Event::assertDispatched(MigrationSkipped::class, 1); }
EventsAreFired() { Event::fake(); $this->artisan('migrate', $this->migrateOptions()); $this->artisan('migrate:rollback', $this->migrateOptions()); Event::assertDispatched(MigrationsStarted::c
{ "filepath": "tests/Integration/Database/MigratorEventsTest.php", "language": "php", "file_size": 6211, "cut_index": 716, "middle_length": 229 }
pace Illuminate\Tests\Integration\Database\EloquentMorphToTouchesTest; use DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentMorphToTouchesTest extends DatabaseTestCase ...
testNotNull() { $comment = (new Comment)->commentable()->associate(Post::first()); DB::enableQueryLog(); $comment->save(); $this->assertCount(2, DB::getQueryLog()); } public function testNull() {
}); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->nullableMorphs('commentable'); }); Post::create(); } public function
{ "filepath": "tests/Integration/Database/EloquentMorphToTouchesTest.php", "language": "php", "file_size": 1366, "cut_index": 524, "middle_length": 229 }
lluminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class EloquentPaginateTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->string('title'...
'.$i, ]); } $this->assertCount(15, Post::paginate(15, ['id', 'title'])); } public function testPaginationWithDistinct() { for ($i = 1; $i <= 3; $i++) { Post::create(['title' => 'Hello world']);
->increments('id'); $table->timestamps(); }); } public function testPaginationOnTopOfColumns() { for ($i = 1; $i <= 50; $i++) { Post::create([ 'title' => 'Title
{ "filepath": "tests/Integration/Database/EloquentPaginateTest.php", "language": "php", "file_size": 3201, "cut_index": 614, "middle_length": 229 }
te\Tests\Integration\Database\EloquentTouchParentWithGlobalScopeTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentTouchParentWithGlobalScop...
$table->string('title'); $table->timestamps(); }); } public function testBasicCreateAndRetrieve() { $post = Post::create(['title' => Str::random(), 'updated_at' => '2016-10-10 10:10:10']); $this->asse
$table->string('title'); $table->timestamps(); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->integer('post_id');
{ "filepath": "tests/Integration/Database/EloquentTouchParentWithGlobalScopeTest.php", "language": "php", "file_size": 1948, "cut_index": 537, "middle_length": 229 }
use PHPUnit\Framework\Attributes\DataProvider; class EloquentWhereHasTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); }); Schema::create('posts', function (Bluepri...
$table->increments('id'); $table->string('commentable_type'); $table->integer('commentable_id'); }); $user = User::create(); $post = tap((new Post(['public' => true]))->user()->associate($user))->save()
(Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_id'); $table->text('content'); }); Schema::create('comments', function (Blueprint $table) {
{ "filepath": "tests/Integration/Database/EloquentWhereHasTest.php", "language": "php", "file_size": 10901, "cut_index": 921, "middle_length": 229 }
te\Tests\Integration\Database\EloquentPivotWithoutTimestampTest; use Illuminate\Database\Eloquent\Attributes\UseFactory; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsT...
le::class) ->withPivot('notes') ->using(UserRole::class) ->withTimestamps(updatedAt: false); } } #[UseFactory(RoleFactory::class)] class Role extends Model { use HasFactory; public function users(): Belongs
; use Orchestra\Testbench\Factories\UserFactory; #[UseFactory(UserFactory::class)] class User extends Authenticatable { use HasFactory; public function roles(): BelongsToMany { return $this->belongsToMany(Ro
{ "filepath": "tests/Integration/Database/EloquentPivotWithoutTimestampTest.fixtures.php", "language": "php", "file_size": 1867, "cut_index": 537, "middle_length": 229 }
ase\Postgres; use PHPUnit\Framework\Attributes\RequiresOperatingSystem; use PHPUnit\Framework\Attributes\RequiresPhpExtension; use RuntimeException; #[RequiresOperatingSystem('Linux|Darwin')] #[RequiresPhpExtension('pdo_pgsql')] class EscapeTest extends PostgresTestCase { public function testEscapeInt() { ...
]->escape(true)); $this->assertSame('false', $this->app['db']->escape(false)); } public function testEscapeNull() { $this->assertSame('null', $this->app['db']->escape(null)); $this->assertSame('null', $this->app['db']->
ertSame('3.14159', $this->app['db']->escape(3.14159)); $this->assertSame('-3.14159', $this->app['db']->escape(-3.14159)); } public function testEscapeBool() { $this->assertSame('true', $this->app['db'
{ "filepath": "tests/Integration/Database/Postgres/EscapeTest.php", "language": "php", "file_size": 2216, "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 MailableWithoutSecuredEncodingTest extends MailableTestCase { ...
:new()->create([ 'name' => $given, ]); $mailable = new class($user) extends Mailable { public $theme = 'taylor'; public function __construct(public User $user) { //
SecuredEncoding(); } #[WithMigration] #[DataProvider('markdownEncodedTemplateDataProvider')] public function testItCanAssertMarkdownEncodedStringUsingTemplate($given, $expected) { $user = UserFactory:
{ "filepath": "tests/Integration/Mail/MailableWithoutSecuredEncodingTest.php", "language": "php", "file_size": 3502, "cut_index": 614, "middle_length": 229 }
t\Framework\Attributes\DataProvider; class MarkdownParserTest extends TestCase { /** {@inheritdoc} */ #[\Override] protected function tearDown(): void { Markdown::flushState(); EncodedHtmlString::flushState(); parent::tearDown(); } #[DataProvider('markdownDataProvider'...
r('markdownEncodedDataProvider')] public function testItCanParseMarkdownEncodedString($given, $expected) { tap(Markdown::parse($given, encoded: true), function ($html) use ($expected) { $this->assertInstanceOf(HtmlString::class,
ing::class, $html); $this->assertStringEqualsStringIgnoringLineEndings($expected.PHP_EOL, (string) $html); $this->assertSame((string) $html, (string) $html->toHtml()); }); } #[DataProvide
{ "filepath": "tests/Integration/Mail/MarkdownParserTest.php", "language": "php", "file_size": 7479, "cut_index": 716, "middle_length": 229 }
pace Illuminate\Tests\Integration\Mail; use Illuminate\Mail\Mailable; use Orchestra\Testbench\TestCase; class RenderingMailWithLocaleTest extends TestCase { protected function defineEnvironment($app) { $app['config']->set('app.locale', 'en'); $app['view']->addLocation(__DIR__.'/Fixtures'); ...
function testMailableRendersInSelectedLocale() { $mail = (new RenderedTestMail)->locale('es'); $this->assertStringContainsString('nombre', $mail->render()); } public function testMailableRendersInAppSelectedLocale() {
], ], ]); } public function testMailableRendersInDefaultLocale() { $mail = new RenderedTestMail; $this->assertStringContainsString('name', $mail->render()); } public
{ "filepath": "tests/Integration/Mail/RenderingMailWithLocaleTest.php", "language": "php", "file_size": 1282, "cut_index": 524, "middle_length": 229 }
lluminate\Mail\Mailable; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Mail; use Illuminate\Testing\Assert; use Orchestra\Testbench\TestCase; class SendingMailWithLocaleTest extends TestCase { protected function defineEnvironment($app) { $app['confi...
public function testMailIsSentWithDefaultLocale() { Mail::to('test@mail.com')->send(new TestMail); $this->assertStringContainsString('name', app('mailer')->getSymfonyTransport()->messages()[0]->toString() );
'*' => [ '*' => [ 'en' => ['nom' => 'name'], 'ar' => ['nom' => 'esm'], 'es' => ['nom' => 'nombre'], ], ], ]); }
{ "filepath": "tests/Integration/Mail/SendingMailWithLocaleTest.php", "language": "php", "file_size": 5757, "cut_index": 716, "middle_length": 229 }
$app['config']->set('mail.driver', 'array'); $app['view']->addNamespace('mail', __DIR__.'/Fixtures') ->addLocation(__DIR__.'/Fixtures'); } public function testMailIsSent() { $mailable = new BasicMailable(); $mailable ->assertHasSubject('My basic title') ...
('My basic content'); } public function testEmbed() { Mail::to('test@mail.com')->send($mailable = new EmbedMailable()); $mailable->assertSeeInHtml('Embed content: cid:'); $mailable->assertSeeInText('Embed content: ');
icMailableWithTextView(); $mailable ->assertHasSubject('My basic title') ->assertSeeInHtml('My basic content') ->assertSeeInText('My basic text view') ->assertDontSeeInText
{ "filepath": "tests/Integration/Mail/SendingMarkdownMailTest.php", "language": "php", "file_size": 10402, "cut_index": 921, "middle_length": 229 }
te\Tests\Integration\Mail; use Illuminate\Mail\Mailable; use Illuminate\Mail\SendQueuedMailable; use Illuminate\Queue\Middleware\RateLimited; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Queue; use Orchestra\Testbench\TestCase; class SendingQueuedMailTest extends ...
return $job->middleware[0] instanceof RateLimited; }); } public function testMailIsSentWhenRoutingQueue() { Queue::fake(); Queue::route(Mailable::class, 'mail-queue', 'mail-connection'); Mail::to('test@mail
function testMailIsSentWithDefaultLocale() { Queue::fake(); Mail::to('test@mail.com')->queue(new SendingQueuedMailTestMail); Queue::assertPushed(SendQueuedMailable::class, function ($job) {
{ "filepath": "tests/Integration/Mail/SendingQueuedMailTest.php", "language": "php", "file_size": 1826, "cut_index": 537, "middle_length": 229 }
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Foundation\Testing\LazilyRefreshDatabase; use Illuminate\Notifications\Events\NotificationSent; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notifiable; use Illuminate\Notifications\Noti...
hingDatabase() { Schema::dropIfExists('sent_message_users'); } public function testDispatchesNotificationSent() { $notificationWasSent = false; $user = SentMessageUser::create(); Event::listen(
base; protected function afterRefreshingDatabase() { Schema::create('sent_message_users', function (Blueprint $table) { $table->increments('id'); }); } protected function beforeRefres
{ "filepath": "tests/Integration/Mail/SentMessageMailTest.php", "language": "php", "file_size": 2435, "cut_index": 563, "middle_length": 229 }
pace Illuminate\Tests\Integration\Routing; use Illuminate\Routing\Attributes\Controllers\Authorize; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class AuthorizeMiddlewareAttributeTest extends TestCase { public function test_attribute_is_respected(): void { $route = Route::ge...
$this->assertEquals([ 'Illuminate\Auth\Middleware\Authorize:all', 'Illuminate\Auth\Middleware\Authorize:except-index,a,b', ], $route->controllerMiddleware()); } } #[Authorize('all')] #[Authorize('only-index', 'a', on
Authorize:only-index,a', 'Illuminate\Auth\Middleware\Authorize:also-index', ], $route->controllerMiddleware()); $route = Route::get('/', [AuthorizeMiddlewareAttributeController::class, 'show']);
{ "filepath": "tests/Integration/Routing/AuthorizeMiddlewareAttributeTest.php", "language": "php", "file_size": 1287, "cut_index": 524, "middle_length": 229 }
oid { unset($this->routeCollection, $this->router); parent::tearDown(); } /** * @return \Illuminate\Routing\CompiledRouteCollection */ protected function collection() { return $this->routeCollection->toCompiledRouteCollection($this->router, $this->app); } ...
ET', 'foo', [ 'uses' => 'FooController@index', 'as' => 'foo_index', ])); $this->assertInstanceOf(Route::class, $outputRoute); $this->assertEquals($inputRoute, $outputRoute); } public function testRo
o_index', ])); $this->assertCount(1, $this->collection()); } public function testRouteCollectionAddReturnsTheRoute() { $outputRoute = $this->collection()->add($inputRoute = $this->newRoute('G
{ "filepath": "tests/Integration/Routing/CompiledRouteCollectionTest.php", "language": "php", "file_size": 21401, "cut_index": 1331, "middle_length": 229 }
estra\Testbench\TestCase; class FallbackRouteTest extends TestCase { public function testBasicFallback() { Route::fallback(function () { return response('fallback', 404); }); Route::get('one', function () { return 'one'; }); $this->assertStringC...
nse('fallback', 404); }); Route::get('one', function () { return 'one'; }); }); $this->assertStringContainsString('one', $this->get('/prefix/one')->getContent()); $this->assertSt
->get('/non-existing')->getStatusCode()); } public function testFallbackWithPrefix() { Route::group(['prefix' => 'prefix'], function () { Route::fallback(function () { return respo
{ "filepath": "tests/Integration/Routing/FallbackRouteTest.php", "language": "php", "file_size": 3262, "cut_index": 614, "middle_length": 229 }
ng; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class FluentRoutingTest extends TestCase { public static $value = ''; public function testMiddlewareRunWhenRegisteredAsArrayOrParams() { $controller = function () { return 'Hello World'; }; Ro...
re2::class]); Route::middleware(Middleware::class) ->get('before_after', $controller) ->middleware([Middleware2::class]); Route::middleware(Middleware::class) ->middleware(Middleware2::class)
e2::class); Route::middleware([Middleware::class, Middleware2::class]) ->get('before_array', $controller); Route::get('after_array', $controller) ->middleware([Middleware::class, Middlewa
{ "filepath": "tests/Integration/Routing/FluentRoutingTest.php", "language": "php", "file_size": 2422, "cut_index": 563, "middle_length": 229 }
hp namespace Illuminate\Tests\Integration\Routing; use Illuminate\Routing\Controllers\HasMiddleware; use Illuminate\Routing\Controllers\Middleware; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class HasMiddlewareTest extends TestCase { public function test_has_middleware_is_respected()...
tatic function middleware() { return [ new Middleware('all'), (new Middleware('only-index'))->only('index'), (new Middleware('except-index'))->except('index'), ]; } public function index()
ute::get('/', [HasMiddlewareTestController::class, 'show']); $this->assertEquals(['all', 'except-index'], $route->controllerMiddleware()); } } class HasMiddlewareTestController implements HasMiddleware { public s
{ "filepath": "tests/Integration/Routing/HasMiddlewareTest.php", "language": "php", "file_size": 1063, "cut_index": 515, "middle_length": 229 }
estra\Testbench\TestCase; class ImplicitBackedEnumRouteBindingTest extends TestCase { protected function defineEnvironment($app): void { $app['config']->set(['app.key' => 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF']); } public function testWithRouteCachingEnabled() { $this->defineCacheRoute...
'/categories/fruits'); $response->assertSee('fruits'); $response = $this->get('/categories/people'); $response->assertSee('people'); $response = $this->get('/categories/cars'); $response->assertNotFound(404);
middleware('web'); Route::get('/categories-default/{category?}', function (CategoryBackedEnum \$category = CategoryBackedEnum::Fruits) { return \$category->value; })->middleware('web'); PHP); $response = $this->get(
{ "filepath": "tests/Integration/Routing/ImplicitBackedEnumRouteBindingTest.php", "language": "php", "file_size": 3058, "cut_index": 614, "middle_length": 229 }
g; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use Orchestra\Testbench\TestCase; #[WithConfig('app.key', 'AckfSECXIvnK5r28GVIWUAxmbBSjTsmF')] class ImplicitModelRouteBindingTest extends TestCase { use InteractsWithPublishedFiles; protected $files = [ 'routes/testbench.php', ]; ...
$table->timestamps(); }); Schema::create('tags', function (Blueprint $table) { $table->ulid('id')->primary(); $table->string('slug'); $table->integer('post_id'); $table->timestamps(
e'); $table->timestamps(); $table->softDeletes(); }); Schema::create('posts', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id');
{ "filepath": "tests/Integration/Routing/ImplicitModelRouteBindingTest.php", "language": "php", "file_size": 10828, "cut_index": 921, "middle_length": 229 }
?php namespace Illuminate\Tests\Integration\Routing; use Illuminate\Routing\Attributes\Controllers\Middleware; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class MiddlewareAttributeTest extends TestCase { public function test_attribute_middleware_is_respected(): void { $rou...
} } #[Middleware('all')] #[Middleware('only-index', only: ['index'])] #[Middleware('except-index', except: ['index'])] class MiddlewareAttributeController { #[Middleware('also-index')] public function index(): void { // ... }
ontrollerMiddleware()); $route = Route::get('/', [MiddlewareAttributeController::class, 'show']); $this->assertEquals([ 'all', 'except-index', ], $route->controllerMiddleware());
{ "filepath": "tests/Integration/Routing/MiddlewareAttributeTest.php", "language": "php", "file_size": 1059, "cut_index": 513, "middle_length": 229 }
ponse = $this->get('test-route', ['Precognition' => 'true']); $response->assertNoContent(); $response->assertHeader('Precognition-Success', 'true'); $this->assertTrue($this->app['ClassWasInstantiated']); } public function testItCanCheckPrecognitiveStateOnTheRequest() { Rout...
True(request()->isPrecognitive()); } public function testItReturnsTheEmptyResponseWhenNotBailing() { Route::get('test-route', function () { precognitive(function () { // }); fail();
precognitive')); $this->assertFalse(request()->isPrecognitive()); $this->get('test-route', ['Precognition' => 'true']); $this->assertTrue(request()->attributes->get('precognitive')); $this->assert
{ "filepath": "tests/Integration/Routing/PrecognitionTest.php", "language": "php", "file_size": 55984, "cut_index": 2151, "middle_length": 229 }
<?php namespace Illuminate\Tests\Integration\Routing; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Session\SessionServiceProvider; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class PreviousUrlTest extends TestCase { public function testPreviousUrlWithoutSession() { ...
return $provider !== SessionServiceProvider::class; }); } } class DummyFormRequest extends FormRequest { public function rules() { return [ 'foo' => [ 'required', 'string',
als(422, $response->status()); } protected function getApplicationProviders($app) { $providers = parent::getApplicationProviders($app); return array_filter($providers, function ($provider) {
{ "filepath": "tests/Integration/Routing/PreviousUrlTest.php", "language": "php", "file_size": 1025, "cut_index": 512, "middle_length": 229 }
space Illuminate\Tests\Integration\Routing; use Illuminate\Contracts\Support\Responsable; use Illuminate\Support\Facades\Route; use Orchestra\Testbench\TestCase; class ResponsableTest extends TestCase { public function testResponsableObjectsAreRendered() { Route::get('/responsable', function () { ...
$this->assertSame('hello world', $response->getContent()); } } class TestResponsableResponse implements Responsable { public function toResponse($request) { return response('hello world', 201, ['X-Test-Header' => 'Taylor']); }
or', $response->headers->get('X-Test-Header'));
{ "filepath": "tests/Integration/Routing/ResponsableTest.php", "language": "php", "file_size": 833, "cut_index": 523, "middle_length": 52 }
minate\Tests\Integration\Routing\Fixtures\ApiResourceTaskController; use Illuminate\Tests\Integration\Routing\Fixtures\ApiResourceTestController; use Orchestra\Testbench\TestCase; class RouteApiResourceTest extends TestCase { public function testApiResource() { Route::apiResource('tests', ApiResourceTe...
->assertEquals(200, $response->getStatusCode()); $this->assertSame('I`m show', $response->getContent()); $response = $this->put('/tests/1'); $this->assertEquals(200, $response->getStatusCode()); $this->assertSame('I`m updat
$response = $this->post('/tests'); $this->assertEquals(200, $response->getStatusCode()); $this->assertSame('I`m store', $response->getContent()); $response = $this->get('/tests/1'); $this
{ "filepath": "tests/Integration/Routing/RouteApiResourceTest.php", "language": "php", "file_size": 4637, "cut_index": 614, "middle_length": 229 }
ase\MySql; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; class DatabaseEloquentMySqlIntegrationTest extends MySqlTestCase { protected function afterRefreshingDatabase() { if (! Schema::hasTabl...
Schema::drop('database_eloquent_mysql_integration_users'); } public function testCreateOrFirst() { $user1 = DatabaseEloquentMySqlIntegrationUser::createOrFirst(['email' => 'taylorotwell@gmail.com']); $this->assertSame('tayloro
$table->string('name')->nullable(); $table->string('email')->unique(); $table->timestamps(); }); } } protected function destroyDatabaseMigrations() {
{ "filepath": "tests/Integration/Database/MySql/DatabaseEloquentMySqlIntegrationTest.php", "language": "php", "file_size": 2828, "cut_index": 563, "middle_length": 229 }