Example of Mock / mockery in realodix/urlhub

File tests/Unit/Services/KeyServiceTest.php (link to Github)
use Mockery;
use Tests\TestCase;

class KeyServiceTest extends TestCase
{
    //
    public function keyRemaining($kc, $nouk, $expected)
    {
        $mock = Mockery::mock(KeyService::class)->makePartial();
        $mock->shouldReceive([
            'keyCapacity'     => $kc,
            'numberOfUsedKey' => $nouk,
        ]);
        $actual = $mock->keyRemaining();

        $this->assertSame($expected, $actual);
    }

    public function keyRemainingInPercent($kc, $nouk, $expected)
    {
        $mock = Mockery::mock(KeyService::class)->makePartial();
        $mock->shouldReceive([
            'keyCapacity'     => $kc,
            'numberOfUsedKey' => $nouk,
        ]);
        $actual = $mock->keyRemainingInPercent();

        $this->assertSame($expected, $actual);
    }
    //
}

Additional resources on mock / mockery: