[增添]添加了datasource的setting数据库以及默认值

This commit is contained in:
makotocc0107
2024-08-27 09:57:44 +08:00
parent d111dfaea4
commit 72eb990970
10955 changed files with 978898 additions and 0 deletions

View File

@@ -0,0 +1,79 @@
<?php
namespace AnourValar\EloquentSerialize\Tests;
use AnourValar\EloquentSerialize\Tests\Models\User;
class UnionTest extends AbstractSuite
{
/**
* @return void
*/
public function testSimple()
{
$this->compare(
User::whereIn('title', ['a', 'b'])->union(User::whereIn('id', ['1', '2']))
);
}
/**
* @return void
*/
public function testNested()
{
// 2 levels
$union = User::where('id', '=', '1');
$union = User::where('id', '=', '2')->union($union);
$this->compare(
User::whereIn('title', ['a', 'b'])->union($union)
);
// 3 levels
$union = User::where('id', '=', '1');
$union = User::where('id', '=', '2')->union($union);
$union = User::where('id', '=', '3')->union($union);
$this->compare(
User::whereIn('title', ['a', 'b'])->union($union)
);
}
/**
* @return void
*/
public function testExpression()
{
$union1 = User::where(function ($query) {
$query->whereDoesnthave('userPhones', function ($query) {
$query->where(function ($query) {
$query
->where('created_at', '>=', '2010-01-01')
->orWhere('id', '=', '1');
});
});
});
$union2 = User::whereHas('userPhones', function ($query) {
$query->where('created_at', '>=', '2010-01-01');
});
$union2 = User::union($union2)->where(function ($query) {
$query
->where('id', '=', '1')
->orWhere(function ($query) {
$query
->where('id', '=', '2')
->orWhere(function ($query) {
$query
->where('title', '!=', 'admin')
->orWhere('id', '=', '3');
});
});
});
$this->compare(
User::whereNotIn('title', ['a', 'b'])->union($union1)->union($union2, true)
);
}
}