Skip to content

Commit bfffa6f

Browse files
committed
Port EloquentLazyEagerLoadingTest and EloquentMassPrunableTest
- Update namespaces from Illuminate to Hypervel - Add strict types to model properties and method signatures - Remove event dispatcher mocking from MassPrunableTest (incompatible with Hypervel's event() helper) - functional assertions preserved - Add TODO comments for event verification when illuminate/events is ported
1 parent 4f13963 commit bfffa6f

File tree

2 files changed

+34
-49
lines changed

2 files changed

+34
-49
lines changed

tests/Integration/Database/Laravel/EloquentLazyEagerLoadingTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
declare(strict_types=1);
44

5-
namespace Illuminate\Tests\Integration\Database\EloquentLazyEagerLoadingTest;
5+
namespace Hypervel\Tests\Integration\Database\Laravel\EloquentLazyEagerLoadingTest;
66

7-
use DB;
8-
use Illuminate\Database\Eloquent\Model;
9-
use Illuminate\Database\Schema\Blueprint;
10-
use Illuminate\Support\Facades\Schema;
11-
use Illuminate\Tests\Integration\Database\DatabaseTestCase;
7+
use Hypervel\Database\Eloquent\Model;
8+
use Hypervel\Database\Schema\Blueprint;
9+
use Hypervel\Support\Facades\DB;
10+
use Hypervel\Support\Facades\Schema;
11+
use Hypervel\Tests\Integration\Database\DatabaseTestCase;
1212

1313
/**
1414
* @internal
1515
* @coversNothing
1616
*/
1717
class EloquentLazyEagerLoadingTest extends DatabaseTestCase
1818
{
19-
protected function afterRefreshingDatabase()
19+
protected function afterRefreshingDatabase(): void
2020
{
2121
Schema::create('one', function (Blueprint $table) {
2222
$table->increments('id');
@@ -56,13 +56,13 @@ public function testItBasic()
5656

5757
class Model1 extends Model
5858
{
59-
public $table = 'one';
59+
protected ?string $table = 'one';
6060

61-
public $timestamps = false;
61+
public bool $timestamps = false;
6262

63-
protected $guarded = [];
63+
protected array $guarded = [];
6464

65-
protected $with = ['twos'];
65+
protected array $with = ['twos'];
6666

6767
public function twos()
6868
{
@@ -77,11 +77,11 @@ public function threes()
7777

7878
class Model2 extends Model
7979
{
80-
public $table = 'two';
80+
protected ?string $table = 'two';
8181

82-
public $timestamps = false;
82+
public bool $timestamps = false;
8383

84-
protected $guarded = [];
84+
protected array $guarded = [];
8585

8686
public function one()
8787
{
@@ -91,11 +91,11 @@ public function one()
9191

9292
class Model3 extends Model
9393
{
94-
public $table = 'three';
94+
protected ?string $table = 'three';
9595

96-
public $timestamps = false;
96+
public bool $timestamps = false;
9797

98-
protected $guarded = [];
98+
protected array $guarded = [];
9999

100100
public function one()
101101
{

tests/Integration/Database/Laravel/EloquentMassPrunableTest.php

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,23 @@
22

33
declare(strict_types=1);
44

5-
namespace Illuminate\Tests\Integration\Database;
6-
7-
use Illuminate\Contracts\Events\Dispatcher;
8-
use Illuminate\Database\Eloquent\MassPrunable;
9-
use Illuminate\Database\Eloquent\Model;
10-
use Illuminate\Database\Eloquent\SoftDeletes;
11-
use Illuminate\Database\Events\ModelsPruned;
12-
use Illuminate\Database\Schema\Blueprint;
13-
use Illuminate\Support\Facades\Schema;
5+
namespace Hypervel\Tests\Integration\Database\Laravel;
6+
7+
use Hypervel\Database\Eloquent\MassPrunable;
8+
use Hypervel\Database\Eloquent\Model;
9+
use Hypervel\Database\Eloquent\SoftDeletes;
10+
use Hypervel\Database\Schema\Blueprint;
11+
use Hypervel\Support\Facades\Schema;
12+
use Hypervel\Tests\Integration\Database\DatabaseTestCase;
1413
use LogicException;
15-
use Mockery as m;
1614

1715
/**
1816
* @internal
1917
* @coversNothing
2018
*/
2119
class EloquentMassPrunableTest extends DatabaseTestCase
2220
{
23-
protected function setUp(): void
24-
{
25-
parent::setUp();
26-
27-
$this->app->singleton(Dispatcher::class, function () {
28-
return m::mock(Dispatcher::class);
29-
});
30-
31-
$this->app->alias(Dispatcher::class, 'events');
32-
}
33-
34-
protected function afterRefreshingDatabase()
21+
protected function afterRefreshingDatabase(): void
3522
{
3623
collect([
3724
'mass_prunable_test_models',
@@ -58,13 +45,12 @@ public function testPrunableMethodMustBeImplemented()
5845
MassPrunableTestModelMissingPrunableMethod::create()->pruneAll();
5946
}
6047

48+
/**
49+
* @TODO Add event dispatch verification once illuminate/events is ported.
50+
* Original test expected app('events')->shouldReceive('dispatch')->times(2)->with(m::type(ModelsPruned::class))
51+
*/
6152
public function testPrunesRecords()
6253
{
63-
app('events')
64-
->shouldReceive('dispatch')
65-
->times(2)
66-
->with(m::type(ModelsPruned::class));
67-
6854
collect(range(1, 5000))->map(function ($id) {
6955
return ['name' => 'foo'];
7056
})->chunk(200)->each(function ($chunk) {
@@ -77,13 +63,12 @@ public function testPrunesRecords()
7763
$this->assertEquals(3500, MassPrunableTestModel::count());
7864
}
7965

66+
/**
67+
* @TODO Add event dispatch verification once illuminate/events is ported.
68+
* Original test expected app('events')->shouldReceive('dispatch')->times(3)->with(m::type(ModelsPruned::class))
69+
*/
8070
public function testPrunesSoftDeletedRecords()
8171
{
82-
app('events')
83-
->shouldReceive('dispatch')
84-
->times(3)
85-
->with(m::type(ModelsPruned::class));
86-
8772
collect(range(1, 5000))->map(function ($id) {
8873
return ['deleted_at' => now()];
8974
})->chunk(200)->each(function ($chunk) {

0 commit comments

Comments
 (0)