|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +use ComplexHeart\Domain\Criteria\Contracts\PaginatedResult; |
| 6 | + |
| 7 | +test('PaginatedResult interface exists and is accessible', function () { |
| 8 | + expect(interface_exists(PaginatedResult::class))->toBeTrue(); |
| 9 | +}); |
| 10 | + |
| 11 | +test('PaginatedResult interface has all required methods', function () { |
| 12 | + $reflection = new ReflectionClass(PaginatedResult::class); |
| 13 | + |
| 14 | + $expectedMethods = [ |
| 15 | + 'items', |
| 16 | + 'total', |
| 17 | + 'perPage', |
| 18 | + 'currentPage', |
| 19 | + 'lastPage', |
| 20 | + 'hasMorePages', |
| 21 | + 'count', |
| 22 | + 'isEmpty', |
| 23 | + 'isNotEmpty', |
| 24 | + ]; |
| 25 | + |
| 26 | + foreach ($expectedMethods as $method) { |
| 27 | + expect($reflection->hasMethod($method)) |
| 28 | + ->toBeTrue("Method '{$method}' should exist in PaginatedResult interface"); |
| 29 | + } |
| 30 | +}); |
| 31 | + |
| 32 | +test('PaginatedResult methods have correct return types', function () { |
| 33 | + $reflection = new ReflectionClass(PaginatedResult::class); |
| 34 | + |
| 35 | + $methodReturnTypes = [ |
| 36 | + 'items' => 'array', |
| 37 | + 'total' => 'int', |
| 38 | + 'perPage' => 'int', |
| 39 | + 'currentPage' => 'int', |
| 40 | + 'lastPage' => 'int', |
| 41 | + 'hasMorePages' => 'bool', |
| 42 | + 'count' => 'int', |
| 43 | + 'isEmpty' => 'bool', |
| 44 | + 'isNotEmpty' => 'bool', |
| 45 | + ]; |
| 46 | + |
| 47 | + foreach ($methodReturnTypes as $methodName => $expectedType) { |
| 48 | + $method = $reflection->getMethod($methodName); |
| 49 | + expect($method->hasReturnType())->toBeTrue("Method {$methodName} should have return type"); |
| 50 | + |
| 51 | + $returnType = $method->getReturnType(); |
| 52 | + expect($returnType)->not->toBeNull("Method {$methodName} return type should not be null"); |
| 53 | + |
| 54 | + if ($returnType instanceof ReflectionNamedType) { |
| 55 | + expect($returnType->getName())->toBe($expectedType, "Method {$methodName} should return {$expectedType}"); |
| 56 | + } |
| 57 | + } |
| 58 | +}); |
| 59 | + |
| 60 | +test('PaginatedResult is an interface not a class', function () { |
| 61 | + $reflection = new ReflectionClass(PaginatedResult::class); |
| 62 | + |
| 63 | + expect($reflection->isInterface())->toBeTrue() |
| 64 | + ->and($reflection->isTrait())->toBeFalse(); |
| 65 | +}); |
| 66 | + |
| 67 | +test('PaginatedResult interface has correct namespace', function () { |
| 68 | + expect(PaginatedResult::class) |
| 69 | + ->toBe('ComplexHeart\Domain\Criteria\Contracts\PaginatedResult'); |
| 70 | +}); |
0 commit comments