summaryrefslogtreecommitdiff
path: root/tests/Unit/Helpers/Stub/UserModelImplementation.php
blob: 1b14a17e946c3e1953981d665bcbea29a7f3916f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

namespace Engelsystem\Test\Unit\Helpers\Stub;

use Engelsystem\Models\User\User;
use Illuminate\Database\Eloquent\Collection;
use InvalidArgumentException;

class UserModelImplementation extends User
{
    /** @var User */
    public static $user = null;

    /** @var int */
    public static $id = null;

    /** @var int */
    public static $apiKey = null;

    /**
     * @param mixed $id
     * @param array $columns
     * @return User|null
     */
    public static function find($id, $columns = ['*'])
    {
        if ($id != static::$id) {
            throw new InvalidArgumentException('Wrong user ID searched');
        }

        return self::$user;
    }

    /**
     * @param string $apiKey
     * @return User[]|Collection|\Illuminate\Database\Query\Builder
     */
    public static function whereApiKey($apiKey)
    {
        if ($apiKey != static::$apiKey) {
            throw new InvalidArgumentException('Wrong api key searched');
        }

        return new Collection([self::$user]);
    }
}