Skip to content

Commit

Permalink
Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
zingimmick committed Feb 7, 2022
1 parent 875d2ec commit 3039264
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
6 changes: 5 additions & 1 deletion tests/BelongsToOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function testEagerLoading(): void
->attach(User::query()->create([]), [
'status' => 1,
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Group $group */
$group = Group::query()->with(['leader'])->findOrFail($group->getKey());
self::assertInstanceOf(User::class, $group->leader);
Expand Down Expand Up @@ -76,6 +77,7 @@ public function testOfMany(): void
->attach($group, [
'status' => 1,
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Group $group */
$group = Group::query()->findOrFail($group->getKey());
self::assertSame('leader', $group->leader()->getRelationName());
Expand Down Expand Up @@ -104,10 +106,11 @@ public function testRetrievedTimes(): void
) use (&$retrievedLogins): void {
foreach ($models as $model) {
if ($model instanceof \Zing\LaravelEloquentRelationships\Tests\Models\User) {
$retrievedLogins++;
++$retrievedLogins;
}
}
});

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Group $group */
$group = Group::query()->create([
'name' => $this->faker->name(),
Expand Down Expand Up @@ -151,6 +154,7 @@ public function testReceivingModel(): void
->create([], [
'status' => 1,
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\User $leader */
$leader = $group->leader;
$this->assertNotNull($leader);
Expand Down
9 changes: 8 additions & 1 deletion tests/MorphToOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ public function testEagerLoading(): void
->attach(Image::query()->create([
'url' => $url,
]), []);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Product $product */
$product = Product::query()->with(['cover'])->findOrFail($product->getKey());
self::assertInstanceOf(Image::class, $product->cover);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $cover */
$cover = $product->cover;
self::assertSame($url, $cover->url);
Expand All @@ -40,6 +42,7 @@ public function testLazyLoading(): void
'url' => $url,
]), []);
self::assertInstanceOf(Image::class, $product->cover);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $cover */
$cover = $product->cover;
self::assertSame($url, $cover->url);
Expand All @@ -51,6 +54,7 @@ public function testWithDefault(): void
'name' => 'test',
]);
self::assertInstanceOf(Image::class, $product->cover);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $cover */
$cover = $product->cover;
self::assertSame('https://example.com/default.png', $cover->url);
Expand All @@ -74,6 +78,7 @@ public function testOfMany(): void
$product = Product::query()->create([]);
$image->bestProduct()
->attach($product, []);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Product $product */
$product = Product::query()->findOrFail($image->getKey());
self::assertSame('cover', $product->cover()->getRelationName());
Expand Down Expand Up @@ -102,7 +107,7 @@ public function testRetrievedTimes(): void
) use (&$retrievedLogins): void {
foreach ($models as $model) {
if ($model instanceof \Zing\LaravelEloquentRelationships\Tests\Models\Image) {
$retrievedLogins++;
++$retrievedLogins;
}
}
});
Expand Down Expand Up @@ -149,6 +154,7 @@ public function testReceivingModel(): void
->create([
'url' => 'test',
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $cover */
$cover = $product->cover;
$this->assertNotNull($cover);
Expand Down Expand Up @@ -177,6 +183,7 @@ public function testMorphType(): void
->updateExistingPivot($image->getKey(), [
'imageable_type' => 'bar',
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $cover */
$cover = $product->cover;
$this->assertNotNull($cover);
Expand Down
7 changes: 6 additions & 1 deletion tests/MorphedByOneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function testEagerLoading(): void
->attach(Image::query()->create([
'url' => $url,
]), []);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $image */
$image = Image::query()->with(['bestProduct'])->findOrFail($product->getKey());
self::assertInstanceOf(Product::class, $image->bestProduct);
Expand All @@ -43,6 +44,7 @@ public function testLazyLoading(): void
->attach(Image::query()->create([
'url' => $url,
]), []);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $image */
$image = Image::query()->findOrFail($product->getKey());
self::assertInstanceOf(Product::class, $image->bestProduct);
Expand Down Expand Up @@ -77,6 +79,7 @@ public function testOfMany(): void
]);
$product->images()
->attach($image, []);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Image $image */
$image = Image::query()->findOrFail($product->getKey());
self::assertSame('bestProduct', $image->bestProduct()->getRelationName());
Expand All @@ -103,7 +106,7 @@ public function testRetrievedTimes(): void
) use (&$retrievedLogins): void {
foreach ($models as $model) {
if ($model instanceof \Zing\LaravelEloquentRelationships\Tests\Models\Product) {
$retrievedLogins++;
++$retrievedLogins;
}
}
});
Expand Down Expand Up @@ -142,6 +145,7 @@ public function testReceivingModel(): void
->create([
'name' => 'test',
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Product $product */
$product = $image->bestProduct;
$this->assertNotNull($product);
Expand Down Expand Up @@ -170,6 +174,7 @@ public function testMorphType(): void
->updateExistingPivot($product->getKey(), [
'imageable_type' => 'bar',
]);

/** @var \Zing\LaravelEloquentRelationships\Tests\Models\Product $product */
$product = $image->bestProduct;
$this->assertNotNull($product);
Expand Down

0 comments on commit 3039264

Please sign in to comment.