prefix
stringlengths
512
512
suffix
stringlengths
256
256
middle
stringlengths
14
229
meta
dict
Default(); } /** * Setup the database schema. * * @return void */ public function createSchema() { $this->schema()->create('users', function ($table) { $table->increments('id'); $table->string('name'); $table->string('options')->nullable()...
$table->foreignId('commentable_id'); $table->string('commentable_type'); $table->foreignId('user_id'); $table->string('body'); $table->softDeletes(); $table->timestamps(); }); $
$table->string('title'); $table->softDeletes(); $table->timestamps(); }); $this->schema()->create('comments', function ($table) { $table->increments('id');
{ "filepath": "tests/Database/DatabaseEloquentFactoryTest.php", "language": "php", "file_size": 47155, "cut_index": 2151, "middle_length": 229 }
mestamp('birthday', 6)->nullable(); $table->timestamps(); }); $this->schema($connection)->create('unique_users', function ($table) { $table->increments('id'); $table->string('name')->nullable(); // Unique constraint will be applied...
end_id'); $table->integer('friend_level_id')->nullable(); }); $this->schema($connection)->create('posts', function ($table) { $table->increments('id'); $table->integer('user_id');
6)->nullable(); $table->timestamps(); }); $this->schema($connection)->create('friends', function ($table) { $table->integer('user_id'); $table->integer('fri
{ "filepath": "tests/Database/DatabaseEloquentIntegrationTest.php", "language": "php", "file_size": 117606, "cut_index": 3790, "middle_length": 229 }
nate\Database\Eloquent\Model; use PHPUnit\Framework\TestCase; class DatabaseEloquentLocalScopesTest extends TestCase { protected function setUp(): void { parent::setUp(); tap(new DB)->addConnection([ 'driver' => 'sqlite', 'database' => ':memory:', ])->bootEloque...
onExistentLocalScope')); } public function testLocalScopeIsApplied() { $model = new EloquentLocalScopesTestModel; $query = $model->newQuery()->active(); $this->assertSame('select * from "table" where "active" = ?', $qu
{ $model = new EloquentLocalScopesTestModel; $this->assertTrue($model->hasNamedScope('active')); $this->assertTrue($model->hasNamedScope('type')); $this->assertFalse($model->hasNamedScope('n
{ "filepath": "tests/Database/DatabaseEloquentLocalScopesTest.php", "language": "php", "file_size": 3124, "cut_index": 614, "middle_length": 229 }
crements('id'); }); $this->schema()->create('logins', function ($table) { $table->increments('id'); $table->foreignId('user_id'); $table->dateTime('deleted_at')->nullable(); }); $this->schema()->create('states', function ($table) { $table...
abase schema. * * @return void */ protected function tearDown(): void { $this->schema()->drop('users'); $this->schema()->drop('logins'); $this->schema()->drop('states'); $this->schema()->drop('prices')
his->schema()->create('prices', function ($table) { $table->increments('id'); $table->dateTime('published_at'); $table->foreignId('user_id'); }); } /** * Tear down the dat
{ "filepath": "tests/Database/DatabaseEloquentHasOneOfManyTest.php", "language": "php", "file_size": 23418, "cut_index": 1331, "middle_length": 229 }
te\Tests\Database; use Illuminate\Database\Connection; use Illuminate\Database\Query\Processors\MySqlProcessor; use Illuminate\Database\Schema\Grammars\MySqlGrammar; use Illuminate\Database\Schema\MySqlBuilder; use Mockery as m; use PHPUnit\Framework\TestCase; class DatabaseMySQLSchemaBuilderTest extends TestCase { ...
$connection->shouldReceive('getTablePrefix')->once()->andReturn('prefix_'); $connection->shouldReceive('scalar')->once()->with('sql')->andReturn(1); $this->assertTrue($builder->hasTable('table')); } public function testGetCo
->andReturn('db'); $connection->shouldReceive('getSchemaGrammar')->andReturn($grammar); $builder = new MySqlBuilder($connection); $grammar->shouldReceive('compileTableExists')->once()->andReturn('sql');
{ "filepath": "tests/Database/DatabaseMySQLSchemaBuilderTest.php", "language": "php", "file_size": 1965, "cut_index": 537, "middle_length": 229 }
$this->assertCount(3, $manager->getPendingTransactions()); $this->assertSame('default', $manager->getPendingTransactions()[0]->connection); $this->assertEquals(1, $manager->getPendingTransactions()[0]->level); $this->assertSame('default', $manager->getPendingTransactions()[1]->connecti...
begin('default', 2); $manager->begin('admin', 1); $manager->rollback('default', 1); $this->assertCount(2, $manager->getPendingTransactions()); $this->assertSame('default', $manager->getPendingTransactions()[0]->connection
quals(1, $manager->getPendingTransactions()[2]->level); } public function testRollingBackTransactions() { $manager = new DatabaseTransactionsManager; $manager->begin('default', 1); $manager->
{ "filepath": "tests/Database/DatabaseTransactionsManagerTest.php", "language": "php", "file_size": 10688, "cut_index": 921, "middle_length": 229 }
Case; use Throwable; class DatabaseTransactionsTest extends TestCase { /** * Setup the database schema. * * @return void */ protected function setUp(): void { $db = new DB; $db->addConnection([ 'driver' => 'sqlite', 'database' => ':memory:', ...
->increments('id'); $table->string('name')->nullable(); $table->string('value')->nullable(); }); } } /** * Tear down the database schema. * * @return void */ protected fun
teSchema(); } protected function createSchema() { foreach (['default', 'second_connection'] as $connection) { $this->schema($connection)->create('users', function ($table) { $table
{ "filepath": "tests/Database/DatabaseTransactionsTest.php", "language": "php", "file_size": 8880, "cut_index": 716, "middle_length": 229 }
Database\Eloquent\Collection; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Query\Builder as QueryBuilder; use Mockery as m; use PHPUnit\Framework\TestCase; class EloquentHasOneOrManyDeprecationTest...
= new HasOneOrManyDeprecationModelStub; $model2->id = null; $relation->getRelated()->shouldReceive('newCollection')->andReturnUsing(function ($array) { return new Collection($array); }); $models = $relation->ma
; $result1->foreign_key = 1; $result2 = new HasOneOrManyDeprecationModelStub; $result2->foreign_key = ''; $model1 = new HasOneOrManyDeprecationModelStub; $model1->id = 1; $model2
{ "filepath": "tests/Database/EloquentHasOneOrManyDeprecationTest.php", "language": "php", "file_size": 3538, "cut_index": 614, "middle_length": 229 }
loquent\MassAssignmentException; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model as Eloquent; use Illuminate\Database\Schema\Blueprint; use InvalidArgumentException; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; #[Group('integration')] class EloquentModelCustomC...
{ $this->schema()->create('casting_table', function (Blueprint $table) { $table->increments('id'); $table->string('address_line_one'); $table->string('address_line_two'); $table->integer('amount');
y:', ]); $db->bootEloquent(); $db->setAsGlobal(); $this->createSchema(); } /** * Setup the database schema. * * @return void */ public function createSchema()
{ "filepath": "tests/Database/EloquentModelCustomCastingTest.php", "language": "php", "file_size": 15192, "cut_index": 921, "middle_length": 229 }
e 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 pending; case done; } e...
self::done => 'done status description' }; } public function toArray() { return [ 'name' => $this->name, 'value' => $this->value, 'description' => $this->description(), ];
self::pending => 'pending status description',
{ "filepath": "tests/Database/Enums.php", "language": "php", "file_size": 876, "cut_index": 559, "middle_length": 52 }
luminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Grammars\MySqlGrammar; use Illuminate\Database\Query\Processors\Processor; use InvalidArgumentException; use Mockery as m; use PHPUnit\Framework\TestCase; class DatabaseMySqlQueryGrammarTest extends TestCase { public...
ame('select * from "users" where \'Hello\\\'World?\' IS NOT NULL AND "email" = \'foo\'', $query); } public function testTimeout() { $builder = $this->getBuilder(); $builder->select('*')->from('users')->where('email', 'like', '%
SqlGrammar($connection); $query = $grammar->substituteBindingsIntoRawSql( 'select * from "users" where \'Hello\\\'World?\' IS NOT NULL AND "email" = ?', ['foo'], ); $this->assertS
{ "filepath": "tests/Database/DatabaseMySqlQueryGrammarTest.php", "language": "php", "file_size": 2836, "cut_index": 563, "middle_length": 229 }
{ $blueprint = new Blueprint($this->getConnection(), 'users'); $blueprint->id()->from(100); $blueprint->string('name')->from(200); $statements = $blueprint->toSql(); $this->assertEquals([ 'alter table `users` add `id` bigint unsigned not null auto_increment primary...
utf8_unicode_ci'); $blueprint = new Blueprint($conn, 'users'); $blueprint->create(); $blueprint->increments('id'); $blueprint->string('email'); $blueprint->engine('InnoDB'); $statements = $blueprint->toSql(
eCreateTable() { $conn = $this->getConnection(); $conn->shouldReceive('getConfig')->once()->with('charset')->andReturn('utf8'); $conn->shouldReceive('getConfig')->once()->with('collation')->andReturn('
{ "filepath": "tests/Database/DatabaseMySqlSchemaGrammarTest.php", "language": "php", "file_size": 71525, "cut_index": 3790, "middle_length": 229 }
uminate\Foundation\Application; use Mockery as m; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\BufferedOutput; class PruneCommandTest extends TestCase { protected function setUp(): void { parent::setUp(); Application::setI...
tainer->alias(DispatcherContract::class, 'events'); } public function testPrunableModelAndExceptWithEachOther(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('The --models and -
Application::class, )(); $container->useAppPath(__DIR__.'/Pruning'); $container->singleton(DispatcherContract::class, function () { return new Dispatcher(); }); $con
{ "filepath": "tests/Database/PruneCommandTest.php", "language": "php", "file_size": 9577, "cut_index": 921, "middle_length": 229 }
PDO; use PHPUnit\Framework\TestCase; class QueryDurationThresholdTest extends TestCase { /** * @var \Illuminate\Support\Carbon */ protected $now; protected function tearDown(): void { Carbon::setTestNow(); parent::tearDown(); } public function testItCanHandleReachi...
1); $this->assertSame(0, $called); $connection->logQuery('xxxx', [], 0.1); $this->assertSame(1, $called); } public function testItIsOnlyCalledOnce() { $connection = new Connection(new PDO('sqlite::memory:'));
onnection->whenQueryingForLongerThan(CarbonInterval::milliseconds(1.1), function () use (&$called) { $called++; }); $connection->logQuery('xxxx', [], 1.0); $connection->logQuery('xxxx', [], 0.
{ "filepath": "tests/Database/QueryDurationThresholdTest.php", "language": "php", "file_size": 7756, "cut_index": 716, "middle_length": 229 }
uminate\Contracts\Events\Dispatcher; use Illuminate\Database\ConnectionResolverInterface; use Illuminate\Database\Console\Seeds\SeedCommand; use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Seeder; use Illuminate\Events\NullDispatcher; use Illumin...
$seeder = m::mock(Seeder::class); $seeder->shouldReceive('setContainer')->once()->andReturnSelf(); $seeder->shouldReceive('setCommand')->once()->andReturnSelf(); $seeder->shouldReceive('__invoke')->once(); $resolver
tends TestCase { public function testHandle() { $input = new ArrayInput(['--force' => true, '--database' => 'sqlite']); $output = new NullOutput; $outputStyle = new OutputStyle($input, $output);
{ "filepath": "tests/Database/SeedCommandTest.php", "language": "php", "file_size": 5447, "cut_index": 716, "middle_length": 229 }
pace Illuminate\Tests\Database; use Illuminate\Database\Connection; use Illuminate\Database\Schema\Grammars\SqlServerGrammar; use Illuminate\Database\Schema\SqlServerBuilder; use Mockery as m; use PHPUnit\Framework\TestCase; class SqlServerBuilderTest extends TestCase { public function testCreateDatabase() { ...
ase('my_temporary_database_a'); } public function testDropDatabaseIfExists() { $connection = m::mock(Connection::class); $grammar = new SqlServerGrammar($connection); $connection->shouldReceive('getSchemaGrammar')->onc
$connection->shouldReceive('statement')->once()->with( 'create database "my_temporary_database_a"' )->andReturn(true); $builder = new SqlServerBuilder($connection); $builder->createDatab
{ "filepath": "tests/Database/SqlServerBuilderTest.php", "language": "php", "file_size": 1321, "cut_index": 524, "middle_length": 229 }
te\Tests\Database; use Illuminate\Database\Console\Migrations\TableGuesser; use PHPUnit\Framework\TestCase; class TableGuesserTest extends TestCase { public function testMigrationIsProperlyParsed() { [$table, $create] = TableGuesser::guess('create_users_table'); $this->assertSame('users', $tab...
ser::guess('change_status_column_in_users_table'); $this->assertSame('users', $table); $this->assertFalse($create); [$table, $create] = TableGuesser::guess('drop_status_column_from_users_table'); $this->assertSame('users',
False($create); [$table, $create] = TableGuesser::guess('add_is_sent_to_crm_column_to_users_table'); $this->assertSame('users', $table); $this->assertFalse($create); [$table, $create] = TableGues
{ "filepath": "tests/Database/TableGuesserTest.php", "language": "php", "file_size": 1969, "cut_index": 537, "middle_length": 229 }
tabase\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * The database connection that should be used by the migration. * * @var string */ protected $connection = 'sqlite3'; /** * Run the migrations. * * @return void ...
'); $table->longText('exception'); $table->timestamp('failed_at')->useCurrent(); $table->index(['connection', 'queue', 'failed_at']); }); } /** * Reverse the migrations. * * @return void
ring('queue'); $table->longText('payload
{ "filepath": "tests/Database/migrations/connection_configured/2022_02_21_000000_create_failed_jobs_table.php", "language": "php", "file_size": 985, "cut_index": 582, "middle_length": 52 }
ations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::connection('sqlite3')->create('jobs', function (Blueprint $table) ...
); $table->unsignedInteger('available_at'); $table->unsignedInteger('created_at'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::connect
$table->unsignedInteger('reserved_at')->nullable(
{ "filepath": "tests/Database/migrations/connection_configured/2022_02_21_120000_create_jobs_table.php", "language": "php", "file_size": 902, "cut_index": 547, "middle_length": 52 }
namespace Illuminate\Tests\Database\stubs; use Illuminate\Contracts\Database\Eloquent\CastsAttributes; use Illuminate\Database\Eloquent\Model; class TestCast implements CastsAttributes { /** * @param Model $model * @param string $key * @param mixed $value * @param array $attributes ...
am string $key * @param mixed $value * @param array $attributes * @return array */ public function set(Model $model, string $key, mixed $value, array $attributes) { if (! $value instanceof TestValueObject) {
ll; } $value = json_decode($value, true); if (! is_array($value)) { return null; } return TestValueObject::make($value); } /** * @param Model $model * @par
{ "filepath": "tests/Database/stubs/TestCast.php", "language": "php", "file_size": 1162, "cut_index": 518, "middle_length": 229 }
pace Illuminate\Tests\Integration\Generators; class CastMakeCommandTest extends TestCase { protected $files = [ 'app/Casts/Foo.php', ]; public function testItCanGenerateCastFile() { $this->artisan('make:cast', ['name' => 'Foo']) ->assertExitCode(0); $this->assertFi...
public function testItCanGenerateInboundCastFile() { $this->artisan('make:cast', ['name' => 'Foo', '--inbound' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Casts;', 'u
lic function get(Model $model, string $key, mixed $value, array $attributes): mixed', 'public function set(Model $model, string $key, mixed $value, array $attributes): mixed', ], 'app/Casts/Foo.php'); }
{ "filepath": "tests/Integration/Generators/CastMakeCommandTest.php", "language": "php", "file_size": 1279, "cut_index": 524, "middle_length": 229 }
TestCase { protected array $files = [ 'app/Reverb.php', 'app/Notification.php', ]; public function testItCanGenerateClassFile() { $this->artisan('make:class', ['name' => 'Reverb']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App;'...
nvokable' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace App;', 'class Notification', 'public function __construct()', 'public function __invoke()', ], 'app
rtisan('make:class', ['name' => 'Notification', '--i
{ "filepath": "tests/Integration/Generators/ClassMakeCommandTest.php", "language": "php", "file_size": 943, "cut_index": 606, "middle_length": 52 }
Case { protected $files = [ 'app/View/Components/Foo.php', 'resources/views/components/foo.blade.php', 'tests/Feature/View/Components/FooTest.php', 'resources/views/custom/path/foo.blade.php', 'app/View/Components/Nested/Foo.php', 'resources/views/components/nested/fo...
turn view('components.foo');", ], 'app/View/Components/Foo.php'); $this->assertFilenameExists('resources/views/components/foo.blade.php'); $this->assertFilenameNotExists('tests/Feature/View/Components/FooTest.php'); } publ
'Foo']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\View\Components;', 'use Illuminate\View\Component;', 'class Foo extends Component', "re
{ "filepath": "tests/Integration/Generators/ComponentMakeCommandTest.php", "language": "php", "file_size": 3956, "cut_index": 614, "middle_length": 229 }
pace Illuminate\Tests\Integration\Generators; class ConsoleMakeCommandTest extends TestCase { protected $files = [ 'app/Console/Commands/FooCommand.php', ]; public function testItCanGenerateConsoleFile() { $this->artisan('make:command', ['name' => 'FooCommand']) ->assertExi...
'app/Console/Commands/FooCommand.php'); } public function testItCanGenerateConsoleFileWithCommandOption() { $this->artisan('make:command', ['name' => 'FooCommand', '--command' => 'foo:bar']) ->assertExitCode(0); $
Attributes\Signature;', 'use Illuminate\Console\Command;', "#[Signature('app:foo-command')]", "#[Description('Command description')]", 'class FooCommand extends Command', ],
{ "filepath": "tests/Integration/Generators/ConsoleMakeCommandTest.php", "language": "php", "file_size": 1451, "cut_index": 524, "middle_length": 229 }
rollers/FooController.php', 'app/Models/Bar.php', 'app/Models/Foo.php', 'tests/Feature/Http/Controllers/FooControllerTest.php', ]; public function testItCanGenerateControllerFile() { $this->artisan('make:controller', ['name' => 'FooController']) ->assertExitCode(...
hp'); $this->assertFilenameNotExists('tests/Feature/Http/Controllers/FooControllerTest.php'); } public function testItCanGenerateControllerFileWhenBaseControllerExists() { $this->artisan('make:controller', ['name' => 'Controll
rollers/FooController.php'); $this->assertFileNotContains([ 'class FooController extends Controller', 'public function __invoke(Request $request)', ], 'app/Http/Controllers/FooController.p
{ "filepath": "tests/Integration/Generators/ControllerMakeCommandTest.php", "language": "php", "file_size": 7699, "cut_index": 716, "middle_length": 229 }
inate\Tests\Integration\Generators\TestCase; class EnumMakeCommandTest extends TestCase { protected $files = [ 'app/IntEnum.php', 'app/StatusEnum.php', 'app/StringEnum.php', 'app/*/OrderStatusEnum.php', ]; public function testItCanGenerateEnumFile() { $this->art...
Contains([ 'namespace App;', 'enum StringEnum: string', ], 'app/StringEnum.php'); } public function testItCanGenerateEnumFileWithInt() { $this->artisan('make:enum', ['name' => 'IntEnum', '--int' => true]
tatusEnum.php'); } public function testItCanGenerateEnumFileWithString() { $this->artisan('make:enum', ['name' => 'StringEnum', '--string' => true]) ->assertExitCode(0); $this->assertFile
{ "filepath": "tests/Integration/Generators/EnumMakeCommandTest.php", "language": "php", "file_size": 2441, "cut_index": 563, "middle_length": 229 }
ators; class ExceptionMakeCommandTest extends TestCase { protected $files = [ 'app/Exceptions/FooException.php', ]; public function testItCanGenerateExceptionFile() { $this->artisan('make:exception', ['name' => 'FooException']) ->assertExitCode(0); $this->assertFil...
ortOption() { $this->artisan('make:exception', ['name' => 'FooException', '--report' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Exceptions;', 'use Exception;',
this->assertFileNotContains([ 'public function report()', 'public function render($request)', ], 'app/Exceptions/FooException.php'); } public function testItCanGenerateExceptionFileWithRep
{ "filepath": "tests/Integration/Generators/ExceptionMakeCommandTest.php", "language": "php", "file_size": 2472, "cut_index": 563, "middle_length": 229 }
ion\Generators; use Illuminate\Tests\Integration\Generators\TestCase; class InterfaceMakeCommandTest extends TestCase { protected $files = [ 'app/Gateway.php', 'app/Contracts/Gateway.php', 'app/Interfaces/Gateway.php', ]; public function testItCanGenerateInterfaceFile() { ...
$files */ $files = $this->app['files']; $files->ensureDirectoryExists($interfacesFolderPath); $this->artisan('make:interface', ['name' => 'Gateway']) ->assertExitCode(0); $this->assertFileContains([
], 'app/Gateway.php'); } public function testItCanGenerateInterfaceFileWhenContractsFolderExists() { $interfacesFolderPath = app_path('Contracts'); /** @var \Illuminate\Filesystem\Filesystem
{ "filepath": "tests/Integration/Generators/InterfaceMakeCommandTest.php", "language": "php", "file_size": 1811, "cut_index": 537, "middle_length": 229 }
te\Tests\Integration\Generators; class JobMakeCommandTest extends TestCase { protected $files = [ 'app/Jobs/FooCreated.php', 'tests/Feature/Jobs/FooCreatedTest.php', ]; public function testItCanGenerateJobFile() { $this->artisan('make:job', ['name' => 'FooCreated']) ...
} public function testItCanGenerateSyncJobFile() { $this->artisan('make:job', ['name' => 'FooCreated', '--sync' => true]) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Jobs;',
Queue\Queueable;', 'class FooCreated implements ShouldQueue', 'use Queueable;', ], 'app/Jobs/FooCreated.php'); $this->assertFilenameNotExists('tests/Feature/Jobs/FooCreatedTest.php');
{ "filepath": "tests/Integration/Generators/JobMakeCommandTest.php", "language": "php", "file_size": 1810, "cut_index": 537, "middle_length": 229 }
ddlewareMakeCommandTest extends TestCase { protected $files = [ 'app/Jobs/Middleware/Foo.php', 'tests/Feature/Jobs/Middleware/FooTest.php', ]; public function testItCanGenerateJobFile() { $this->artisan('make:job-middleware', ['name' => 'Foo']) ->assertExitCode(0); ...
public function testItCanGenerateJobFileWithTest() { $this->artisan('make:job-middleware', ['name' => 'Foo', '--test' => true]) ->assertExitCode(0); $this->assertFilenameExists('app/Jobs/Middleware/Foo.php'); $th
ests/Feature/Jobs/Middleware/FooTest.php'); }
{ "filepath": "tests/Integration/Generators/JobMiddlewareMakeCommandTest.php", "language": "php", "file_size": 969, "cut_index": 582, "middle_length": 52 }
ase { protected $files = [ 'app/Listeners/FooListener.php', 'tests/Feature/Listeners/FooListenerTest.php', ]; public function testItCanGenerateListenerFile() { $this->artisan('make:listener', ['name' => 'FooListener']) ->assertExitCode(0); $this->assertFileC...
ke:listener', ['name' => 'FooListener', '--event' => 'FooListenerCreated']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Listeners;', 'use App\Events\FooListenerCreated;', 'class F
his->assertFileNotContains([ 'class FooListener implements ShouldQueue', ], 'app/Listeners/FooListener.php'); } public function testItCanGenerateListenerFileForEvent() { $this->artisan('ma
{ "filepath": "tests/Integration/Generators/ListenerMakeCommandTest.php", "language": "php", "file_size": 3893, "cut_index": 614, "middle_length": 229 }
'resources/views/mail/*.blade.php', 'tests/Feature/Mail/*.php', ]; public function testItCanGenerateMailFile() { $this->artisan('make:mail', ['name' => 'FooMail']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Mail;', 'use ...
foo-mail']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Mail;', 'use Illuminate\Mail\Mailable;', 'class FooMail extends Mailable', 'return new Content(', "
$this->assertFilenameNotExists('tests/Feature/Mail/FooMailTest.php'); } public function testItCanGenerateMailFileWithMarkdownOption() { $this->artisan('make:mail', ['name' => 'FooMail', '--markdown' => '
{ "filepath": "tests/Integration/Generators/MailMakeCommandTest.php", "language": "php", "file_size": 5741, "cut_index": 716, "middle_length": 229 }
namespace Illuminate\Tests\Integration\Generators; class MiddlewareMakeCommandTest extends TestCase { protected $files = [ 'app/Http/Middleware/Foo.php', 'tests/Feature/Http/Middleware/FooTest.php', ]; public function testItCanGenerateMiddlewareFile() { $this->artisan('make:mi...
enameNotExists('tests/Feature/Http/Middleware/FooTest.php'); } public function testItCanGenerateMiddlewareFile_with_tests() { $this->artisan('make:middleware', ['name' => 'Foo', '--test' => true]) ->assertExitCode(0);
lluminate\Http\Request;', 'class Foo', 'public function handle(Request $request, Closure $next)', 'return $next($request);', ], 'app/Http/Middleware/Foo.php'); $this->assertFil
{ "filepath": "tests/Integration/Generators/MiddlewareMakeCommandTest.php", "language": "php", "file_size": 1157, "cut_index": 518, "middle_length": 229 }
ators; class MigrateMakeCommandTest extends TestCase { public function testItCanGenerateMigrationFile() { $this->artisan('make:migration', ['name' => 'AddBarToFoosTable']) ->assertExitCode(0); $this->assertMigrationFileContains([ 'use Illuminate\Database\Migrations\Migr...
ns([ 'use Illuminate\Database\Migrations\Migration;', 'return new class extends Migration', 'Schema::table(\'foobar\', function (Blueprint $table) {', ], 'add_bar_to_foos_table.php'); } public function t
ion testItCanGenerateMigrationFileWIthTableOption() { $this->artisan('make:migration', ['name' => 'AddBarToFoosTable', '--table' => 'foobar']) ->assertExitCode(0); $this->assertMigrationFileContai
{ "filepath": "tests/Integration/Generators/MigrateMakeCommandTest.php", "language": "php", "file_size": 2042, "cut_index": 563, "middle_length": 229 }
rations/*_create_foos_table.php', 'database/seeders/FooSeeder.php', 'tests/Feature/Models/FooTest.php', ]; public function testItCanGenerateModelFile() { $this->artisan('make:model', ['name' => 'Foo']) ->assertExitCode(0); $this->assertFileContains([ ...
sFactory;', ], 'app/Models/Foo.php'); $this->assertFilenameNotExists('app/Http/Controllers/FooController.php'); $this->assertFilenameNotExists('database/factories/FooFactory.php'); $this->assertFilenameNotExists('database/s
ins([ '{{ factoryImport }}', 'use Illuminate\Database\Eloquent\Factories\HasFactory;', '{{ factory }}', '/** @use HasFactory<\Database\Factories\FooFactory> */', 'use Ha
{ "filepath": "tests/Integration/Generators/ModelMakeCommandTest.php", "language": "php", "file_size": 10051, "cut_index": 921, "middle_length": 229 }
estCase { protected $files = [ 'app/Notifications/FooNotification.php', 'resources/views/foo-notification.blade.php', 'tests/Feature/Notifications/FooNotificationTest.php', ]; public function testItCanGenerateNotificationFile() { $this->artisan('make:notification', ['nam...
n.blade.php'); $this->assertFilenameNotExists('tests/Feature/Notifications/FooNotificationTest.php'); } public function testItCanGenerateNotificationFileWithMarkdownOption() { $this->artisan('make:notification', ['name' => 'Foo
on;', 'class FooNotification extends Notification', 'return (new MailMessage)', ], 'app/Notifications/FooNotification.php'); $this->assertFilenameNotExists('resources/views/foo-notificatio
{ "filepath": "tests/Integration/Generators/NotificationMakeCommandTest.php", "language": "php", "file_size": 3156, "cut_index": 614, "middle_length": 229 }
namespace Illuminate\Tests\Integration\Generators; class ObserverMakeCommandTest extends TestCase { protected $files = [ 'app/Observers/FooObserver.php', ]; public function testItCanGenerateObserverFile() { $this->artisan('make:observer', ['name' => 'FooObserver']) ->asser...
e App\Observers;', 'use App\Models\Foo;', 'class FooObserver', 'public function created(Foo $foo)', 'public function updated(Foo $foo)', 'public function deleted(Foo $foo)', 'public fu
ion testItCanGenerateObserverFileWithModel() { $this->artisan('make:observer', ['name' => 'FooObserver', '--model' => 'Foo']) ->assertExitCode(0); $this->assertFileContains([ 'namespac
{ "filepath": "tests/Integration/Generators/ObserverMakeCommandTest.php", "language": "php", "file_size": 1138, "cut_index": 518, "middle_length": 229 }
pace Illuminate\Tests\Integration\Generators; class PolicyMakeCommandTest extends TestCase { protected $files = [ 'app/Policies/FooPolicy.php', ]; public function testItCanGeneratePolicyFile() { $this->artisan('make:policy', ['name' => 'FooPolicy']) ->assertExitCode(0); ...
ntains([ 'namespace App\Policies;', 'use App\Models\Post;', 'use Illuminate\Foundation\Auth\User;', 'class FooPolicy', 'public function viewAny(User $user)', 'public function view(User
hp'); } public function testItCanGeneratePolicyFileWithModelOption() { $this->artisan('make:policy', ['name' => 'FooPolicy', '--model' => 'Post']) ->assertExitCode(0); $this->assertFileCo
{ "filepath": "tests/Integration/Generators/PolicyMakeCommandTest.php", "language": "php", "file_size": 1385, "cut_index": 524, "middle_length": 229 }
ate\Database\Eloquent\Relations\MorphTo; use PHPUnit\Framework\TestCase; class DatabaseEloquentInverseRelationMorphManyTest extends TestCase { /** * Setup the database schema. * * @return void */ protected function setUp(): void { $db = new DB; $db->addConnection([ ...
unction ($table) { $table->increments('id'); $table->morphs('commentable'); $table->timestamps(); }); } /** * Tear down the database schema. * * @return void */ protected function
nction createSchema() { $this->schema()->create('test_posts', function ($table) { $table->increments('id'); $table->timestamps(); }); $this->schema()->create('test_comments', f
{ "filepath": "tests/Database/DatabaseEloquentInverseRelationMorphManyTest.php", "language": "php", "file_size": 12022, "cut_index": 921, "middle_length": 229 }
ttributesTest extends TestCase { protected function setUp(): void { $db = new DB; $db->addConnection([ 'driver' => 'sqlite', 'database' => ':memory:', ]); $db->bootEloquent(); $db->setAsGlobal(); } public function testHasManyAddsAttribute...
tedModel->parent_id); $this->assertSame($value, $relatedModel->$key); } public function testHasOneAddsAttributes(): void { $parentId = 123; $key = 'a key'; $value = 'the value'; $parent = new RelatedWit
ationship = $parent ->hasMany(RelatedWithAttributesModel::class, 'parent_id') ->withAttributes([$key => $value]); $relatedModel = $relationship->make(); $this->assertSame($parentId, $rela
{ "filepath": "tests/Database/DatabaseEloquentHasOneOrManyWithAttributesTest.php", "language": "php", "file_size": 8488, "cut_index": 716, "middle_length": 229 }
tributes\DataProvider; use PHPUnit\Framework\TestCase; use ReflectionMethod; use Symfony\Component\Process\Process; class DatabaseMySqlSchemaStateTest extends TestCase { #[DataProvider('provider')] public function testConnectionString(string $expectedConnectionString, array $expectedVariables, array $dbConfig)...
>invoke($schemaState, $versionInfo); $this->assertEquals($expectedConnectionString, $connString); // test baseVariables $method = new ReflectionMethod(get_class($schemaState), 'baseVariables'); $variables = $method->invoke
nection); $versionInfo = ['version' => '8.0.0', 'isMariaDb' => false]; // test connectionString $method = new ReflectionMethod(get_class($schemaState), 'connectionString'); $connString = $method-
{ "filepath": "tests/Database/DatabaseMySqlSchemaStateTest.php", "language": "php", "file_size": 6714, "cut_index": 716, "middle_length": 229 }
luminate\Database\Query\Processors\PostgresProcessor; use PHPUnit\Framework\TestCase; class DatabasePostgresProcessorTest extends TestCase { public function testProcessColumns() { $processor = new PostgresProcessor; $listing = [ ['name' => 'id', 'type_name' => 'int4', 'type' => 'in...
2)', 'collation' => '', 'nullable' => true, 'default' => '4', 'comment' => 'NULL', 'generated' => false], ['name' => 'birth_date', 'type_name' => 'timestamp', 'type' => 'timestamp(6) without time zone', 'collation' => '', 'nullable' => false, '
ar', 'type' => 'character varying(100)', 'collation' => 'collate', 'nullable' => false, 'default' => '', 'comment' => 'foo', 'generated' => false], ['name' => 'balance', 'type_name' => 'numeric', 'type' => 'numeric(8,
{ "filepath": "tests/Database/DatabasePostgresProcessorTest.php", "language": "php", "file_size": 2369, "cut_index": 563, "middle_length": 229 }
te\Tests\Database; use Illuminate\Database\Connection; use Illuminate\Database\Query\Processors\PostgresProcessor; use Illuminate\Database\Schema\Grammars\PostgresGrammar; use Illuminate\Database\Schema\PostgresBuilder; use Mockery as m; use PHPUnit\Framework\TestCase; class DatabasePostgresSchemaBuilderTest extends ...
wice()->andReturn('prefix_'); $connection->shouldReceive('scalar')->twice()->with('sql')->andReturn(1); $this->assertTrue($builder->hasTable('table')); $this->assertTrue($builder->hasTable('public.table')); } public functi
tSchemaGrammar')->andReturn($grammar); $builder = new PostgresBuilder($connection); $grammar->shouldReceive('compileTableExists')->twice()->andReturn('sql'); $connection->shouldReceive('getTablePrefix')->t
{ "filepath": "tests/Database/DatabasePostgresSchemaBuilderTest.php", "language": "php", "file_size": 1914, "cut_index": 537, "middle_length": 229 }
namespace Illuminate\Tests\Database; use Illuminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Processors\Processor; use Mockery as m; use PDO; use PHPUnit\Framework\TestCase; class DatabaseProcessorTest extends TestCase { public function testInsertGetIdProcessing()...
houldReceive('getConnection')->andReturn($connection); $processor = new Processor; $result = $processor->processInsertGetId($builder, 'sql', ['foo'], 'id'); $this->assertSame(1, $result); } } class ProcessorTestPDOStub extends
onnection::class); $connection->shouldReceive('insert')->once()->with('sql', ['foo']); $connection->shouldReceive('getPdo')->once()->andReturn($pdo); $builder = m::mock(Builder::class); $builder->s
{ "filepath": "tests/Database/DatabaseProcessorTest.php", "language": "php", "file_size": 1165, "cut_index": 518, "middle_length": 229 }
use Mockery as m; use PDOException; use PHPUnit\Framework\TestCase; class DatabaseQueryExceptionTest extends TestCase { public function testIfItEmbedsBindingsIntoSql() { $connection = $this->getConnection(); $sql = 'SELECT * FROM huehue WHERE a = ? and hue = ?'; $bindings = [1, 'br']; ...
estIfItReturnsSameSqlWhenThereAreNoBindings() { $connection = $this->getConnection(); $sql = "SELECT * FROM huehue WHERE a = 1 and hue = 'br'"; $bindings = []; $expectedSql = $sql; $pdoException = new PDOExcep
Name(), $sql, $bindings, $pdoException); DB::shouldReceive('connection')->andReturn($connection); $result = $exception->getRawSql(); $this->assertSame($expectedSql, $result); } public function t
{ "filepath": "tests/Database/DatabaseQueryExceptionTest.php", "language": "php", "file_size": 6346, "cut_index": 716, "middle_length": 229 }
luminate\Container\Container; use Illuminate\Database\Connection; use Illuminate\Database\Schema\SQLiteBuilder; use Illuminate\Filesystem\Filesystem; use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\File; use Mockery as m; use PHPUnit\Framework\TestCase; class DatabaseSQLiteBuilderTest extends Tes...
abase() { $connection = m::mock(Connection::class); $connection->shouldReceive('getSchemaGrammar')->once(); $builder = new SQLiteBuilder($connection); File::shouldReceive('put') ->once() ->with(
FacadeApplication($app); } protected function tearDown(): void { Container::setInstance(null); Facade::setFacadeApplication(null); parent::tearDown(); } public function testCreateDat
{ "filepath": "tests/Database/DatabaseSQLiteBuilderTest.php", "language": "php", "file_size": 2464, "cut_index": 563, "middle_length": 229 }
(['toSql'])->setConstructorArgs([$conn, 'users'])->getMock(); $blueprint->expects($this->once())->method('toSql')->willReturn(['foo', 'bar']); $blueprint->build(); } public function testIndexDefaultNames() { $blueprint = $this->getBlueprint(table: 'users'); $blueprint->uniq...
->spatialIndex('coordinates'); $commands = $blueprint->getCommands(); $this->assertSame('geo_coordinates_spatialindex', $commands[0]->index); } public function testIndexDefaultNamesWhenPrefixSupplied() { $blueprint = $t
rs'); $blueprint->index('foo'); $commands = $blueprint->getCommands(); $this->assertSame('users_foo_index', $commands[0]->index); $blueprint = $this->getBlueprint(table: 'geo'); $blueprint
{ "filepath": "tests/Database/DatabaseSchemaBlueprintTest.php", "language": "php", "file_size": 32657, "cut_index": 1331, "middle_length": 229 }
luminate\Console\Command; use Illuminate\Container\Container; use Illuminate\Database\Seeder; use Mockery as m; use Mockery\Mock; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Output\OutputInterface; class TestSeeder extends Seeder { public function run() { // } } class TestDepsSee...
(3); $command = m::mock(Command::class); $command->shouldReceive('getOutput')->times(3)->andReturn($output); $seeder->setCommand($command); $container->shouldReceive('make')->once()->with('ClassName')->andReturn($child = m::
ClassAndCallsRun() { $seeder = new TestSeeder; $seeder->setContainer($container = m::mock(Container::class)); $output = m::mock(OutputInterface::class); $output->shouldReceive('writeln')->times
{ "filepath": "tests/Database/DatabaseSeederTest.php", "language": "php", "file_size": 2499, "cut_index": 563, "middle_length": 229 }
e\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Query\Builder as BaseBuilder; use Illuminate\Database\Query\Grammars\Grammar; use Illuminate\Database\Query\Processors\Processor; use Mockery as m; use PHPUnit\Framework\TestCase; use stdClass; class DatabaseSoftDeletingScopeTest extends TestCase { pub...
del); } public function testRestoreExtension() { $builder = new EloquentBuilder(new BaseBuilder( m::mock(ConnectionInterface::class), m::mock(Grammar::class), m::mock(Processor::class) ));
el::class); $model->shouldReceive('getQualifiedDeletedAtColumn')->once()->andReturn('table.deleted_at'); $builder->shouldReceive('whereNull')->once()->with('table.deleted_at'); $scope->apply($builder, $mo
{ "filepath": "tests/Database/DatabaseSoftDeletingScopeTest.php", "language": "php", "file_size": 6470, "cut_index": 716, "middle_length": 229 }
luminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; use PHPUnit\Framework\TestCase; class DatabaseSoftDeletingTest extends TestCase { public function testDeletedAtIsAddedToCastsAsDefaultType() { $model = new SoftDeletingModel; $this->a...
model->deleted_at); $this->assertTrue($expected->eq($model->deleted_at)); } public function testExistingCastOverridesAddedDateCast() { $model = new class(['deleted_at' => '2018-12-29 13:59:39']) extends SoftDeletingModel
{ $expected = Carbon::createFromFormat('Y-m-d H:i:s', '2018-12-29 13:59:39'); $model = new SoftDeletingModel(['deleted_at' => $expected->format('Y-m-d H:i:s')]); $this->assertInstanceOf(Carbon::class, $
{ "filepath": "tests/Database/DatabaseSoftDeletingTest.php", "language": "php", "file_size": 2038, "cut_index": 563, "middle_length": 229 }
rConstraintsAreProperlyAdded() { $relation = $this->getOneRelation(); $relation->getParent()->shouldReceive('getKeyName')->once()->andReturn('id'); $relation->getParent()->shouldReceive('getKeyType')->once()->andReturn('string'); $relation->getQuery()->shouldReceive('whereIn')->once(...
exact same for morph many because the classes share this code... * Will still test to be safe. */ public function testMorphManySetsProperConstraints() { $this->getManyRelation(); } public function testMorphManyEagerConst
rphResetModelStub; $model1->id = 1; $model2 = new EloquentMorphResetModelStub; $model2->id = 2; $relation->addEagerConstraints([$model1, $model2]); } /** * Note that the tests are the
{ "filepath": "tests/Database/DatabaseEloquentMorphTest.php", "language": "php", "file_size": 25541, "cut_index": 1331, "middle_length": 229 }
te\Tests\Database; use Illuminate\Database\Query\Processors\MySqlProcessor; use PHPUnit\Framework\TestCase; class DatabaseMySqlProcessorTest extends TestCase { public function testProcessColumns() { $processor = new MySqlProcessor; $listing = [ ['name' => 'id', 'type_name' => 'bigi...
, 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL', 'expression' => null], ]; $expected = [ ['name' => 'id', 'type_name'
'type_name' => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => '', 'expression' => null], ['name' => 'email', 'type_name' => 'varchar'
{ "filepath": "tests/Database/DatabaseMySqlProcessorTest.php", "language": "php", "file_size": 1954, "cut_index": 537, "middle_length": 229 }
luminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Expression; use Illuminate\Database\Query\Grammars\Grammar; use Mockery as m; use PHPUnit\Framework\TestCase; use ReflectionClass; class DatabaseQueryGrammarTest extends TestCase { public function testWhereRawReturns...
rtSame('select * from "users"', $rawQuery); } public function testWhereRawReturnsStringWhenStringPassed() { $builder = m::mock(Builder::class); $grammar = new Grammar(m::mock(Connection::class)); $reflection = new Refle
$method = $reflection->getMethod('whereRaw'); $expressionArray = ['sql' => new Expression('select * from "users"')]; $rawQuery = $method->invoke($grammar, $builder, $expressionArray); $this->asse
{ "filepath": "tests/Database/DatabaseQueryGrammarTest.php", "language": "php", "file_size": 2628, "cut_index": 563, "middle_length": 229 }
is->getConnection(), 'users'); $blueprint->create(); $blueprint->temporary(); $blueprint->increments('id'); $blueprint->string('email'); $statements = $blueprint->toSql(); $this->assertCount(1, $statements); $this->assertSame('create temporary table "users" ("id"...
ropTableIfExists() { $blueprint = new Blueprint($this->getConnection(), 'users'); $blueprint->dropIfExists(); $statements = $blueprint->toSql(); $this->assertCount(1, $statements); $this->assertSame('drop table
on(), 'users'); $blueprint->drop(); $statements = $blueprint->toSql(); $this->assertCount(1, $statements); $this->assertSame('drop table "users"', $statements[0]); } public function testD
{ "filepath": "tests/Database/DatabaseSQLiteSchemaGrammarTest.php", "language": "php", "file_size": 49622, "cut_index": 2151, "middle_length": 229 }
se\Query\Processors\Processor; use Illuminate\Database\Schema\Builder; use Illuminate\Database\Schema\Grammars\Grammar; use Mockery as m; use PHPUnit\Framework\TestCase; use stdClass; class DatabaseSchemaBuilderTest extends TestCase { public function testCreateDatabase() { $connection = m::mock(Connect...
n testDropDatabaseIfExists() { $connection = m::mock(Connection::class); $grammar = m::mock(stdClass::class); $grammar->shouldReceive('compileDropDatabaseIfExists')->andReturn('sql'); $connection->shouldReceive('getSchem
dReturn($grammar); $connection->shouldReceive('statement')->with('sql')->andReturnTrue(); $builder = new Builder($connection); $this->assertTrue($builder->createDatabase('foo')); } public functio
{ "filepath": "tests/Database/DatabaseSchemaBuilderTest.php", "language": "php", "file_size": 3760, "cut_index": 614, "middle_length": 229 }
luminate\Database\Eloquent\SoftDeletes; use Illuminate\Support\Carbon; use Mockery as m; use PHPUnit\Framework\TestCase; use stdClass; class DatabaseSoftDeletingTraitTest extends TestCase { public function testDeleteSetsSoftDeletedColumn() { $model = m::mock(DatabaseSoftDeletingTraitStub::class); ...
>with([ 'deleted_at', 'updated_at', ]); $model->shouldReceive('usesTimestamps')->once()->andReturn(true); $model->delete(); $this->assertInstanceOf(Carbon::class, $model->deleted_at); } publ
eturn($query); $query->shouldReceive('update')->once()->with([ 'deleted_at' => 'date-time', 'updated_at' => 'date-time', ]); $model->shouldReceive('syncOriginalAttributes')->once()-
{ "filepath": "tests/Database/DatabaseSoftDeletingTraitTest.php", "language": "php", "file_size": 2894, "cut_index": 563, "middle_length": 229 }
luminate\Database\Schema\SqliteSchemaState; use Illuminate\Database\SQLiteConnection; use Illuminate\Filesystem\Filesystem; use Mockery as m; use PDO; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\Process; class DatabaseSqliteSchemaStateTest extends TestCase { public function testLoadSchemaToDataba...
lass); $processFactory = m::spy(function () use ($process) { return $process; }); $schemaState = new SqliteSchemaState($connection, null, $processFactory); $schemaState->load('database/schema/sqlite-schema.dump'
= m::mock(SQLiteConnection::class); $connection->shouldReceive('getConfig')->andReturn($config); $connection->shouldReceive('getDatabaseName')->andReturn($config['database']); $process = m::spy(Process::c
{ "filepath": "tests/Database/DatabaseSqliteSchemaStateTest.php", "language": "php", "file_size": 2474, "cut_index": 563, "middle_length": 229 }
luminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Grammars\MySqlGrammar; use Illuminate\Database\Query\Processors\Processor; use Illuminate\Database\Schema\Grammars\MySqlGrammar as MySqlGrammarSchema; use Illuminate\Database\Schema\MySqlBuilder; use Mockery; use PHPUnit\...
tf8mb4_unicode_ci'); $connection->shouldReceive('getSchemaGrammar')->once()->andReturn($grammar); $connection->shouldReceive('statement')->once()->with( 'create database `my_temporary_database` default character set `utf8mb4` de
mmar = new MySqlGrammarSchema($connection); $connection->shouldReceive('getConfig')->once()->with('charset')->andReturn('utf8mb4'); $connection->shouldReceive('getConfig')->once()->with('collation')->andReturn('u
{ "filepath": "tests/Database/DatabaseMySqlBuilderTest.php", "language": "php", "file_size": 2599, "cut_index": 563, "middle_length": 229 }
nection = m::mock(Connection::class); $grammar = new PostgresGrammar($connection); $connection->shouldReceive('getConfig')->once()->with('charset')->andReturn('utf8'); $connection->shouldReceive('getSchemaGrammar')->once()->andReturn($grammar); $connection->shouldReceive('statement')->o...
'getSchemaGrammar')->once()->andReturn($grammar); $connection->shouldReceive('statement')->once()->with( 'drop database if exists "my_database_a"' )->andReturn(true); $builder = $this->getBuilder($connection);
ase('my_temporary_database'); } public function testDropDatabaseIfExists() { $connection = m::mock(Connection::class); $grammar = new PostgresGrammar($connection); $connection->shouldReceive(
{ "filepath": "tests/Database/DatabasePostgresBuilderTest.php", "language": "php", "file_size": 14833, "cut_index": 921, "middle_length": 229 }
on testAddingVector() { $blueprint = new Blueprint($this->getConnection(), 'embeddings'); $blueprint->vector('embedding', 384); $statements = $blueprint->toSql($this->getConnection(), $this->getGrammar()); $this->assertCount(1, $statements); $this->assertSame('alter table "e...
t null', $statements[0]); } public function testAddingNullableTsvectorColumn() { $blueprint = new Blueprint($this->getConnection(), 'test'); $blueprint->tsvector('search_vector')->nullable(); $statements = $blueprint->t
'test'); $blueprint->tsvector('search_vector'); $statements = $blueprint->toSql(); $this->assertCount(1, $statements); $this->assertSame('alter table "test" add column "search_vector" tsvector no
{ "filepath": "tests/Database/DatabasePostgresSchemaGrammarTest.php", "language": "php", "file_size": 58292, "cut_index": 2151, "middle_length": 229 }
er->select('*')->from('users')->where('id', [12]); $this->assertSame('select * from "users" where "id" = ?', $builder->toSql()); $this->assertEquals([0 => 12], $builder->getBindings()); $builder = $this->getBuilder(); $builder->select('*')->from('users')->where('id', '=', [12, 30]); ...
$builder = $this->getBuilder(); $builder->select('*')->from('users')->where('id', '<>', [12, 30]); $this->assertSame('select * from "users" where "id" <> ?', $builder->toSql()); $this->assertEquals([0 => 12], $builder->getBindin
$builder->select('*')->from('users')->where('id', '!=', [12, 30]); $this->assertSame('select * from "users" where "id" != ?', $builder->toSql()); $this->assertEquals([0 => 12], $builder->getBindings());
{ "filepath": "tests/Database/DatabaseQueryBuilderTest.php", "language": "php", "file_size": 398084, "cut_index": 13624, "middle_length": 229 }
te\Tests\Database; use Illuminate\Database\Query\Processors\SQLiteProcessor; use PHPUnit\Framework\TestCase; class DatabaseSQLiteProcessorTest extends TestCase { public function testProcessColumns() { $processor = new SQLiteProcessor; $listing = [ ['name' => 'id', 'type' => 'INTEG...
'1', 'primary' => '0', 'extra' => 1], ]; $expected = [ ['name' => 'id', 'type_name' => 'integer', 'type' => 'integer', 'collation' => null, 'nullable' => false, 'default' => '', 'auto_increment' => true, 'comment' => null, 'gene
> 1], ['name' => 'is_active', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' => '1', 'primary' => '0', 'extra' => 1], ['name' => 'with/slash', 'type' => 'tinyint(1)', 'nullable' => '0', 'default' =>
{ "filepath": "tests/Database/DatabaseSQLiteProcessorTest.php", "language": "php", "file_size": 2006, "cut_index": 537, "middle_length": 229 }
$this->assertCount(1, $statements); $this->assertSame('create table "prefix_users" ("id" int not null identity primary key, "email" nvarchar(255) not null)', $statements[0]); } public function testCreateTemporaryTable() { $connection = $this->getConnection(); $connection->should...
l" nvarchar(255) not null)', $statements[0]); } public function testCreateTemporaryTableWithPrefix() { $connection = $this->getConnection(prefix: 'prefix_'); $blueprint = new Blueprint($connection, 'users'); $blueprint-
s('id'); $blueprint->string('email'); $statements = $blueprint->toSql(); $this->assertCount(1, $statements); $this->assertSame('create table "#users" ("id" int not null identity primary key, "emai
{ "filepath": "tests/Database/DatabaseSqlServerSchemaGrammarTest.php", "language": "php", "file_size": 40200, "cut_index": 2151, "middle_length": 229 }
ase\EloquentHasOneIsTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentHasOneIsTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { ...
testChildIsNotNull() { $parent = Post::first(); $child = null; $this->assertFalse($parent->attachment()->is($child)); $this->assertTrue($parent->attachment()->isNot($child)); } public function testChildIsModel
(Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_id')->nullable(); }); $post = Post::create(); $post->attachment()->create(); } public function
{ "filepath": "tests/Integration/Database/EloquentHasOneIsTest.php", "language": "php", "file_size": 2647, "cut_index": 563, "middle_length": 229 }
ase\Eloquent\Model; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentHasOneOfManyTest extends DatabaseTestCase { public $retrievedLogins; protected function afterRefreshingDatabase() { Schema::create('users', function ($table) { ...
} public function testItOnlyEagerLoadsRequiredModels() { $this->retrievedLogins = 0; User::getEventDispatcher()->listen('eloquent.retrieved:*', function ($event, $models) { foreach ($models as $model) {
states', function ($table) { $table->increments('id'); $table->string('state'); $table->string('type'); $table->foreignId('user_id'); $table->timestamps(); });
{ "filepath": "tests/Integration/Database/EloquentHasOneOfManyTest.php", "language": "php", "file_size": 3713, "cut_index": 614, "middle_length": 229 }
ase\EloquentLazyEagerLoadingTest; use DB; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentLazyEagerLoadingTest extends DatabaseTestCase { protected function afterRefre...
}); } public function testItBasic() { $one = Model1::create(); $one->twos()->create(); $one->threes()->create(); $model = Model1::find($one->id); $this->assertTrue($model->relationLoaded('twos
$table->increments('id'); $table->integer('one_id'); }); Schema::create('three', function (Blueprint $table) { $table->increments('id'); $table->integer('one_id');
{ "filepath": "tests/Integration/Database/EloquentLazyEagerLoadingTest.php", "language": "php", "file_size": 2082, "cut_index": 563, "middle_length": 229 }
se Illuminate\Database\Eloquent\MassPrunable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Events\ModelsPruned; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Schema; use LogicException; use Mockery...
test_models', 'mass_prunable_soft_delete_test_models', 'mass_prunable_test_model_missing_prunable_methods', ])->each(function ($table) { Schema::create($table, function (Blueprint $table) { $table
() { return m::mock(Dispatcher::class); }); $this->app->alias(Dispatcher::class, 'events'); } protected function afterRefreshingDatabase() { collect([ 'mass_prunable_
{ "filepath": "tests/Integration/Database/EloquentMassPrunableTest.php", "language": "php", "file_size": 3343, "cut_index": 614, "middle_length": 229 }
ase\EloquentModelCustomEventsTest; use Illuminate\Database\Eloquent\Attributes\ObservedBy; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class El...
Schema::create('eloquent_model_stub_with_custom_event_from_traits', function (Blueprint $table) { $table->boolean('custom_attribute'); $table->boolean('observer_attribute'); }); } public function testFlushListen
$_SERVER['fired_event'] = true; }); } protected function afterRefreshingDatabase() { Schema::create('test_model1', function (Blueprint $table) { $table->increments('id'); });
{ "filepath": "tests/Integration/Database/EloquentModelCustomEventsTest.php", "language": "php", "file_size": 2703, "cut_index": 563, "middle_length": 229 }
minate\Support\Carbon; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelDateCastingTest extends DatabaseTestCase { /** {@inheritdoc} */ protected function afterRefreshingDatabase() { Schema::create('test_model1', function (Bluepri...
$table->date('date_field')->nullable(); $table->datetime('datetime_field')->nullable(); $table->date('immutable_date_field')->nullable(); $table->datetime('immutable_datetime_field')->nullable(); $table-
utable_date_field')->nullable(); $table->datetime('immutable_datetime_field')->nullable(); }); Schema::create('test_model2', function (Blueprint $table) { $table->increments('id');
{ "filepath": "tests/Integration/Database/EloquentModelDateCastingTest.php", "language": "php", "file_size": 6473, "cut_index": 716, "middle_length": 229 }
ema\Blueprint; use Illuminate\Support\Exceptions\MathException; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelDecimalCastingTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('test_model1'...
=> 'decimal:20', ]; }; $model->amount = 0.123456789e3; $this->assertSame('123.45678900000000000000', $model->amount); $model->amount = '0.123456789e3'; $this->assertSame('123.45678900000000000000', $mod
llable(); }); } public function testItHandlesExponent() { $model = new class extends Model { public $timestamps = false; protected $casts = [ 'amount'
{ "filepath": "tests/Integration/Database/EloquentModelDecimalCastingTest.php", "language": "php", "file_size": 6320, "cut_index": 716, "middle_length": 229 }
ate\Support\Facades\Crypt; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Fluent; use stdClass; class EloquentModelEncryptedCastingTest extends DatabaseTestCase { protected $encrypter; protected function setUp(): void { parent::setUp(); $this->encrypter = $this->mock(Encryp...
$table->text('secret_object')->nullable(); $table->text('secret_collection')->nullable(); }); } public function testStringsAreCastable() { $this->encrypter->expects('encrypt') ->with('this i
unction (Blueprint $table) { $table->increments('id'); $table->string('secret', 1000)->nullable(); $table->text('secret_array')->nullable(); $table->text('secret_json')->nullable();
{ "filepath": "tests/Integration/Database/EloquentModelEncryptedCastingTest.php", "language": "php", "file_size": 14385, "cut_index": 921, "middle_length": 229 }
yptedArrayObject; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Collection; use Orchestra\Testbench\TestCase; class EloquentModelEncryptedDirtyTest extends TestCase { public function testDirtyAttributeBehaviorWithNoPreviousKeys() { config(['app.key' => str_repeat('a', 32)]); Mo...
// Encrypted attributes should always be considered dirty if updated in any way because of rotatable encryption keys... $this->assertFalse($model->isDirty('secret')); $this->assertFalse($model->isDirty('secret_array_object'));
syncOriginal(); $this->assertFalse($model->isDirty('secret')); $this->assertFalse($model->isDirty('secret_array_object')); $model->secret = 'some-secret'; $model->secret_array_object = [1, 2, 3];
{ "filepath": "tests/Integration/Database/EloquentModelEncryptedDirtyTest.php", "language": "php", "file_size": 3213, "cut_index": 614, "middle_length": 229 }
tends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('enum_casts', function (Blueprint $table) { $table->increments('id'); $table->string('string_status', 100)->nullable(); $table->json('string_status_collection')->nullable(); ...
id'); $table->string('string_status', 100)->unique(); }); } public function testEnumsAreCastable() { DB::table('enum_casts')->insert([ 'string_status' => 'pending', 'string_status_collection'
$table->json('integer_status_array')->nullable(); $table->string('arrayable_status')->nullable(); }); Schema::create('unique_enum_casts', function (Blueprint $table) { $table->increments('
{ "filepath": "tests/Integration/Database/EloquentModelEnumCastingTest.php", "language": "php", "file_size": 13440, "cut_index": 921, "middle_length": 229 }
lueprint $table) { $table->increments('id'); $table->string('password')->nullable(); }); } public function testHashedWithBcrypt() { Config::set('hashing.driver', 'bcrypt'); Config::set('hashing.bcrypt.rounds', 13); $subject = HashedCast::create([ ...
d, ]); } public function testNotHashedIfAlreadyHashedWithBcrypt() { Config::set('hashing.driver', 'bcrypt'); Config::set('hashing.bcrypt.rounds', 13); $subject = HashedCast::create([ // "password";
)['algo']); $this->assertSame(13, password_get_info($subject->password)['options']['cost']); $this->assertDatabaseHas('hashed_casts', [ 'id' => $subject->id, 'password' => $subject->passwor
{ "filepath": "tests/Integration/Database/EloquentModelHashedCastingTest.php", "language": "php", "file_size": 12486, "cut_index": 921, "middle_length": 229 }
ase\EloquentModelDateCastingTest; use Carbon\CarbonImmutable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelImmutableDateCastingTest extends DatabaseTestCase { ...
eld' => '2019-10-01', 'datetime_field' => '2019-10-01 10:15:20', ]); $this->assertSame('2019-10-01T00:00:00.000000Z', $model->toArray()['date_field']); $this->assertSame('2019-10-01T10:15:20.000000Z', $model->toArray()[
date_field')->nullable(); $table->datetime('datetime_field')->nullable(); }); } public function testDatesAreImmutableCastable() { $model = TestModelImmutable::create([ 'date_fi
{ "filepath": "tests/Integration/Database/EloquentModelImmutableDateCastingTest.php", "language": "php", "file_size": 2340, "cut_index": 563, "middle_length": 229 }
atabase\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; use stdClass; class EloquentModelJsonCastingTest extends DatabaseTestCase { protected function afterRefreshingDatab...
ield')->nullable(); }); } public function testStringsAreCastable() { /** @var \Illuminate\Tests\Integration\Database\EloquentModelJsonCastingTest\JsonCast $object */ $object = JsonCast::create([ 'basic_strin
$table->json('json_string_as_json_field')->nullable(); $table->json('array_as_json_field')->nullable(); $table->json('object_as_json_field')->nullable(); $table->json('collection_as_json_f
{ "filepath": "tests/Integration/Database/EloquentModelJsonCastingTest.php", "language": "php", "file_size": 3268, "cut_index": 614, "middle_length": 229 }
nate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelLoadCountTest extends DatabaseTestCase { protected function afterRefreshingData...
able->unsignedInteger('base_model_id'); }); Schema::create('deleted_related', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->softDeletes();
le) { $table->increments('id'); $table->unsignedInteger('base_model_id'); }); Schema::create('related2s', function (Blueprint $table) { $table->increments('id'); $t
{ "filepath": "tests/Integration/Database/EloquentModelLoadCountTest.php", "language": "php", "file_size": 3527, "cut_index": 614, "middle_length": 229 }
ase\EloquentModelLoadMaxTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelLoadMaxTest extends DatabaseTestCase { protected ...
rint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); BaseModel::create(); Related1::create(['base_model_id' => 1, 'number' => 10]);
s', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); Schema::create('related2s', function (Bluep
{ "filepath": "tests/Integration/Database/EloquentModelLoadMaxTest.php", "language": "php", "file_size": 2623, "cut_index": 563, "middle_length": 229 }
ase\EloquentModelLoadMinTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelLoadMinTest extends DatabaseTestCase { protected ...
rint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); BaseModel::create(); Related1::create(['base_model_id' => 1, 'number' => 10]);
s', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); Schema::create('related2s', function (Bluep
{ "filepath": "tests/Integration/Database/EloquentModelLoadMinTest.php", "language": "php", "file_size": 2623, "cut_index": 563, "middle_length": 229 }
minate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelLoadMissingTest extends DatabaseTestCase { protected function afterRefres...
{ $table->increments('id'); $table->unsignedInteger('first_comment_id')->nullable(); $table->string('content')->nullable(); }); Schema::create('comments', function (Blueprint $table) { $table
('comment_mentions_users', function (Blueprint $table) { $table->unsignedInteger('comment_id'); $table->unsignedInteger('user_id'); }); Schema::create('posts', function (Blueprint $table)
{ "filepath": "tests/Integration/Database/EloquentModelLoadMissingTest.php", "language": "php", "file_size": 3247, "cut_index": 614, "middle_length": 229 }
ase\EloquentModelLoadSumTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentModelLoadSumTest extends DatabaseTestCase { protected ...
rint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); BaseModel::create(); Related1::create(['base_model_id' => 1, 'number' => 10]);
s', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('base_model_id'); $table->integer('number'); }); Schema::create('related2s', function (Bluep
{ "filepath": "tests/Integration/Database/EloquentModelLoadSumTest.php", "language": "php", "file_size": 2557, "cut_index": 563, "middle_length": 229 }
ase\EloquentModelRefreshTest; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\Concerns\AsPivot; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; ...
= Post::create(['title' => 'mohamed']); $post->refresh(); } public function testItRefreshesASoftDeletedModel() { $post = Post::create(['title' => 'said']); Post::find($post->id)->delete(); $this->assertFalse
e->increments('id'); $table->string('title'); $table->timestamps(); $table->softDeletes(); }); } public function testItRefreshesModelExcludedByGlobalScope() { $post
{ "filepath": "tests/Integration/Database/EloquentModelRefreshTest.php", "language": "php", "file_size": 3004, "cut_index": 563, "middle_length": 229 }
lationAutoloadTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('tags', function (Blueprint $table) { $table->increments('id'); $table->string('name')->nullable(); $table->string('status')->nullable(); $table->un...
ent_id')->nullable(); $table->morphs('commentable'); }); Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->morphs('likeable'); }); } public function
os', function (Blueprint $table) { $table->increments('id'); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('par
{ "filepath": "tests/Integration/Database/EloquentModelRelationAutoloadTest.php", "language": "php", "file_size": 9213, "cut_index": 921, "middle_length": 229 }
pace Illuminate\Tests\Integration\Database; use Illuminate\Contracts\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Attributes\Scope; use Illuminate\Database\Eloquent\Model; class EloquentModelScopeTest extends DatabaseTestCase { public function testModelHasScope() { $model = new TestScop...
c function testModelDoesNotHaveScopeWhenPrivateVisibility() { $model = new TestScopeModel1; $this->assertFalse($model->hasNamedScope('existsAsPrivate')); } } class TestScopeModel1 extends Model { public function scopeExists(Bu
alse($model->hasNamedScope('doesNotExist')); } public function testModelHasAttributedScope() { $model = new TestScopeModel1; $this->assertTrue($model->hasNamedScope('existsAsWell')); } publi
{ "filepath": "tests/Integration/Database/EloquentModelScopeTest.php", "language": "php", "file_size": 1275, "cut_index": 524, "middle_length": 229 }
\Eloquent\Model; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentBelongsToTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create(...
stHasSelf() { $users = User::has('parent')->get(); $this->assertCount(1, $users); } public function testHasSelfCustomOwnerKey() { $users = User::has('parentBySlug')->get(); $this->assertCount(1, $users);
$table->string('parent_slug')->nullable(); }); $user = User::create(['slug' => Str::random()]); User::create(['parent_id' => $user->id, 'parent_slug' => $user->slug]); } public function te
{ "filepath": "tests/Integration/Database/EloquentBelongsToTest.php", "language": "php", "file_size": 4237, "cut_index": 614, "middle_length": 229 }
e\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentCollectionLoadCountTest extends DatabaseTestCase { p...
Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_id'); }); $post = Post::create(); $post->comments()->saveMany([new Comment, new Comment])
default_value'); $table->softDeletes(); }); Schema::create('comments', function (Blueprint $table) { $table->increments('id'); $table->unsignedInteger('post_id'); });
{ "filepath": "tests/Integration/Database/EloquentCollectionLoadCountTest.php", "language": "php", "file_size": 3708, "cut_index": 614, "middle_length": 229 }
(Blueprint $table) { $table->increments('id'); $table->string('title')->nullable(); $table->unsignedInteger('user_id')->nullable(); $table->timestamps(); }); Schema::create('test_users', function ($table) { $table->increments('id'); ...
function testPaginationWithUnion() { TestPost::fillAndInsert([ ['title' => 'Hello world', 'user_id' => 1], ['title' => 'Goodbye world', 'user_id' => 2], ['title' => 'Howdy', 'user_id' => 3], ['ti
$posts[] = [ 'title' => 'Title '.$i, ]; } TestPost::fillAndInsert($posts); $this->assertCount(15, TestPost::cursorPaginate(15, ['id', 'title'])); } public
{ "filepath": "tests/Integration/Database/EloquentCursorPaginateTest.php", "language": "php", "file_size": 10841, "cut_index": 921, "middle_length": 229 }
base\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasManyThrough; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\DatabaseTestCase; class EloquentEagerL...
unction (Blueprint $table) { $table->id(); $table->unsignedBigInteger('post_id'); $table->timestamps(); }); Schema::create('roles', function (Blueprint $table) { $table->id(); $ta
}); Schema::create('posts', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('user_id'); $table->timestamps(); }); Schema::create('comments', f
{ "filepath": "tests/Integration/Database/EloquentEagerLoadingLimitTest.php", "language": "php", "file_size": 6658, "cut_index": 716, "middle_length": 229 }
se\Schema\Blueprint; use Illuminate\Support\Facades\Schema; use Illuminate\Tests\Integration\Database\Fixtures\Post; use Illuminate\Tests\Integration\Database\Fixtures\PostStringyKey; class EloquentDeleteTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('post...
:create('roles', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->softDeletes(); }); } public function testDeleteUseLimitWithoutJoins(): void { $totalPost
comments', function (Blueprint $table) { $table->increments('id'); $table->string('body')->nullable(); $table->integer('post_id'); $table->timestamps(); }); Schema:
{ "filepath": "tests/Integration/Database/EloquentDeleteTest.php", "language": "php", "file_size": 6829, "cut_index": 716, "middle_length": 229 }
lluminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; class EloquentHasManyTest extends DatabaseTestCase { protected function afterRefresh...
quent_has_many_test_logins', function ($table) { $table->id(); $table->foreignId('eloquent_has_many_test_user_id'); $table->timestamp('login_time'); }); } public function testCanGetHasOneFromHasManyRelat
ction ($table) { $table->id(); $table->foreignId('eloquent_has_many_test_user_id'); $table->string('title')->unique(); $table->timestamps(); }); Schema::create('elo
{ "filepath": "tests/Integration/Database/EloquentHasManyTest.php", "language": "php", "file_size": 4456, "cut_index": 614, "middle_length": 229 }
luminate\Database\Connection; use Illuminate\Database\Query\Builder; use Illuminate\Database\Query\Grammars\PostgresGrammar; use Mockery as m; use PHPUnit\Framework\TestCase; class DatabasePostgresQueryGrammarTest extends TestCase { public function testToRawSql() { $connection = m::mock(Connection::cla...
email" = \'foo\'', $query); } public function testCustomOperators() { PostgresGrammar::customOperators(['@@@', '@>', '']); PostgresGrammar::customOperators(['@@>', 1]); $connection = m::mock(Connection::class);
toRawSql( 'select * from "users" where \'{}\' ?? \'Hello\\\'\\\'World?\' AND "email" = ?', ['foo'], ); $this->assertSame('select * from "users" where \'{}\' ? \'Hello\\\'\\\'World?\' AND "
{ "filepath": "tests/Database/DatabasePostgresQueryGrammarTest.php", "language": "php", "file_size": 2286, "cut_index": 563, "middle_length": 229 }
namespace Illuminate\Tests\Integration\Generators; use Illuminate\Queue\Console\FailedTableCommand; class QueueFailedTableCommandTest extends TestCase { public function testCreateMakesMigration() { $this->artisan(FailedTableCommand::class)->assertExitCode(0); $this->assertMigrationFileContai...
$table->string(\'connection\');', '$table->string(\'queue\');', '$table->index([\'connection\', \'queue\', \'failed_at\']);', 'Schema::dropIfExists(\'failed_jobs\');', ], 'create_failed_jobs_table.php'); } }
'
{ "filepath": "tests/Integration/Generators/QueueFailedTableCommandTest.php", "language": "php", "file_size": 788, "cut_index": 518, "middle_length": 14 }
te\Tests\Integration\Generators; class RuleMakeCommandTest extends TestCase { protected $files = [ 'app/Rules/Foo.php', ]; public function testItCanGenerateRuleFile() { $this->artisan('make:rule', ['name' => 'Foo']) ->assertExitCode(0); $this->assertFileContains([ ...
'use Illuminate\Contracts\Validation\ValidationRule;', 'class Foo implements ValidationRule', 'public function validate(string $attribute, mixed $value, Closure $fail): void', ], 'app/Rules/Foo.php'); } pub
public function testItCanGenerateInvokableRuleFile() { $this->artisan('make:rule', ['name' => 'Foo']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App\Rules;',
{ "filepath": "tests/Integration/Generators/RuleMakeCommandTest.php", "language": "php", "file_size": 1553, "cut_index": 537, "middle_length": 229 }
es=1); namespace Illuminate\Tests\Integration\Generators; class TraitMakeCommandTest extends TestCase { public function testItCanGenerateTraitFile() { $this->artisan('make:trait', ['name' => 'FooTrait']) ->assertExitCode(0); $this->assertFileContains([ 'namespace App;'...
->assertExitCode(0); $this->assertFileContains([ 'namespace App\Traits;', 'trait FooTrait', ], 'app/Traits/FooTrait.php'); $files->deleteDirectory($traitsFolderPath); } public function test
'); /** @var \Illuminate\Filesystem\Filesystem $files */ $files = $this->app['files']; $files->ensureDirectoryExists($traitsFolderPath); $this->artisan('make:trait', ['name' => 'FooTrait'])
{ "filepath": "tests/Integration/Generators/TraitMakeCommandTest.php", "language": "php", "file_size": 1589, "cut_index": 537, "middle_length": 229 }
('id'); $table->integer('team_id')->nullable(); }); Schema::create('teams', function (Blueprint $table) { $table->increments('id'); $table->integer('owner_id'); }); Schema::create('posts', function (Blueprint $table) { $table->increments(...
); $users = AfterQueryUser::query() ->afterQuery(function (Collection $users) use ($afterQueryIds) { $afterQueryIds->push(...$users->pluck('id')->all()); $this->assertContainsOnlyInstancesOf(AfterQueryU
r('post_id'); $table->timestamps(); }); } public function testAfterQueryOnEloquentBuilder() { AfterQueryUser::create(); AfterQueryUser::create(); $afterQueryIds = collect(
{ "filepath": "tests/Integration/Database/AfterQueryTest.php", "language": "php", "file_size": 12411, "cut_index": 921, "middle_length": 229 }
tion testValueCanStoreNewCache() { $store = $this->getStore(); $store->put('foo', 'bar', 60); $this->assertSame('bar', $store->get('foo')); } public function testPutOperationShouldNotStoreExpired() { $store = $this->getStore(); $store->put('foo', 'bar', 0); ...
{ $store = $this->getStore(); $store->put('foo', 'bar', 60); DB::beginTransaction(); $store->put('foo', 'new-bar', 60); DB::commit(); $this->assertSame('new-bar', $store->get('foo')); } public
s->getStore(); $store->put('foo', 'bar', 60); $store->put('foo', 'new-bar', 60); $this->assertSame('new-bar', $store->get('foo')); } public function testValueCanUpdateExistCacheInTransaction()
{ "filepath": "tests/Integration/Database/DatabaseCacheStoreTest.php", "language": "php", "file_size": 10589, "cut_index": 921, "middle_length": 229 }
tabase\Eloquent\SoftDeletes; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Schema; use Mockery as m; class DatabaseEloquentBroadcastingTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { ...
el->name = 'Taylor'; $model->save(); Event::assertDispatched(function (BroadcastableModelEventOccurred $event) { return $event->model instanceof TestEloquentBroadcastUser && count($event->broadcastOn()) ===
; $table->timestamps(); }); } public function testBasicBroadcasting() { Event::fake([BroadcastableModelEventOccurred::class]); $model = new TestEloquentBroadcastUser; $mod
{ "filepath": "tests/Integration/Database/DatabaseEloquentBroadcastingTest.php", "language": "php", "file_size": 9979, "cut_index": 921, "middle_length": 229 }
le) { $table->increments('id'); $table->timestamps(); $table->decimal('price'); }); } public function testBasicCustomCasting() { $model = new TestEloquentModelWithCustomCast; $model->uppercase = 'taylor'; $this->assertSame('TAYLOR', $mode...
lizedModel->toArray()['uppercase']); $model->syncOriginal(); $model->uppercase = 'dries'; $this->assertSame('TAYLOR', $model->getOriginal('uppercase')); $model = new TestEloquentModelWithCustomCast; $model->upperca
erialize(serialize($model)); $this->assertSame('TAYLOR', $unserializedModel->uppercase); $this->assertSame('TAYLOR', $unserializedModel->getAttributes()['uppercase']); $this->assertSame('TAYLOR', $unseria
{ "filepath": "tests/Integration/Database/DatabaseEloquentModelCustomCastingTest.php", "language": "php", "file_size": 21855, "cut_index": 1331, "middle_length": 229 }
p namespace Illuminate\Tests\Integration\Database; use Illuminate\Foundation\Testing\DatabaseMigrations; use Orchestra\Testbench\TestCase; abstract class DatabaseTestCase extends TestCase { use DatabaseMigrations; /** * The current database driver. * * @var string */ protected $drive...
}); parent::setUp(); } protected function defineEnvironment($app) { $connection = $app['config']->get('database.default'); $this->driver = $app['config']->get("database.connections.$connection.driver"); }
$this->app['db']->purge($name); }
{ "filepath": "tests/Integration/Database/DatabaseTestCase.php", "language": "php", "file_size": 827, "cut_index": 516, "middle_length": 52 }
lluminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; class EloquentAggregateTest extends DatabaseTestCase { protected function afterRefreshingDatabase() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->integer('c');...
rAggregateTest::create(['c' => 4, 'name' => 'test-name4', 'balance' => +1]); UserAggregateTest::create(['c' => 5, 'name' => 'test-name5', 'balance' => +2]); UserAggregateTest::create(['c' => 6, 'name' => 'test-name5', 'balance' => null]);
'name' => 'test-name1', 'balance' => -1]); UserAggregateTest::create(['c' => 2, 'name' => 'test-name2', 'balance' => -1]); UserAggregateTest::create(['c' => 3, 'name' => 'test-name3', 'balance' => 0]); Use
{ "filepath": "tests/Integration/Database/EloquentAggregateTest.php", "language": "php", "file_size": 4697, "cut_index": 614, "middle_length": 229 }