forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEloquentNamedScopeAttributeTest.php
47 lines (37 loc) · 1.34 KB
/
EloquentNamedScopeAttributeTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace Illuminate\Tests\Integration\Database;
use Orchestra\Testbench\Attributes\WithMigration;
use Orchestra\Testbench\TestCase;
use PHPUnit\Framework\Attributes\DataProvider;
#[WithMigration]
class EloquentNamedScopeAttributeTest extends TestCase
{
protected $query = 'select * from "named_scope_users" where "email_verified_at" is not null';
protected function setUp(): void
{
parent::setUp();
$this->markTestSkippedUnless(
$this->usesSqliteInMemoryDatabaseConnection(),
'Requires in-memory database connection',
);
}
#[DataProvider('namedScopeDataProvider')]
public function test_it_can_query_named_scoped_from_the_query_builder(string $methodName)
{
$query = Fixtures\NamedScopeUser::query()->{$methodName}(true);
$this->assertSame($this->query, $query->toRawSql());
}
#[DataProvider('namedScopeDataProvider')]
public function test_it_can_query_named_scoped_from_static_query(string $methodName)
{
$query = Fixtures\NamedScopeUser::{$methodName}(true);
$this->assertSame($this->query, $query->toRawSql());
}
public static function namedScopeDataProvider(): array
{
return [
'scope with return' => ['verified'],
'scope without return' => ['verifiedWithoutReturn'],
];
}
}