Skip to content

Commit bc0d82e

Browse files
committed
fix: attempt to fix flickering tests when using postgres
1 parent 7920911 commit bc0d82e

File tree

11 files changed

+40
-10
lines changed

11 files changed

+40
-10
lines changed

tests/Fixtures/app/Models/Category.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\SoftDeletes;
7+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
78

89
class Category extends Model
910
{
10-
use SoftDeletes;
11+
use SoftDeletes, AppliesDefaultOrder;
1112

1213
protected $fillable = [
1314
'name'

tests/Fixtures/app/Models/Company.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Orion\Tests\Fixtures\App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
67

78
class Company extends Model
89
{
10+
use AppliesDefaultOrder;
11+
912
/**
1013
* The attributes that are mass assignable.
1114
*

tests/Fixtures/app/Models/Notification.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@
66

77
use Illuminate\Database\Eloquent\Model;
88
use Illuminate\Database\Eloquent\SoftDeletes;
9+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
910

1011
class Notification extends Model
1112
{
12-
use SoftDeletes;
13+
use SoftDeletes, AppliesDefaultOrder;
1314

1415
protected $fillable = ['text'];
1516

tests/Fixtures/app/Models/Post.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
use Illuminate\Database\Eloquent\Relations\BelongsTo;
99
use Illuminate\Database\Eloquent\Relations\HasOne;
1010
use Illuminate\Database\Eloquent\SoftDeletes;
11+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
1112

1213
class Post extends Model
1314
{
14-
use SoftDeletes;
15+
use SoftDeletes, AppliesDefaultOrder;
1516

1617
/**
1718
* The attributes that are mass assignable.

tests/Fixtures/app/Models/PostImage.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\Relations\BelongsTo;
77
use Illuminate\Database\Eloquent\SoftDeletes;
8+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
89

910
class PostImage extends Model
1011
{
11-
use SoftDeletes;
12+
use SoftDeletes, AppliesDefaultOrder;
1213

1314
/**
1415
* The attributes that are mass assignable.

tests/Fixtures/app/Models/PostMeta.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
use Illuminate\Database\Eloquent\Model;
66
use Illuminate\Database\Eloquent\Relations\BelongsTo;
7+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
78

89
class PostMeta extends Model
910
{
11+
use AppliesDefaultOrder;
12+
1013
/**
1114
* The attributes that are mass assignable.
1215
*

tests/Fixtures/app/Models/Role.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Orion\Tests\Fixtures\App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
67

78
class Role extends Model
89
{
10+
use AppliesDefaultOrder;
11+
912
/**
1013
* The attributes that are mass assignable.
1114
*

tests/Fixtures/app/Models/Team.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Orion\Tests\Fixtures\App\Models;
44

55
use Illuminate\Database\Eloquent\Model;
6+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
67

78
class Team extends Model
89
{
10+
use AppliesDefaultOrder;
11+
912
/**
1013
* The attributes that are mass assignable.
1114
*

tests/Fixtures/app/Models/User.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
namespace Orion\Tests\Fixtures\App\Models;
44

55
use Illuminate\Foundation\Auth\User as Authenticatable;
6+
use Orion\Tests\Fixtures\App\Traits\AppliesDefaultOrder;
67

78
class User extends Authenticatable
89
{
10+
use AppliesDefaultOrder;
11+
912
/**
1013
* The attributes that are mass assignable.
1114
*
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Orion\Tests\Fixtures\App\Traits;
4+
5+
use Illuminate\Database\Eloquent\Builder;
6+
7+
trait AppliesDefaultOrder
8+
{
9+
protected static function boot()
10+
{
11+
parent::boot();
12+
// Order by name ASC
13+
static::addGlobalScope('order', function (Builder $builder) {
14+
$builder->orderBy('id', 'asc');
15+
});
16+
}
17+
}

0 commit comments

Comments
 (0)