prefix stringlengths 512 512 | suffix stringlengths 256 256 | middle stringlengths 14 229 | meta dict |
|---|---|---|---|
eption;
use Mockery as m;
use PDO;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
class DatabaseConnectionFactoryTest extends TestCase
{
protected $db;
protected function setUp(): void
{
$this->db = new DB;
$this->db->addConnection([
'driver' => 'sqlite',
... | lobal();
}
public function testConnectionCanBeCreated()
{
$this->assertInstanceOf(PDO::class, $this->db->getConnection()->getPdo());
$this->assertInstanceOf(PDO::class, $this->db->getConnection()->getReadPdo());
$this-> | => 'sqlite',
'read' => [
'database' => ':memory:',
],
'write' => [
'database' => ':memory:',
],
], 'read_write');
$this->db->setAsG | {
"filepath": "tests/Database/DatabaseConnectionFactoryTest.php",
"language": "php",
"file_size": 6410,
"cut_index": 716,
"middle_length": 229
} |
nection->getPostProcessor());
}
public function testSelectOneCallsSelectAndReturnsSingleResult()
{
$connection = $this->getMockConnection(['select']);
$connection->expects($this->once())->method('select')->with('foo', ['bar' => 'baz'])->willReturn(['foo']);
$this->assertSame('foo', ... | public function testScalarThrowsExceptionIfMultipleColumnsAreSelected()
{
$connection = $this->getMockConnection(['selectOne']);
$connection->expects($this->once())->method('selectOne')->with('select a, b from tbl')->willReturn((obj | );
$connection->expects($this->once())->method('selectOne')->with('select count(*) from tbl')->willReturn((object) ['count(*)' => 5]);
$this->assertSame(5, $connection->scalar('select count(*) from tbl'));
}
| {
"filepath": "tests/Database/DatabaseConnectionTest.php",
"language": "php",
"file_size": 34319,
"cut_index": 2151,
"middle_length": 229
} |
om']]));
}
#[DataProvider('mySqlConnectProvider')]
public function testMySqlConnectCallsCreateConnectionWithProperArguments($dsn, $config)
{
$connector = $this->getMockBuilder(MySqlConnector::class)->onlyMethods(['createConnection', 'getOptions'])->getMock();
$connection = m::mock(PDO::... | 8_unicode_ci';")->andReturn(true);
$result = $connector->connect($config);
$this->assertSame($result, $connection);
}
public static function mySqlConnectProvider()
{
return [
['mysql:host=foo;dbname=bar', [ | dsn, $config, ['options'])->willReturn($connection);
$connection->shouldReceive('exec')->once()->with('use `bar`;')->andReturn(true);
$connection->shouldReceive('exec')->once()->with("SET NAMES 'utf8' COLLATE 'utf | {
"filepath": "tests/Database/DatabaseConnectorTest.php",
"language": "php",
"file_size": 18494,
"cut_index": 1331,
"middle_length": 229
} |
minate\Database\Eloquent\Model;
use Illuminate\Support\BinaryCodec;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Uid\Ulid;
class DatabaseEloquentAsBinaryCastTest extends TestCase
{
protected function tearDown(): void
{
$reflection = new \Refl... | $model->setRawAttributes(['no_format' => 'value']);
$model->no_format;
}
public function testCastThrowsOnInvalidFormat()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Unsupp | stCastThrowsWhenFormatMissing()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('The binary codec format is required.');
$model = new AsBinaryTestModel;
| {
"filepath": "tests/Database/DatabaseEloquentAsBinaryCastTest.php",
"language": "php",
"file_size": 3577,
"cut_index": 614,
"middle_length": 229
} |
ork\TestCase;
class DatabaseEloquentBelongsToManyAggregateTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
... | a();
$order = BelongsToManyAggregateTestTestTransaction::query()
->withSum('allocatedTo as total_allocated', 'allocations.amount')
->first();
$this->assertEquals(1200, $order->total_allocated);
}
public fu | ->withSum('products as total_products', 'order_product.quantity')
->first();
$this->assertEquals(12, $order->total_products);
}
public function testWithSumSameTable()
{
$this->seedDat | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyAggregateTest.php",
"language": "php",
"file_size": 5414,
"cut_index": 716,
"middle_length": 229
} |
nate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model as Eloquent;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyChunkByIdTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
... | $this->schema()->create('articles', function ($table) {
$table->increments('id');
$table->string('title');
});
$this->schema()->create('article_user', function ($table) {
$table->increments('id') |
* @return void
*/
public function createSchema()
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
});
| {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyChunkByIdTest.php",
"language": "php",
"file_size": 3958,
"cut_index": 614,
"middle_length": 229
} |
estNow();
parent::tearDown();
}
#[DataProvider('createOrFirstValues')]
public function testCreateOrFirstMethodCreatesNewRelated(Closure|array $values): void
{
$source = new BelongsToManyCreateOrFirstTestSourceModel();
$source->id = 123;
$this->mockConnectionForModels(
... | reated_at") values (?, ?, ?, ?)',
['foo', 'bar', '2023-01-01 00:00:00', '2023-01-01 00:00:00'],
)->andReturnTrue();
$source->getConnection()->expects('insert')->with(
'insert into "pivot_table" ("related_id", "sourc | >andReturn(0);
$source->getConnection()->shouldReceive('getName')->andReturn('sqlite');
$source->getConnection()->expects('insert')->with(
'insert into "related_table" ("attr", "val", "updated_at", "c | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyCreateOrFirstTest.php",
"language": "php",
"file_size": 25208,
"cut_index": 1331,
"middle_length": 229
} |
nate\Database\Eloquent\Model as Eloquent;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyEachByIdTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);... | nction ($table) {
$table->increments('id');
$table->string('title');
});
$this->schema()->create('article_user', function ($table) {
$table->increments('id');
$table->integer('article_id')->u | on createSchema()
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
});
$this->schema()->create('articles', fu | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyEachByIdTest.php",
"language": "php",
"file_size": 3509,
"cut_index": 614,
"middle_length": 229
} |
ion" aria-label="{{ __('Pagination Navigation') }}" class="flex gap-2 items-center justify-between">
@if ($paginator->onFirstPage())
<span class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-600 bg-white border border-gray-300 cursor-not-allowed leading-5 rounded-md dark:text-gr... | :bg-gray-100 active:text-gray-800 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray-600 dark:text-gray-200 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-900 dark:hover: | ="prev" class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-800 bg-white border border-gray-300 leading-5 rounded-md hover:text-gray-700 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active | {
"filepath": "src/Illuminate/Pagination/resources/views/simple-tailwind.blade.php",
"language": "php",
"file_size": 2148,
"cut_index": 563,
"middle_length": 229
} |
rphToMany;
use Illuminate\Database\Query\Expression;
use Illuminate\Database\Schema\Blueprint;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyExpressionTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sql... | ['1_t1'])
->get();
$this->assertCount(1, $tags);
$this->assertEquals(2, $tags->first()->getKey());
}
public function testQualifiedColumnExpression(): void
{
$this->seedData();
$tags = DatabaseEloqu | sExpression(): void
{
$this->seedData();
$tags = DatabaseEloquentBelongsToManyExpressionTestTestPost::findOrFail(1)
->tags()
->wherePivotNotIn(new Expression("tag_id || '_' || type"), | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyExpressionTest.php",
"language": "php",
"file_size": 5179,
"cut_index": 716,
"middle_length": 229
} |
nate\Database\Eloquent\Model as Eloquent;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyLazyByIdTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);... | nction ($table) {
$table->increments('aid');
$table->string('title');
});
$this->schema()->create('article_user', function ($table) {
$table->integer('article_id')->unsigned();
$table->foreig | on createSchema()
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
});
$this->schema()->create('articles', fu | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyLazyByIdTest.php",
"language": "php",
"file_size": 3485,
"cut_index": 614,
"middle_length": 229
} |
e PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyOrFailTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->se... | ('role_user', function ($table) {
$table->integer('user_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->boolean('active')->default(false);
});
}
protected function tearDown(): void
| $table->string('email');
});
$this->schema()->create('roles', function ($table) {
$table->increments('id');
$table->string('name');
});
$this->schema()->create | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyOrFailTest.php",
"language": "php",
"file_size": 5761,
"cut_index": 716,
"middle_length": 229
} |
nate\Database\Eloquent\Model as Eloquent;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManySyncReturnValueTypeTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
... | ticles', function ($table) {
$table->string('id');
$table->string('title');
$table->primary('id');
});
$this->schema()->create('article_user', function ($table) {
$table->string('article_id' | blic function createSchema()
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
});
$this->schema()->create('ar | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManySyncReturnValueTypeTest.php",
"language": "php",
"file_size": 4500,
"cut_index": 614,
"middle_length": 229
} |
Pivot;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManySyncTouchesParentTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
... | s();
});
$this->schema()->create('article_user', function ($table) {
$table->string('article_id');
$table->foreign('article_id')->references('id')->on('articles');
$table->integer('user_id')->unsigned(); | unction createSchema()
{
$this->schema()->create('articles', function ($table) {
$table->string('id');
$table->string('title');
$table->primary('id');
$table->timestamp | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManySyncTouchesParentTest.php",
"language": "php",
"file_size": 5727,
"cut_index": 716,
"middle_length": 229
} |
\Database\Eloquent\Relations\MorphToMany;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyWithAttributesPendingTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:'... | $pivot = DB::table('pending_attributes_pivot')->first();
$this->assertSame('meta', $pivot->type);
$this->assertSame($post->id, $pivot->post_id);
$this->assertSame($tag->id, $pivot->tag_id);
}
public function testQueriesPen | $post = ManyToManyPendingAttributesPost::create();
$tag = $post->metaTags()->create(['name' => 'long article']);
$this->assertSame('long article', $tag->name);
$this->assertTrue($tag->visible);
| {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyWithAttributesPendingTest.php",
"language": "php",
"file_size": 7755,
"cut_index": 716,
"middle_length": 229
} |
\Database\Eloquent\Relations\MorphToMany;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentBelongsToManyWithAttributesTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
... | :table('with_attributes_pivot')->first();
$this->assertSame('meta', $pivot->type);
$this->assertSame($post->id, $pivot->post_id);
$this->assertSame($tag->id, $pivot->tag_id);
}
public function testQueriesWithAttributesAndPi | ManyToManyWithAttributesPost::create();
$tag = $post->metaTags()->create(['name' => 'long article']);
$this->assertSame('long article', $tag->name);
$this->assertTrue($tag->visible);
$pivot = DB: | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php",
"language": "php",
"file_size": 7806,
"cut_index": 716,
"middle_length": 229
} |
Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Grammars\Grammar;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class DatabaseEloquentBelongsToManyWithCastedAttributesTest extends TestCase
{
... | n(false);
$model1->shouldReceive('hasAttributeMutator')->andReturn(false);
$model1->shouldReceive('hasRelationAutoloadCallback')->andReturn(false);
$model1->shouldReceive('getCasts')->andReturn([]);
$model1->shouldReceive('g | e')->passthru();
$model1->shouldReceive('getAttribute')->with('parent_key')->andReturn(1);
$model1->shouldReceive('getAttribute')->with('foo')->passthru();
$model1->shouldReceive('hasGetMutator')->andRetur | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyWithCastedAttributesTest.php",
"language": "php",
"file_size": 3376,
"cut_index": 614,
"middle_length": 229
} |
mail::message>
{{-- Greeting --}}
@if (! empty($greeting))
# {{ $greeting }}
@else
@if ($level === 'error')
# @lang('Whoops!')
@else
# @lang('Hello!')
@endif
@endif
{{-- Intro Lines --}}
@foreach ($introLines as $line)
{{ $line }}
@endforeach
{{-- Action Button --}}
@isset($actionText)
<?php
$color = match ($lev... | Text)
<x-slot:subcopy>
@lang(
"If you're having trouble clicking the \":actionText\" button, copy and paste the URL below\n".
'into your web browser:',
[
'actionText' => $actionText,
]
) <span class="break-all">[{{ $displayableActio | Lines --}}
@foreach ($outroLines as $line)
{{ $line }}
@endforeach
{{-- Salutation --}}
@if (! empty($salutation))
{{ $salutation }}
@else
@lang('Regards,')<br>
{{ config('app.name') }}
@endif
{{-- Subcopy --}}
@isset($action | {
"filepath": "src/Illuminate/Notifications/resources/views/email.blade.php",
"language": "php",
"file_size": 1081,
"cut_index": 515,
"middle_length": 229
} |
luminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Grammars\Grammar;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class DatabaseEloquentBelongsToManyWithDefaultAttributesTest extends Test... | s->getMockBuilder(BelongsToMany::class)->onlyMethods(['touchIfTouching'])->setConstructorArgs($this->getRelationArguments())->getMock();
$relation->withPivotValue(['is_admin' => 1]);
$query = m::mock(stdClass::class);
$query->shoul | ConstructorArgs($this->getRelationArguments())->getMock();
$relation->withPivotValue(['is_admin' => 1]);
}
public function testWithPivotValueMethodSetsDefaultArgumentsForInsertion()
{
$relation = $thi | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyWithDefaultAttributesTest.php",
"language": "php",
"file_size": 2730,
"cut_index": 563,
"middle_length": 229
} |
te\Tests\Database;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Query\Grammars\Grammar;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class DatabaseEloquentBelongsToManyWithoutTouch... | hing(function () use ($related) {
$this->assertTrue($related::isIgnoringTouch());
$builder = m::mock(Builder::class);
$builder->shouldReceive('join');
$parent = m::mock(User::class);
$parent->sh | akePartial();
$related->shouldReceive('getUpdatedAtColumn')->never();
$related->shouldReceive('freshTimestampString')->never();
$this->assertFalse($related::isIgnoringTouch());
Model::withoutTouc | {
"filepath": "tests/Database/DatabaseEloquentBelongsToManyWithoutTouchingTest.php",
"language": "php",
"file_size": 2239,
"cut_index": 563,
"middle_length": 229
} |
protected $related;
public function testBelongsToWithDefault()
{
$relation = $this->getRelation()->withDefault();
$this->builder->shouldReceive('first')->once()->andReturnNull();
$newModel = new EloquentBelongsToModelStub;
$this->related->shouldReceive('newInstance')->once(... | $this->related->shouldReceive('newInstance')->once()->andReturn($newModel);
$this->assertSame($newModel, $relation->getResults());
$this->assertSame('taylor', $newModel->username);
}
public function testBelongsToWithArrayDefa | on()->withDefault(function ($newModel) {
$newModel->username = 'taylor';
});
$this->builder->shouldReceive('first')->once()->andReturnNull();
$newModel = new EloquentBelongsToModelStub;
| {
"filepath": "tests/Database/DatabaseEloquentBelongsToTest.php",
"language": "php",
"file_size": 16539,
"cut_index": 921,
"middle_length": 229
} |
d(Closure|array $values): void
{
$model = new EloquentBuilderCreateOrFirstTestModel();
$this->mockConnectionForModel($model, 'SQLite', [123]);
$model->getConnection()->shouldReceive('transactionLevel')->andReturn(0);
$model->getConnection()->shouldReceive('getName')->andReturn('sqlit... | ertEquals([
'id' => 123,
'attr' => 'foo',
'val' => 'bar',
'created_at' => '2023-01-01T00:00:00.000000Z',
'updated_at' => '2023-01-01T00:00:00.000000Z',
], $result->toArray());
}
p | 023-01-01 00:00:00', '2023-01-01 00:00:00'],
)->andReturnTrue();
$result = $model->newQuery()->createOrFirst(['attr' => 'foo'], $values);
$this->assertTrue($result->wasRecentlyCreated);
$this->ass | {
"filepath": "tests/Database/DatabaseEloquentBuilderCreateOrFirstTest.php",
"language": "php",
"file_size": 27297,
"cut_index": 1331,
"middle_length": 229
} |
::Baz);
$this->assertSame('No query results for model [Foo] Baz', $exception->getMessage());
$this->assertSame(['Baz'], $exception->getIds());
}
public function testFindOrFailMethodWithManyThrowsModelNotFoundException()
{
$this->expectException(ModelNotFoundException::class);
... | ith(['column'])->andReturn(new Collection([$model]));
$builder->findOrFail([1, 2], ['column']);
}
public function testFindOrFailMethodWithManyUsingCollectionThrowsModelNotFoundException()
{
$this->expectException(ModelNotFoundE | lass.'[get]', [$this->getMockQueryBuilder()]);
$builder->setModel($model);
$builder->getQuery()->shouldReceive('whereIntegerInRaw')->once()->with('foo_table.foo', [1, 2]);
$builder->shouldReceive('get')->w | {
"filepath": "tests/Database/DatabaseEloquentBuilderTest.php",
"language": "php",
"file_size": 145109,
"cut_index": 7068,
"middle_length": 229
} |
ection;
use Illuminate\Support\Str;
use Symfony\Component\Mailer\Header\MetadataHeader;
use Symfony\Component\Mailer\Header\TagHeader;
class MailChannel
{
/**
* The mailer implementation.
*
* @var \Illuminate\Contracts\Mail\Factory
*/
protected $mailer;
/**
* The markdown implemen... | /**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return \Illuminate\Mail\SentMessage|null
*/
public function send($notifiable, Notifica | ry $mailer
* @param \Illuminate\Mail\Markdown $markdown
*/
public function __construct(MailFactory $mailer, Markdown $markdown)
{
$this->mailer = $mailer;
$this->markdown = $markdown;
}
| {
"filepath": "src/Illuminate/Notifications/Channels/MailChannel.php",
"language": "php",
"file_size": 9384,
"cut_index": 921,
"middle_length": 229
} |
protected $items;
/**
* The number of items to be shown per page.
*
* @var int
*/
protected $perPage;
/**
* The current page being "viewed".
*
* @var int
*/
protected $currentPage;
/**
* The base path to assign to all URLs.
*
* @var string... | ndicates that the paginator's string representation should be escaped when __toString is invoked.
*
* @var bool
*/
protected $escapeWhenCastingToString = false;
/**
* The number of links to display on each side of current page | to all URLs.
*
* @var string|null
*/
protected $fragment;
/**
* The query string variable used to store the page.
*
* @var string
*/
protected $pageName = 'page';
/**
* I | {
"filepath": "src/Illuminate/Pagination/AbstractPaginator.php",
"language": "php",
"file_size": 18041,
"cut_index": 1331,
"middle_length": 229
} |
e\Contracts\Support\Jsonable;
use Illuminate\Support\Collection;
use IteratorAggregate;
use JsonSerializable;
/**
* @template TKey of array-key
*
* @template-covariant TValue
*
* @extends AbstractCursorPaginator<TKey, TValue>
*
* @implements Arrayable<TKey, TValue>
* @implements ArrayAccess<TKey, TValue>
* @i... | ginator instance.
*
* @param Collection<TKey, TValue>|Arrayable<TKey, TValue>|iterable<TKey, TValue>|null $items
* @param int $perPage
* @param \Illuminate\Pagination\Cursor|null $cursor
* @param array $options (path, quer | IteratorAggregate, Jsonable, JsonSerializable, PaginatorContract
{
/**
* Indicates whether there are more items in the data source.
*
* @var bool
*/
protected $hasMore;
/**
* Create a new pa | {
"filepath": "src/Illuminate/Pagination/CursorPaginator.php",
"language": "php",
"file_size": 5225,
"cut_index": 716,
"middle_length": 229
} |
?php
namespace Illuminate\Pagination;
class PaginationState
{
/**
* Bind the pagination state resolvers using the given application container as a base.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return void
*/
public static function resolveUsing($app)
{
... | return 1;
});
Paginator::queryStringResolver(fn () => $app['request']->query());
CursorPaginator::currentCursorResolver(function ($cursorName = 'cursor') use ($app) {
return Cursor::fromEncoded($app['request']->inpu | e = 'page') use ($app) {
$page = $app['request']->input($pageName);
if (filter_var($page, FILTER_VALIDATE_INT) !== false && (int) $page >= 1) {
return (int) $page;
}
| {
"filepath": "src/Illuminate/Pagination/PaginationState.php",
"language": "php",
"file_size": 1035,
"cut_index": 513,
"middle_length": 229
} |
Illuminate\Contracts\Pagination\LengthAwarePaginator
*/
protected $paginator;
/**
* Create a new URL window instance.
*
* @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
*/
public function __construct(PaginatorContract $paginator)
{
$this->pagi... | n get()
{
$onEachSide = $this->paginator->onEachSide;
if ($this->paginator->lastPage() < ($onEachSide * 2) + 8) {
return $this->getSmallSlider();
}
return $this->getUrlSlider($onEachSide);
}
/**
|
public static function make(PaginatorContract $paginator)
{
return (new static($paginator))->get();
}
/**
* Get the window of URLs to be shown.
*
* @return array
*/
public functio | {
"filepath": "src/Illuminate/Pagination/UrlWindow.php",
"language": "php",
"file_size": 5721,
"cut_index": 716,
"middle_length": 229
} |
class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span class="page-link" aria-hidden="true">‹</span>
</li>
... | ))
<li class="page-item disabled" aria-disabled="true"><span class="page-link">{{ $element }}</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@for | lsaquo;</a>
</li>
@endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element | {
"filepath": "src/Illuminate/Pagination/resources/views/bootstrap-4.blade.php",
"language": "php",
"file_size": 2084,
"cut_index": 563,
"middle_length": 229
} |
<div class="d-flex justify-content-between flex-fill d-sm-none">
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">... | i class="page-item">
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">@lang('pagination.next')</a>
</li>
@else
<li class="page-item disabled" aria-disable | >previousPageUrl() }}" rel="prev">@lang('pagination.previous')</a>
</li>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<l | {
"filepath": "src/Illuminate/Pagination/resources/views/bootstrap-5.blade.php",
"language": "php",
"file_size": 4219,
"cut_index": 614,
"middle_length": 229
} |
if ($paginator->hasPages())
<nav>
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.previous')</span>
... | ageUrl() }}" rel="next">@lang('pagination.next')</a>
</li>
@else
<li class="page-item disabled" aria-disabled="true">
<span class="page-link">@lang('pagination.next')</span>
</ | </li>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasMorePages())
<li class="page-item">
<a class="page-link" href="{{ $paginator->nextP | {
"filepath": "src/Illuminate/Pagination/resources/views/simple-bootstrap-4.blade.php",
"language": "php",
"file_size": 1053,
"cut_index": 513,
"middle_length": 229
} |
paginator->hasPages())
<nav role="navigation" aria-label="{!! __('Pagination Navigation') !!}">
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="page-item disabled" aria-disabled="true">
<span class="p... | orePages())
<li class="page-item">
<a class="page-link" href="{{ $paginator->nextPageUrl() }}" rel="next">{!! __('pagination.next') !!}</a>
</li>
@else
<li class="page-item dis | previousPageUrl() }}" rel="prev">
{!! __('pagination.previous') !!}
</a>
</li>
@endif
{{-- Next Page Link --}}
@if ($paginator->hasM | {
"filepath": "src/Illuminate/Pagination/resources/views/simple-bootstrap-5.blade.php",
"language": "php",
"file_size": 1186,
"cut_index": 518,
"middle_length": 229
} |
ations;
trait HasDatabaseNotifications
{
/**
* Get the entity's notifications.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<DatabaseNotification, $this>
*/
public function notifications()
{
return $this->morphMany(DatabaseNotification::class, 'notifiable')->late... | tifications()->read();
}
/**
* Get the entity's unread notifications.
*
* @return \Illuminate\Database\Eloquent\Relations\MorphMany<DatabaseNotification, $this>
*/
public function unreadNotifications()
{
return | n readNotifications()
{
return $this->no | {
"filepath": "src/Illuminate/Notifications/HasDatabaseNotifications.php",
"language": "php",
"file_size": 897,
"cut_index": 547,
"middle_length": 52
} |
namespace Illuminate\Notifications;
use Illuminate\Contracts\Notifications\Dispatcher as DispatcherContract;
use Illuminate\Contracts\Notifications\Factory as FactoryContract;
use Illuminate\Support\ServiceProvider;
class NotificationServiceProvider extends ServiceProvider
{
/**
* Boot the application servi... | provider.
*
* @return void
*/
public function register()
{
$this->app->singleton(ChannelManager::class, fn ($app) => new ChannelManager($app));
$this->app->alias(
ChannelManager::class, DispatcherContrac | {
$this->publishes([
__DIR__.'/resources/views' => $this->app->resourcePath('views/vendor/notifications'),
], 'laravel-notifications');
}
}
/**
* Register the service | {
"filepath": "src/Illuminate/Notifications/NotificationServiceProvider.php",
"language": "php",
"file_size": 1128,
"cut_index": 518,
"middle_length": 229
} |
dQueueAfterCommit;
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Queue\Attributes\Backoff;
use Illuminate\Queue\Attributes\DeleteWhenMissingModels;
use Illuminate\Queue\Attributes\MaxExceptions;
use Illuminate\Queue\Attributes\ReadsQueueAttribu... | * @var \Illuminate\Support\Collection
*/
public $notifiables;
/**
* The notification to be sent.
*
* @var \Illuminate\Notifications\Notification
*/
public $notification;
/**
* All of the channels to send | ection;
class SendQueuedNotifications implements ShouldQueue
{
use InteractsWithQueue, Queueable, ReadsQueueAttributes, SerializesModels;
/**
* The notifiable entities that should receive the notification.
*
| {
"filepath": "src/Illuminate/Notifications/SendQueuedNotifications.php",
"language": "php",
"file_size": 5538,
"cut_index": 716,
"middle_length": 229
} |
hp
namespace Illuminate\Notifications\Console;
use Illuminate\Console\MigrationGeneratorCommand;
use Symfony\Component\Console\Attribute\AsCommand;
#[AsCommand(name: 'make:notifications-table', aliases: ['notifications:table'])]
class NotificationTableCommand extends MigrationGeneratorCommand
{
/**
* The co... | e migration table name.
*
* @return string
*/
protected function migrationTableName()
{
return 'notifications';
}
/**
* Get the path to the migration stub file.
*
* @return string
*/
protected | rotected $aliases = ['notifications:table'];
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create a migration for the notifications table';
/**
* Get th | {
"filepath": "src/Illuminate/Notifications/Console/NotificationTableCommand.php",
"language": "php",
"file_size": 1096,
"cut_index": 515,
"middle_length": 229
} |
info, success, error).
*
* @var string
*/
public $level = 'info';
/**
* The subject of the notification.
*
* @var string
*/
public $subject;
/**
* The notification's greeting.
*
* @var string
*/
public $greeting;
/**
* The notificati... | /**
* The action URL.
*
* @var string
*/
public $actionUrl;
/**
* The name of the mailer that should send the notification.
*
* @var string
*/
public $mailer;
/**
* Indicate that the notificati |
/**
* The "outro" lines of the notification.
*
* @var array
*/
public $outroLines = [];
/**
* The text / label for the action.
*
* @var string
*/
public $actionText;
| {
"filepath": "src/Illuminate/Notifications/Messages/SimpleMessage.php",
"language": "php",
"file_size": 5861,
"cut_index": 716,
"middle_length": 229
} |
use Illuminate\Notifications\Notification;
use RuntimeException;
class DatabaseChannel
{
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return \Illuminate\Database\Eloquent\Model
*/
public func... | ray
*/
protected function buildPayload($notifiable, Notification $notification)
{
return [
'id' => $notification->id,
'type' => method_exists($notification, 'databaseType')
? $notification->datab | fication)
);
}
/**
* Build an array payload for the DatabaseNotification Model.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @return ar | {
"filepath": "src/Illuminate/Notifications/Channels/DatabaseChannel.php",
"language": "php",
"file_size": 2107,
"cut_index": 563,
"middle_length": 229
} |
uminate\Bus\Queueable;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
class BroadcastNotificationCreated implements ShouldBroadcast
{
use Queueable, Serial... | = [],
) {
}
/**
* Get the channels the event should broadcast on.
*
* @return array
*/
public function broadcastOn()
{
if ($this->notifiable instanceof AnonymousNotifiable &&
$this->notifiable->r | \Notification $notification The notification instance.
* @param array $data The notification data.
*/
public function __construct(
public $notifiable,
public $notification,
public $data | {
"filepath": "src/Illuminate/Notifications/Events/BroadcastNotificationCreated.php",
"language": "php",
"file_size": 3165,
"cut_index": 614,
"middle_length": 229
} |
e;
use Illuminate\Contracts\Support\Jsonable;
use Illuminate\Support\Collection;
use IteratorAggregate;
use JsonSerializable;
/**
* @template TKey of array-key
*
* @template-covariant TValue
*
* @extends AbstractPaginator<TKey, TValue>
*
* @implements Arrayable<TKey, TValue>
* @implements ArrayAccess<TKey, TVa... | last available page.
*
* @var int
*/
protected $lastPage;
/**
* Create a new paginator instance.
*
* @param Collection<TKey, TValue>|Arrayable<TKey, TValue>|iterable<TKey, TValue>|null $items
* @param int $to | ayAccess, Countable, IteratorAggregate, Jsonable, JsonSerializable, LengthAwarePaginatorContract
{
/**
* The total number of items before slicing.
*
* @var int
*/
protected $total;
/**
* The | {
"filepath": "src/Illuminate/Pagination/LengthAwarePaginator.php",
"language": "php",
"file_size": 7011,
"cut_index": 716,
"middle_length": 229
} |
())
<nav>
<ul class="pagination">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<li class="disabled" aria-disabled="true" aria-label="@lang('pagination.previous')">
<span aria-hidden="true">‹</span>
</li>
... | bled" aria-disabled="true"><span>{{ $element }}</span></li>
@endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($pag | @endif
{{-- Pagination Elements --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<li class="disa | {
"filepath": "src/Illuminate/Pagination/resources/views/bootstrap-3.blade.php",
"language": "php",
"file_size": 1864,
"cut_index": 537,
"middle_length": 229
} |
r->onFirstPage())
<span class="inline-flex items-center px-4 py-2 text-sm font-medium text-gray-600 bg-white border border-gray-300 cursor-not-allowed leading-5 rounded-md dark:text-gray-300 dark:bg-gray-700 dark:border-gray-600">
{!! __('pagination.previous') !!}
</s... | 600 dark:text-gray-200 dark:focus:border-blue-700 dark:active:bg-gray-700 dark:active:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-900 dark:hover:text-gray-200">
{!! __('pagination.previous') !!}
</a>
@ | er-gray-300 leading-5 rounded-md hover:text-gray-700 focus:outline-none focus:ring ring-gray-300 focus:border-blue-300 active:bg-gray-100 active:text-gray-800 transition ease-in-out duration-150 dark:bg-gray-800 dark:border-gray- | {
"filepath": "src/Illuminate/Pagination/resources/views/tailwind.blade.php",
"language": "php",
"file_size": 8972,
"cut_index": 716,
"middle_length": 229
} |
ationSent;
use Illuminate\Queue\Attributes\Connection;
use Illuminate\Queue\Attributes\Delay;
use Illuminate\Queue\Attributes\Queue as QueueAttribute;
use Illuminate\Queue\Attributes\ReadsQueueAttributes;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Illuminate\Support\Traits\Localizable;
use Symfo... | tracts\Bus\Dispatcher
*/
protected $bus;
/**
* The event dispatcher.
*
* @var \Illuminate\Contracts\Events\Dispatcher
*/
protected $events;
/**
* The locale to be used when sending notifications.
*
| butes;
/**
* The notification manager instance.
*
* @var \Illuminate\Notifications\ChannelManager
*/
protected $manager;
/**
* The Bus dispatcher instance.
*
* @var \Illuminate\Con | {
"filepath": "src/Illuminate/Notifications/NotificationSender.php",
"language": "php",
"file_size": 10671,
"cut_index": 921,
"middle_length": 229
} |
te\Notifications\Channels;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Notifications\Events\BroadcastNotificationCreated;
use Illuminate\Notifications\Messages\BroadcastMessage;
use Illuminate\Notifications\Notification;
use RuntimeException;
class BroadcastChannel
{
/**
* The event dispatcher... | uminate\Notifications\Notification $notification
* @return array|null
*/
public function send($notifiable, Notification $notification)
{
$message = $this->getData($notifiable, $notification);
$event = new BroadcastNotifi | ispatcher $events
*/
public function __construct(Dispatcher $events)
{
$this->events = $events;
}
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Ill | {
"filepath": "src/Illuminate/Notifications/Channels/BroadcastChannel.php",
"language": "php",
"file_size": 2013,
"cut_index": 537,
"middle_length": 229
} |
pport\Collection;
use UnexpectedValueException;
/** @implements Arrayable<array-key, mixed> */
class Cursor implements Arrayable
{
/**
* The parameters associated with the cursor.
*
* @var array
*/
protected $parameters;
/**
* Determine whether the cursor points to the next or pre... | * Get the given parameter from the cursor.
*
* @param string $parameterName
* @return string|null
*
* @throws \UnexpectedValueException
*/
public function parameter(string $parameterName)
{
if (! array_key_ex | $pointsToNextItems
*/
public function __construct(array $parameters, $pointsToNextItems = true)
{
$this->parameters = $parameters;
$this->pointsToNextItems = $pointsToNextItems;
}
/**
| {
"filepath": "src/Illuminate/Pagination/Cursor.php",
"language": "php",
"file_size": 3444,
"cut_index": 614,
"middle_length": 229
} |
pace Illuminate\Notifications;
use Illuminate\Contracts\Notifications\Dispatcher;
use Illuminate\Support\Str;
trait RoutesNotifications
{
/**
* Send the given notification.
*
* @param mixed $instance
* @return void
*/
public function notify($instance)
{
app(Dispatcher::c... | er.
*
* @param string $driver
* @param \Illuminate\Notifications\Notification|null $notification
* @return mixed
*/
public function routeNotificationFor($driver, $notification = null)
{
if (method_exists($this, | */
public function notifyNow($instance, ?array $channels = null)
{
app(Dispatcher::class)->sendNow($this, $instance, $channels);
}
/**
* Get the notification routing information for the given driv | {
"filepath": "src/Illuminate/Notifications/RoutesNotifications.php",
"language": "php",
"file_size": 1297,
"cut_index": 524,
"middle_length": 229
} |
lluminate\Support\Traits\Tappable;
use Illuminate\Support\Traits\TransformsToResourceCollection;
use Stringable;
use Traversable;
/**
* @template TKey of array-key
*
* @template-covariant TValue
*
* @mixin \Illuminate\Support\Collection<TKey, TValue>
*/
abstract class AbstractCursorPaginator implements Htmlable,... | /
protected $path = '/';
/**
* The query parameters to add to all URLs.
*
* @var array
*/
protected $query = [];
/**
* The URL fragment to add to all URLs.
*
* @var string|null
*/
protected $fra |
*/
protected $items;
/**
* The number of items to be shown per page.
*
* @var int
*/
protected $perPage;
/**
* The base path to assign to all URLs.
*
* @var string
* | {
"filepath": "src/Illuminate/Pagination/AbstractCursorPaginator.php",
"language": "php",
"file_size": 15856,
"cut_index": 921,
"middle_length": 229
} |
())
<div class="ui pagination menu" role="navigation">
{{-- Previous Page Link --}}
@if ($paginator->onFirstPage())
<a class="icon item disabled" aria-disabled="true" aria-label="@lang('pagination.previous')"> <i class="left chevron icon"></i> </a>
@else
<a class="ico... | endif
{{-- Array Of Links --}}
@if (is_array($element))
@foreach ($element as $page => $url)
@if ($page == $paginator->currentPage())
<a class="item active" href="{{ $url | --}}
@foreach ($elements as $element)
{{-- "Three Dots" Separator --}}
@if (is_string($element))
<a class="icon item disabled" aria-disabled="true">{{ $element }}</a>
@ | {
"filepath": "src/Illuminate/Pagination/resources/views/semantic-ui.blade.php",
"language": "php",
"file_size": 1682,
"cut_index": 537,
"middle_length": 229
} |
nt\Relations\Pivot;
use Illuminate\Database\Query\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class DatabaseEloquentPivotTest extends TestCase
{
public function testPropertiesAreSetCorrectly()
{
$parent = m::mock(... | );
$connection->shouldReceive('getPostProcessor')->andReturn($processor = m::mock(Processor::class));
$parent->getConnection()->getQueryGrammar()->shouldReceive('getDateFormat')->andReturn('Y-m-d H:i:s');
$parent->setDateFormat('Y-m | nResolverInterface::class));
$resolver->shouldReceive('connection')->andReturn($connection = m::mock(Connection::class));
$connection->shouldReceive('getQueryGrammar')->andReturn($grammar = m::mock(Grammar::class) | {
"filepath": "tests/Database/DatabaseEloquentPivotTest.php",
"language": "php",
"file_size": 8406,
"cut_index": 716,
"middle_length": 229
} |
orphicIntegrationTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
... | able->integer('user_id');
$table->string('title');
$table->text('body');
$table->timestamps();
});
$this->schema()->create('comments', function ($table) {
$table->increments('id');
| le->increments('id');
$table->string('email')->unique();
$table->timestamps();
});
$this->schema()->create('posts', function ($table) {
$table->increments('id');
$t | {
"filepath": "tests/Database/DatabaseEloquentPolymorphicIntegrationTest.php",
"language": "php",
"file_size": 7613,
"cut_index": 716,
"middle_length": 229
} |
Unit\Framework\TestCase;
class DatabaseEloquentPolymorphicRelationsIntegrationTest extends TestCase
{
/**
* Bootstrap Eloquent.
*
* @return void
*/
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'datab... | crements('id');
$table->timestamps();
});
$this->schema('default')->create('tags', function ($table) {
$table->increments('id');
$table->timestamps();
});
$this->schema('default')->creat | ma('default')->create('posts', function ($table) {
$table->increments('id');
$table->timestamps();
});
$this->schema('default')->create('images', function ($table) {
$table->in | {
"filepath": "tests/Database/DatabaseEloquentPolymorphicRelationsIntegrationTest.php",
"language": "php",
"file_size": 5512,
"cut_index": 716,
"middle_length": 229
} |
rk\TestCase;
class DatabaseEloquentRelationTest extends TestCase
{
public function testSetRelationFail()
{
$parent = new EloquentRelationResetModelStub;
$relation = new EloquentRelationResetModelStub;
$parent->setRelation('test', $relation);
$parent->setRelation('foo', 'bar');
... | odUpdatesRelatedTimestamps()
{
$builder = m::mock(Builder::class);
$parent = m::mock(Model::class);
$parent->shouldReceive('getAttribute')->with('id')->andReturn(1);
$related = m::mock(EloquentNoTouchingModelStub::class) | ion = new EloquentRelationResetModelStub;
$parent->setRelation('foo', $relation);
$parent->unsetRelation('foo');
$this->assertFalse($parent->relationLoaded('foo'));
}
public function testTouchMeth | {
"filepath": "tests/Database/DatabaseEloquentRelationTest.php",
"language": "php",
"file_size": 13952,
"cut_index": 921,
"middle_length": 229
} |
\Grammars\Grammar;
use Illuminate\Database\Query\Processors\Processor;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentRelationshipsTest extends TestCase
{
public function testStandardRelationships()
{
$post = new Post;
$this->assertInstanceOf(HasOne::class, $post->atta... | ());
$this->assertInstanceOf(HasOneThrough::class, $post->contract());
$this->assertInstanceOf(MorphToMany::class, $post->tags());
$this->assertInstanceOf(MorphTo::class, $post->postable());
}
public function testOverridden | ss, $post->owner());
$this->assertInstanceOf(MorphMany::class, $post->likes());
$this->assertInstanceOf(BelongsToMany::class, $post->viewers());
$this->assertInstanceOf(HasManyThrough::class, $post->lovers | {
"filepath": "tests/Database/DatabaseEloquentRelationshipsTest.php",
"language": "php",
"file_size": 19614,
"cut_index": 1331,
"middle_length": 229
} |
luminate\Database\Eloquent\Collection;
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Tests\Database\Fixtures\Models\EloquentResourceCollectionTestModel;
use Illuminate\Tests\Database\Fixtures\Models\EloquentResourceTestResourceModelWithUs... | \TestCase;
class DatabaseEloquentResourceCollectionTest extends TestCase
{
public function testItCanTransformToExplicitResource()
{
$collection = new Collection([
new EloquentResourceCollectionTestModel(),
]);
| ResourceCollectionTestResource;
use Illuminate\Tests\Database\Fixtures\Resources\EloquentResourceTestJsonResource;
use Illuminate\Tests\Database\Fixtures\Resources\EloquentResourceTestJsonResourceCollection;
use PHPUnit\Framework | {
"filepath": "tests/Database/DatabaseEloquentResourceCollectionTest.php",
"language": "php",
"file_size": 2969,
"cut_index": 563,
"middle_length": 229
} |
ourceTestResourceModel;
use Illuminate\Tests\Database\Fixtures\Models\EloquentResourceTestResourceModelWithGuessableResource;
use Illuminate\Tests\Database\Fixtures\Models\EloquentResourceTestResourceModelWithUseResourceAttribute;
use Illuminate\Tests\Database\Fixtures\Resources\EloquentResourceTestJsonResource;
use PH... | resource);
}
public function testItThrowsExceptionWhenResourceCannotBeFound()
{
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Failed to find resource class for model [Illuminate\Tests\Database\F | ResourceModel();
$resource = $model->toResource(EloquentResourceTestJsonResource::class);
$this->assertInstanceOf(EloquentResourceTestJsonResource::class, $resource);
$this->assertSame($model, $resource-> | {
"filepath": "tests/Database/DatabaseEloquentResourceModelTest.php",
"language": "php",
"file_size": 3046,
"cut_index": 614,
"middle_length": 229
} |
$table->softDeletes();
});
$this->schema()->create('comments', function ($table) {
$table->increments('id');
$table->integer('owner_id')->nullable();
$table->string('owner_type')->nullable();
$table->integer('post_id');
$table->string('... | $table->increments('id');
$table->string('name');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Tear down the database schema.
*
* @return void
*/
protected func |
$table->integer('user_id');
$table->string('address');
$table->timestamps();
$table->softDeletes();
});
$this->schema()->create('groups', function ($table) {
| {
"filepath": "tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php",
"language": "php",
"file_size": 36515,
"cut_index": 2151,
"middle_length": 229
} |
te\Tests\Database;
use Illuminate\Database\ClassMorphViolationException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Illuminate\Database\Eloquent\Relations\Relation;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentStrictMorphsTest extends TestCase
{
protecte... |
Relation::morphMap([
'test' => TestModel::class,
]);
$morphName = $model->getMorphClass();
$this->assertSame('test', $morphName);
}
public function testMapsCanBeEnforcedInOneMethod()
{
$mo | Exception(ClassMorphViolationException::class);
$model = new TestModel;
$model->getMorphClass();
}
public function testStrictModeDoesNotThrowExceptionWhenMorphMap()
{
$model = new TestModel; | {
"filepath": "tests/Database/DatabaseEloquentStrictMorphsTest.php",
"language": "php",
"file_size": 1882,
"cut_index": 537,
"middle_length": 229
} |
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
/**
* Setup the database schema.
*
* @return void
*/
public function createSchema()
{
$this->schema()... | updated_at', function ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->string('updated_at');
});
}
/**
* Tear down the database schema.
*
* @return void
| )->create('users_created_at', function ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->string('created_at');
});
$this->schema()->create('users_ | {
"filepath": "tests/Database/DatabaseEloquentTimestampsTest.php",
"language": "php",
"file_size": 11859,
"cut_index": 921,
"middle_length": 229
} |
nate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Builder;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentWithAttributesPendingTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
... | $query = PendingAttributesModel::query()
->withAttributes([$key => $value], asConditions: false);
$model = $query->make();
$this->assertSame($value, $model->$key);
}
public function testDoesNotAddWheres(): void
{ | $this->schema()->dropIfExists((new PendingAttributesModel)->getTable());
parent::tearDown();
}
public function testAddsAttributes(): void
{
$key = 'a key';
$value = 'the value';
| {
"filepath": "tests/Database/DatabaseEloquentWithAttributesPendingTest.php",
"language": "php",
"file_size": 4179,
"cut_index": 614,
"middle_length": 229
} |
nate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Schema\Builder;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentWithAttributesTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
... | WithAttributesModel::query()
->withAttributes([$key => $value]);
$model = $query->make();
$this->assertSame($value, $model->$key);
}
public function testAddsWheres(): void
{
$key = 'a key';
$value | his->schema()->dropIfExists((new WithAttributesModel)->getTable());
parent::tearDown();
}
public function testAddsAttributes(): void
{
$key = 'a key';
$value = 'the value';
$query = | {
"filepath": "tests/Database/DatabaseEloquentWithAttributesTest.php",
"language": "php",
"file_size": 4200,
"cut_index": 614,
"middle_length": 229
} |
nate\Database\Eloquent\MissingAttributeException;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentWithCastsTest extends TestCase
{
protected function setUp(): void
{
parent::... | $table->timestamps();
});
$this->schema()->create('unique_times', function ($table) {
$table->increments('id');
$table->time('time')->unique();
$table->timestamps();
});
}
pub | AsGlobal();
$this->createSchema();
}
protected function createSchema()
{
$this->schema()->create('times', function ($table) {
$table->increments('id');
$table->time('time');
| {
"filepath": "tests/Database/DatabaseEloquentWithCastsTest.php",
"language": "php",
"file_size": 3489,
"cut_index": 614,
"middle_length": 229
} |
hp
namespace Illuminate\Tests\Database;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Events\Dispatcher;
use PHPUnit\Framework\TestCase;
class DatabaseIntegrationTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
... | });
$connection->select('select ?', [true]);
$this->assertInstanceOf(QueryExecuted::class, $queryExecuted);
$this->assertSame('select ?', $queryExecuted->sql);
$this->assertSame([true], $queryExecuted->bindings);
|
public function testQueryExecutedToRawSql(): void
{
$connection = DB::connection();
$connection->listen(function (QueryExecuted $query) use (&$queryExecuted): void {
$queryExecuted = $query;
| {
"filepath": "tests/Database/DatabaseIntegrationTest.php",
"language": "php",
"file_size": 1074,
"cut_index": 515,
"middle_length": 229
} |
te\Tests\Database;
use Illuminate\Database\Connection;
use Illuminate\Database\Schema\Grammars\MariaDbGrammar;
use Illuminate\Database\Schema\MariaDbBuilder;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class DatabaseMariaDbBuilderTest extends TestCase
{
public function testCreateDatabase()
{
$co... | tement')->once()->with(
'create database `my_temporary_database` default character set `utf8mb4` default collate `utf8mb4_unicode_ci`'
)->andReturn(true);
$builder = new MariaDbBuilder($connection);
$builder->createData | $connection->shouldReceive('getConfig')->once()->with('collation')->andReturn('utf8mb4_unicode_ci');
$connection->shouldReceive('getSchemaGrammar')->once()->andReturn($grammar);
$connection->shouldReceive('sta | {
"filepath": "tests/Database/DatabaseMariaDbBuilderTest.php",
"language": "php",
"file_size": 1565,
"cut_index": 537,
"middle_length": 229
} |
;
use Illuminate\Database\Query\Processors\MariaDbProcessor;
use PHPUnit\Framework\TestCase;
class DatabaseMariaDbProcessorTest extends TestCase
{
public function testProcessColumns()
{
$processor = new MariaDbProcessor;
$listing = [
['name' => 'id', 'type_name' => 'bigint', 'type'... | 'varchar(100)', 'collation' => 'collate', 'nullable' => 'YES', 'default' => 'NULL', 'extra' => 'on update CURRENT_TIMESTAMP', 'comment' => 'NULL', 'expression' => null],
];
$expected = [
['name' => 'id', 'type_name' => 'bigint' | => 'varchar', 'type' => 'varchar(100)', 'collation' => 'collate', 'nullable' => 'NO', 'default' => 'foo', 'extra' => '', 'comment' => '', 'expression' => null],
['name' => 'email', 'type_name' => 'varchar', 'type' => | {
"filepath": "tests/Database/DatabaseMariaDbProcessorTest.php",
"language": "php",
"file_size": 1941,
"cut_index": 537,
"middle_length": 229
} |
;
use Illuminate\Database\Connection;
use Illuminate\Database\Query\Processors\MariaDbProcessor;
use Illuminate\Database\Schema\Grammars\MariaDbGrammar;
use Illuminate\Database\Schema\MariaDbBuilder;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class DatabaseMariaDbSchemaBuilderTest extends TestCase
{
public... | $connection->shouldReceive('getTablePrefix')->once()->andReturn('prefix_');
$connection->shouldReceive('scalar')->once()->with('sql')->andReturn(1);
$this->assertTrue($builder->hasTable('table'));
}
public function testGetColumnL | turn('db');
$connection->shouldReceive('getSchemaGrammar')->andReturn($grammar);
$builder = new MariaDbBuilder($connection);
$grammar->shouldReceive('compileTableExists')->once()->andReturn('sql');
| {
"filepath": "tests/Database/DatabaseMariaDbSchemaBuilderTest.php",
"language": "php",
"file_size": 1966,
"cut_index": 537,
"middle_length": 229
} |
ame([
'alter table `users` add `id` int unsigned not null auto_increment primary key',
'alter table `users` add `email` varchar(255) not null',
], $statements);
$conn = $this->getConnection();
$conn->shouldReceive('getConfig')->andReturn(null);
$conn->shouldRecei... | alue()
{
$conn = $this->getConnection();
$conn->shouldReceive('getConfig')->once()->with('charset')->andReturn('utf8');
$conn->shouldReceive('getConfig')->once()->with('collation')->andReturn('utf8_unicode_ci');
$conn->s | = $blueprint->toSql();
$this->assertCount(1, $statements);
$this->assertSame('create table `users` (`id` uuid not null, primary key (`id`))', $statements[0]);
}
public function testAutoIncrementStartingV | {
"filepath": "tests/Database/DatabaseMariaDbSchemaGrammarTest.php",
"language": "php",
"file_size": 64444,
"cut_index": 2151,
"middle_length": 229
} |
HPUnit\Framework\TestCase;
use ReflectionMethod;
class DatabaseMariaDbSchemaStateTest extends TestCase
{
#[DataProvider('provider')]
public function testConnectionString(string $expectedConnectionString, array $expectedVariables, array $dbConfig): void
{
$connection = $this->createMock(MariaDbConne... | uals($expectedConnectionString, $connString);
// test baseVariables
$method = new ReflectionMethod(get_class($schemaState), 'baseVariables');
$variables = $method->invoke($schemaState, $dbConfig);
$this->assertEquals($expe | MariaDb' => true];
// test connectionString
$method = new ReflectionMethod(get_class($schemaState), 'connectionString');
$connString = $method->invoke($schemaState, $versionInfo);
$this->assertEq | {
"filepath": "tests/Database/DatabaseMariaDbSchemaStateTest.php",
"language": "php",
"file_size": 5648,
"cut_index": 716,
"middle_length": 229
} |
k\TestCase;
class DatabaseMigrationCreatorTest extends TestCase
{
public function testBasicCreateMethodStoresMigrationFile()
{
$creator = $this->getCreator();
$creator->method('getDatePrefix')->willReturn('foo');
$creator->getFilesystem()->shouldReceive('exists')->once()->with('stubs/m... | ()->shouldReceive('glob')->once()->with('foo/*.php')->andReturn(['foo/foo_create_bar.php']);
$creator->getFilesystem()->shouldReceive('requireOnce')->once()->with('foo/foo_create_bar.php');
$creator->create('create_bar', 'foo');
}
| r->getFilesystem()->shouldReceive('ensureDirectoryExists')->once()->with('foo');
$creator->getFilesystem()->shouldReceive('put')->once()->with('foo/foo_create_bar.php', 'return new class');
$creator->getFilesystem | {
"filepath": "tests/Database/DatabaseMigrationCreatorTest.php",
"language": "php",
"file_size": 5569,
"cut_index": 716,
"middle_length": 229
} |
pace Illuminate\Tests\Database;
use Illuminate\Database\Console\Migrations\InstallCommand;
use Illuminate\Database\Migrations\MigrationRepositoryInterface;
use Illuminate\Foundation\Application;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Cons... | ->shouldReceive('repositoryExists')->once()->andReturn(false);
$this->runCommand($command, ['--database' => 'foo']);
}
public function testFireCallsRepositoryToInstallExists()
{
$command = new InstallCommand($repo = m::mock(Mi | m::mock(MigrationRepositoryInterface::class));
$command->setLaravel(new Application);
$repo->shouldReceive('setSource')->once()->with('foo');
$repo->shouldReceive('createRepository')->once();
$repo | {
"filepath": "tests/Database/DatabaseMigrationInstallCommandTest.php",
"language": "php",
"file_size": 1447,
"cut_index": 524,
"middle_length": 229
} |
mand;
use Illuminate\Database\Migrations\MigrationCreator;
use Illuminate\Foundation\Application;
use Illuminate\Support\Composer;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
class DatabaseMigrationMakeCommandTest ex... | o', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'foo', true)
->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_foo.php');
$this->runCommand($command, ['name' => 'create_foo']);
}
public function testBasicCreateGivesCreat | ser = m::mock(Composer::class)
);
$app = new Application;
$app->useDatabasePath(__DIR__);
$command->setLaravel($app);
$creator->shouldReceive('create')->once()
->with('create_fo | {
"filepath": "tests/Database/DatabaseMigrationMakeCommandTest.php",
"language": "php",
"file_size": 4618,
"cut_index": 614,
"middle_length": 229
} |
base\Events\SchemaLoaded;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Foundation\Application;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
class DatabaseMigrationMigrateCommandTest extend... | andReturn([]);
$migrator->shouldReceive('hasRunAnyMigrations')->andReturn(true);
$migrator->shouldReceive('usingConnection')->once()->andReturnUsing(function ($name, $callback) {
return $callback();
});
$migrator | spatcher::class));
$app = new ApplicationDatabaseMigrationStub(['path.database' => __DIR__]);
$app->useDatabasePath(__DIR__);
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()-> | {
"filepath": "tests/Database/DatabaseMigrationMigrateCommandTest.php",
"language": "php",
"file_size": 8087,
"cut_index": 716,
"middle_length": 229
} |
e\Database\Console\Migrations\MigrateCommand;
use Illuminate\Database\Console\Migrations\RefreshCommand;
use Illuminate\Database\Console\Migrations\ResetCommand;
use Illuminate\Database\Console\Migrations\RollbackCommand;
use Illuminate\Database\Events\DatabaseRefreshed;
use Illuminate\Foundation\Application;
use Mocke... | mmandCallsCommandsWithProperArguments()
{
$command = new RefreshCommand;
$app = new ApplicationDatabaseRefreshStub(['path.database' => __DIR__]);
$dispatcher = $app->instance(Dispatcher::class, $events = m::mock());
$co | ullOutput;
class DatabaseMigrationRefreshCommandTest extends TestCase
{
protected function tearDown(): void
{
RefreshCommand::prohibit(false);
parent::tearDown();
}
public function testRefreshCo | {
"filepath": "tests/Database/DatabaseMigrationRefreshCommandTest.php",
"language": "php",
"file_size": 4669,
"cut_index": 614,
"middle_length": 229
} |
itory;
use Illuminate\Support\Collection;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use stdClass;
class DatabaseMigrationRepositoryTest extends TestCase
{
public function testGetRanMigrationsListMigrationsByPackage()
{
$repo = $this->getRepository();
$query = m::mock(stdClass::class);
... | ', 'asc')->andReturn($query);
$query->shouldReceive('pluck')->once()->with('migration')->andReturn(new Collection(['bar']));
$query->shouldReceive('useWritePdo')->once()->andReturn($query);
$this->assertEquals(['bar'], $repo->getRa | ->shouldReceive('table')->once()->with('migrations')->andReturn($query);
$query->shouldReceive('orderBy')->once()->with('batch', 'asc')->andReturn($query);
$query->shouldReceive('orderBy')->once()->with('migration | {
"filepath": "tests/Database/DatabaseMigrationRepositoryTest.php",
"language": "php",
"file_size": 5490,
"cut_index": 716,
"middle_length": 229
} |
esetCommand;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Foundation\Application;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
class DatabaseMigrationResetCommandTest extends TestCase
{
protected fu... | migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('usingConnection')->once()->with(null, m::type(Closure::class))->andReturnUsing(function ($connection, $callback) {
$callback();
});
$migr | ommand = new ResetCommand($migrator = m::mock(Migrator::class));
$app = new ApplicationDatabaseResetStub(['path.database' => __DIR__]);
$app->useDatabasePath(__DIR__);
$command->setLaravel($app);
$ | {
"filepath": "tests/Database/DatabaseMigrationResetCommandTest.php",
"language": "php",
"file_size": 3230,
"cut_index": 614,
"middle_length": 229
} |
d;
use Illuminate\Database\Migrations\Migrator;
use Illuminate\Foundation\Application;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
class DatabaseMigrationRollbackCommandTest extends TestCase
{
public function tes... | ndReturnUsing(function ($name, $callback) {
return $callback();
});
$migrator->shouldReceive('setOutput')->once()->andReturn($migrator);
$migrator->shouldReceive('rollback')->once()->with([__DIR__.DIRECTORY_SEPARATOR.'mi | .database' => __DIR__]);
$app->useDatabasePath(__DIR__);
$command->setLaravel($app);
$migrator->shouldReceive('paths')->once()->andReturn([]);
$migrator->shouldReceive('usingConnection')->once()->a | {
"filepath": "tests/Database/DatabaseMigrationRollbackCommandTest.php",
"language": "php",
"file_size": 4152,
"cut_index": 614,
"middle_length": 229
} |
ramework\TestCase;
class DatabaseMigratorIntegrationTest extends TestCase
{
protected $db;
protected $migrator;
/**
* Bootstrap Eloquent.
*
* @return void
*/
protected function setUp(): void
{
$this->db = $db = new DB;
$db->addConnection([
'driver' ... | tDatabaseManager());
$container->bind('db.schema', function ($app) {
return $app['db']->connection()->getSchemaBuilder();
});
Facade::setFacadeApplication($container);
$this->migrator = new Migrator(
| $db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
], 'sqlite3');
$db->setAsGlobal();
$container = new Container;
$container->instance('db', $db->ge | {
"filepath": "tests/Database/DatabaseMigratorIntegrationTest.php",
"language": "php",
"file_size": 13263,
"cut_index": 921,
"middle_length": 229
} |
eEloquentMorphToTest extends TestCase
{
protected $builder;
protected $related;
public function testLookupDictionaryIsProperlyConstructedForEnums()
{
$relation = $this->getRelation();
$relation->addEagerConstraints([
$one = (object) ['morph_type' => 'morph_type_2', 'foreign... | }
}
public function testLookupDictionaryIsProperlyConstructed()
{
$stringish = new class
{
public function __toString()
{
return 'foreign_key_2';
}
};
| )) {
$value = $dictionary['morph_type_2'][$enumKey->value][0]->foreign_key;
$this->assertEquals(TestEnum::test, $value);
} else {
$this->fail('An enum should contain value property');
| {
"filepath": "tests/Database/DatabaseEloquentMorphToTest.php",
"language": "php",
"file_size": 16357,
"cut_index": 921,
"middle_length": 229
} |
te\Tests\Database;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Pivot;
use Mockery as m;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentCollectionQueueableTest extends TestCase
{
public function testSerializesPivotsEntitiesI... | ->getQueueableId()
->once();
}
/**
* @throws \Exception
*/
public function testJsonSerializationOfCollectionQueueableIdsWorks()
{
// When the ID of a Model is binary instead of int or string, the Collec | ->once();
}
public function testSerializesModelEntitiesById()
{
$spy = m::spy(Model::class);
$c = new Collection([$spy]);
$c->getQueueableIds();
$spy->shouldHaveReceived()
| {
"filepath": "tests/Database/DatabaseEloquentCollectionQueueableTest.php",
"language": "php",
"file_size": 1618,
"cut_index": 537,
"middle_length": 229
} |
loquent\Relations\HasOne;
use Illuminate\Database\Query\Builder as Query;
use Illuminate\Tests\Database\DynamicRelationModel2 as Related;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentDynamicRelationsTest extends TestCase
{
public function testBasicDynamicRelations()
{
DynamicRelationModel::res... | Model::resolveRelationUsing('dynamicRelConflict', fn ($m) => $m->hasOne(Related::class));
DynamicRelationModel::resolveRelationUsing('dynamicRelConflict', fn (DynamicRelationModel $m) => new FakeHasManyRel);
$model = new DynamicRelationMod | is->assertEquals(['many' => 'related'], $model->getRelationValue('dynamicRel_2'));
}
public function testBasicDynamicRelationsOverride()
{
// Dynamic Relations can override each other.
DynamicRelation | {
"filepath": "tests/Database/DatabaseEloquentDynamicRelationsTest.php",
"language": "php",
"file_size": 5155,
"cut_index": 716,
"middle_length": 229
} |
parent::setUp();
tap(new DB)->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
])->bootEloquent();
}
protected function tearDown(): void
{
Model::unsetConnectionResolver();
parent::tearDown();
}
public function testGlobalSco... | ope(ActiveScope::class);
$this->assertSame('select * from "table"', $query->toSql());
$this->assertSame([], $query->getBindings());
}
public function testClassNameGlobalScopeIsApplied()
{
$model = new EloquentClassNameG | ());
$this->assertEquals([1], $query->getBindings());
}
public function testGlobalScopeCanBeRemoved()
{
$model = new EloquentGlobalScopesTestModel;
$query = $model->newQuery()->withoutGlobalSc | {
"filepath": "tests/Database/DatabaseEloquentGlobalScopesTest.php",
"language": "php",
"file_size": 12181,
"cut_index": 921,
"middle_length": 229
} |
testMakeManyCreatesARelatedModelForEachRecord()
{
$records = [
'taylor' => ['name' => 'taylor'],
'colin' => ['name' => 'colin'],
];
$relation = $this->getRelation();
$relation->getRelated()->shouldReceive('newCollection')->once()->andReturn(new Collection);
... | nces[0]);
$this->assertEquals($colin, $instances[1]);
}
public function testCreateMethodProperlyCreatesNewModel()
{
$relation = $this->getRelation();
$created = $this->expectCreatedModel($relation, ['name' => 'taylor']) | 'colin']);
$colin->expects($this->never())->method('save');
$instances = $relation->makeMany($records);
$this->assertInstanceOf(Collection::class, $instances);
$this->assertEquals($taylor, $insta | {
"filepath": "tests/Database/DatabaseEloquentHasManyTest.php",
"language": "php",
"file_size": 18509,
"cut_index": 1331,
"middle_length": 229
} |
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->unsignedInteger('country_id');
$table->string('country_short');
$table->timestamps();
$table->softDeletes();
}... | string('name');
$table->string('shortname');
$table->timestamps();
});
}
/**
* Tear down the database schema.
*
* @return void
*/
protected function tearDown(): void
{
$this->sche | $table->text('body');
$table->string('email');
$table->timestamps();
});
$this->schema()->create('countries', function ($table) {
$table->increments('id');
$table-> | {
"filepath": "tests/Database/DatabaseEloquentHasManyThroughIntegrationTest.php",
"language": "php",
"file_size": 25198,
"cut_index": 1331,
"middle_length": 229
} |
ttributesPendingTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
}
public function testHasManyAddsAt... | $this->assertSame($parentId, $relatedModel->parent_id);
$this->assertSame($value, $relatedModel->$key);
}
public function testHasOneAddsAttributes(): void
{
$parentId = 123;
$key = 'a key';
$value = 'the value'; | $relationship = $parent
->hasMany(RelatedPendingAttributesModel::class, 'parent_id')
->withAttributes([$key => $value], asConditions: false);
$relatedModel = $relationship->make();
| {
"filepath": "tests/Database/DatabaseEloquentHasOneOrManyWithAttributesPendingTest.php",
"language": "php",
"file_size": 9176,
"cut_index": 716,
"middle_length": 229
} |
est extends TestCase
{
protected $builder;
protected $related;
protected $parent;
public function testHasOneWithDefault()
{
$relation = $this->getRelation()->withDefault();
$this->builder->shouldReceive('first')->once()->andReturnNull();
$newModel = new EloquentHasOneMod... | });
$this->builder->shouldReceive('first')->once()->andReturnNull();
$newModel = new EloquentHasOneModelStub;
$this->related->shouldReceive('newInstance')->once()->andReturn($newModel);
$this->assertSame($newModel, $rela | odel->getAttribute('foreign_key'));
}
public function testHasOneWithDynamicDefault()
{
$relation = $this->getRelation()->withDefault(function ($newModel) {
$newModel->username = 'taylor';
| {
"filepath": "tests/Database/DatabaseEloquentHasOneTest.php",
"language": "php",
"file_size": 12922,
"cut_index": 921,
"middle_length": 229
} |
tabase' => ':memory:']);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
public function createSchema(): void
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
});
$this->schema()->create('interme... | ->increments('id');
$table->string('state');
$table->string('type');
$table->foreignId('intermediate_id');
$table->timestamps();
});
$this->schema()->create('prices', function ($table) {
| $table->increments('id');
$table->foreignId('intermediate_id');
$table->dateTime('deleted_at')->nullable();
});
$this->schema()->create('states', function ($table) {
$table | {
"filepath": "tests/Database/DatabaseEloquentHasOneThroughOfManyTest.php",
"language": "php",
"file_size": 29276,
"cut_index": 1331,
"middle_length": 229
} |
Database\Eloquent\Relations\Relation;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentIntegrationWithTablePrefixTest extends TestCase
{
/**
* Bootstrap Eloquent.
*
* @return void
*/
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
... | ble->string('email');
$table->timestamps();
});
$this->schema('default')->create('friends', function ($table) {
$table->integer('user_id');
$table->integer('friend_id');
});
$this->schem | ablePrefix('prefix_');
$this->createSchema();
}
protected function createSchema()
{
$this->schema('default')->create('users', function ($table) {
$table->increments('id');
$ta | {
"filepath": "tests/Database/DatabaseEloquentIntegrationWithTablePrefixTest.php",
"language": "php",
"file_size": 5298,
"cut_index": 716,
"middle_length": 229
} |
lluminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasOne;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentInverseRelationHasOneTest extends TestCase
{
/**
* Setup the dat... | on ($table) {
$table->increments('id');
$table->timestamps();
});
$this->schema()->create('test_child', function ($table) {
$table->increments('id');
$table->foreignId('parent_id')->unique(); | atabase' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
protected function createSchema()
{
$this->schema()->create('test_parent', functi | {
"filepath": "tests/Database/DatabaseEloquentInverseRelationHasOneTest.php",
"language": "php",
"file_size": 6692,
"cut_index": 716,
"middle_length": 229
} |
lluminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\MorphOne;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentInverseRelationMorphOneTest extends TestCase
{
/**
* Setup the d... | ion ($table) {
$table->increments('id');
$table->timestamps();
});
$this->schema()->create('test_images', function ($table) {
$table->increments('id');
$table->morphs('imageable');
| 'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
protected function createSchema()
{
$this->schema()->create('test_posts', funct | {
"filepath": "tests/Database/DatabaseEloquentInverseRelationMorphOneTest.php",
"language": "php",
"file_size": 7903,
"cut_index": 716,
"middle_length": 229
} |
lation;
use Illuminate\Support\Stringable;
use Mockery as m;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentInverseRelationTest extends TestCase
{
public function testBuilderCallbackIsNotAppliedWhenInverseRelationIsNotSet()
{
$builder = m::mock(Buil... | el')->andReturn(new HasInverseRelationRelatedStub());
$builder->shouldReceive('afterQuery')->never();
$this->expectException(RelationNotFoundException::class);
(new HasInverseRelationStub($builder, new HasInverseRelationParentStub | nStub($builder, new HasInverseRelationParentStub());
}
public function testBuilderCallbackIsNotSetIfInverseRelationIsEmptyString()
{
$builder = m::mock(Builder::class);
$builder->shouldReceive('getMod | {
"filepath": "tests/Database/DatabaseEloquentInverseRelationTest.php",
"language": "php",
"file_size": 14141,
"cut_index": 921,
"middle_length": 229
} |
estCase;
class DatabaseEloquentModelAttributesTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->addConnection([
'driver' => 'sqlite',
... | = new ModelWithTableAttributeAndProperty;
$this->assertSame('property_table', $model->getTable());
}
public function test_child_table_attribute_overrides_inherited_table_property(): void
{
$model = new ChildModelWithTableAttr | tribute(): void
{
$model = new ModelWithTableAttribute;
$this->assertSame('custom_table_name', $model->getTable());
}
public function test_table_property_takes_precedence(): void
{
$model | {
"filepath": "tests/Database/DatabaseEloquentModelAttributesTest.php",
"language": "php",
"file_size": 18995,
"cut_index": 1331,
"middle_length": 229
} |
OneOfManyTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
/**
... | ring('type')->nullable();
});
}
/**
* Tear down the database schema.
*
* @return void
*/
protected function tearDown(): void
{
$this->schema()->drop('products');
$this->schema()->drop('states');
| ncrements('id');
});
$this->schema()->create('states', function ($table) {
$table->increments('id');
$table->morphs('stateful');
$table->string('state');
$table->st | {
"filepath": "tests/Database/DatabaseEloquentMorphOneOfManyTest.php",
"language": "php",
"file_size": 7865,
"cut_index": 716,
"middle_length": 229
} |
se\Query\Expression;
use Illuminate\Database\Query\Grammars\Grammar;
use Mockery\Adapter\Phpunit\MockeryTestCase as TestCase;
use Mockery as m;
use SortDirection;
use stdClass;
class DatabaseEloquentMorphToManyTest extends TestCase
{
public function testEagerConstraintsAreProperlyAdded(): void
{
$relat... | ->getParent()));
$model1 = new EloquentMorphToManyModelStub;
$model1->id = 1;
$model2 = new EloquentMorphToManyModelStub;
$model2->id = 2;
$relation->addEagerConstraints([$model1, $model2]);
}
public functio |
$relation->getQuery()->shouldReceive('whereIntegerInRaw')->once()->with('taggables.taggable_id', [1, 2]);
$relation->getQuery()->shouldReceive('where')->once()->with('taggables.taggable_type', get_class($relation | {
"filepath": "tests/Database/DatabaseEloquentMorphToManyTest.php",
"language": "php",
"file_size": 7149,
"cut_index": 716,
"middle_length": 229
} |
ry:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
protected function createSchema()
{
$this->schema()->create('users', function ($table) {
$table->increments('id');
$table->string('email')->unique();
});
... | own(): void
{
$this->schema()->drop('users');
$this->schema()->drop('articles');
$this->schema()->drop('comments');
parent::tearDown();
}
public function testAddingItemsToCollection()
{
$c = new Col | $this->schema()->create('comments', function ($table) {
$table->increments('id');
$table->integer('article_id');
$table->string('content');
});
}
protected function tearD | {
"filepath": "tests/Database/DatabaseEloquentCollectionTest.php",
"language": "php",
"file_size": 29891,
"cut_index": 1331,
"middle_length": 229
} |
blic function testCreateOrFirstMethodCreatesNewRecord(Closure|array $values): void
{
$model = new HasManyCreateOrFirstTestParentModel();
$model->id = 123;
$this->mockConnectionForModel($model, 'SQLite', [456]);
$model->getConnection()->shouldReceive('transactionLevel')->andReturn(0);... | ['attr' => 'foo'], $values);
$this->assertTrue($result->wasRecentlyCreated);
$this->assertEquals([
'id' => 456,
'parent_id' => 123,
'attr' => 'foo',
'val' => 'bar',
'created_at' => | ", "parent_id", "updated_at", "created_at") values (?, ?, ?, ?, ?)',
['foo', 'bar', 123, '2023-01-01 00:00:00', '2023-01-01 00:00:00'],
)->andReturnTrue();
$result = $model->children()->createOrFirst( | {
"filepath": "tests/Database/DatabaseEloquentHasManyCreateOrFirstTest.php",
"language": "php",
"file_size": 19630,
"cut_index": 1331,
"middle_length": 229
} |
aProvider('createOrFirstValues')]
public function testCreateOrFirstMethodCreatesNewRecord(Closure|array $values): void
{
$parent = new HasManyThroughCreateOrFirstTestParentModel();
$parent->id = 123;
$this->mockConnectionForModel($parent, 'SQLite', [789]);
$parent->getConnection(... | children()->createOrFirst(['attr' => 'foo'], $values);
$this->assertTrue($result->wasRecentlyCreated);
$this->assertEquals([
'id' => 789,
'attr' => 'foo',
'val' => 'bar',
'created_at' => '2023 | 'insert into "child" ("attr", "val", "updated_at", "created_at") values (?, ?, ?, ?)',
['foo', 'bar', '2023-01-01 00:00:00', '2023-01-01 00:00:00'],
)->andReturnTrue();
$result = $parent-> | {
"filepath": "tests/Database/DatabaseEloquentHasManyThroughCreateOrFirstTest.php",
"language": "php",
"file_size": 17804,
"cut_index": 1331,
"middle_length": 229
} |
w DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
/**
* Setup the database schema.
*
* @return void
*/
public function create... | ble) {
$table->increments('id');
$table->integer('user_id')->unique();
$table->string('title');
$table->text('body');
$table->string('email');
$table->timestamps();
});
| eger('position_id')->unique()->nullable();
$table->string('position_short');
$table->timestamps();
$table->softDeletes();
});
$this->schema()->create('contracts', function ($ta | {
"filepath": "tests/Database/DatabaseEloquentHasOneThroughIntegrationTest.php",
"language": "php",
"file_size": 15023,
"cut_index": 921,
"middle_length": 229
} |
lluminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentInverseRelationHasMan... | $this->schema()->create('test_users', function ($table) {
$table->increments('id');
$table->timestamps();
});
$this->schema()->create('test_posts', function ($table) {
$table->increments('id');
| on([
'driver' => 'sqlite',
'database' => ':memory:',
]);
$db->bootEloquent();
$db->setAsGlobal();
$this->createSchema();
}
protected function createSchema()
{
| {
"filepath": "tests/Database/DatabaseEloquentInverseRelationHasManyTest.php",
"language": "php",
"file_size": 8766,
"cut_index": 716,
"middle_length": 229
} |
nate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
use PHPUnit\Framework\TestCase;
class DatabaseEloquentIrregularPluralTest extends TestCase
{
protected function setUp(): void
{
$db = new DB;
$db->addConnection([
'driver' => 'sqlite',
'database' => ':memory:'... | function ($table) {
$table->increments('id');
$table->string('title');
});
$this->schema()->create('irregular_plural_human_irregular_plural_token', function ($table) {
$table->integer('irregular_plural_h | r_plural_humans', function ($table) {
$table->increments('id');
$table->string('email')->unique();
$table->timestamps();
});
$this->schema()->create('irregular_plural_tokens', | {
"filepath": "tests/Database/DatabaseEloquentIrregularPluralTest.php",
"language": "php",
"file_size": 4246,
"cut_index": 614,
"middle_length": 229
} |
$this->assertFalse($model->isDirty('collectionAttribute'));
}
public function testDirtyOnCastedArrayObject()
{
$model = new EloquentModelCastingStub;
$model->setRawAttributes([
'asarrayobjectAttribute' => '{"foo": "bar"}',
]);
$model->syncOriginal();
$... | blic function testDirtyOnCastedCollection()
{
$model = new EloquentModelCastingStub;
$model->setRawAttributes([
'ascollectionAttribute' => '{"foo": "bar"}',
]);
$model->syncOriginal();
$this->assertI | oo' => 'bar'];
$this->assertFalse($model->isDirty('asarrayobjectAttribute'));
$model->asarrayobjectAttribute = ['foo' => 'baz'];
$this->assertTrue($model->isDirty('asarrayobjectAttribute'));
}
pu | {
"filepath": "tests/Database/DatabaseEloquentModelTest.php",
"language": "php",
"file_size": 179704,
"cut_index": 7068,
"middle_length": 229
} |
racts\Support\Jsonable;
use Illuminate\Support\Collection;
use IteratorAggregate;
use JsonSerializable;
/**
* @template TKey of array-key
*
* @template-covariant TValue
*
* @extends AbstractPaginator<TKey, TValue>
*
* @implements Arrayable<TKey, TValue>
* @implements ArrayAccess<TKey, TValue>
* @implements It... | * @param Collection<TKey, TValue>|Arrayable<TKey, TValue>|iterable<TKey, TValue> $items
* @param int $perPage
* @param int|null $currentPage
* @param array $options (path, query, fragment, pageName)
*/
public function __co | able, JsonSerializable, PaginatorContract
{
/**
* Indicates if there are more items in the data source.
*
* @var bool
*/
protected $hasMore;
/**
* Create a new paginator instance.
*
| {
"filepath": "src/Illuminate/Pagination/Paginator.php",
"language": "php",
"file_size": 5106,
"cut_index": 716,
"middle_length": 229
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.