<?php

declare(strict_types=1);

use App\Http\Api\Scope\GlobalScope;
use App\Http\Api\Scope\RelationScope;
use App\Http\Api\Scope\TypeScope;
use Illuminate\Foundation\Testing\WithFaker;

uses(WithFaker::class);

test('global scope is not within scope', function (): void {
    $scope = new TypeScope(fake()->word());

    $otherScope = new GlobalScope();

    $this->assertFalse($scope->isWithinScope($otherScope));
});

test('type scope is not within scope', function (): void {
    $scope = new TypeScope(fake()->unique()->word());

    $otherScope = new TypeScope(fake()->unique()->word());

    $this->assertFalse($scope->isWithinScope($otherScope));
});

test('type scope is within scope', function (): void {
    $type = fake()->word();

    $scope = new TypeScope($type);

    $otherScope = new TypeScope($type);

    $this->assertTrue($scope->isWithinScope($otherScope));
});

test('relation scope is not within scope', function (): void {
    $scope = new TypeScope(fake()->word());

    $otherScope = new RelationScope(fake()->word());

    $this->assertFalse($scope->isWithinScope($otherScope));
});

test('relation scope is within scope', function (): void {
    $type = fake()->word();

    $scope = new TypeScope($type);

    $otherScope = new RelationScope($type);

    $this->assertTrue($scope->isWithinScope($otherScope));
});
