DoorDatabaseTest.php 993 Bytes
Newer Older
Jacob Priddy's avatar
Jacob Priddy committed
1
2
3
4
5
6
7
<?php


namespace Tests\Database;

use Source\Entities\Door;
use Tests\DatabaseTestCase;
8
use Source\Entities\HashedSearchable;
Jacob Priddy's avatar
Jacob Priddy committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use Source\Gateways\Doors\DatabaseDoorsRepository;

class DoorDatabaseTest extends DatabaseTestCase
{
    protected DatabaseDoorsRepository $doors;

    public function setUp(): void
    {
        parent::setUp();

        $this->doors = new DatabaseDoorsRepository();
    }

    /**
     * @test
24
     * @throws \Source\Exceptions\EntityExistsException
Jacob Priddy's avatar
Jacob Priddy committed
25
26
27
     */
    public function it_creates_and_finds_doors(): void
    {
28
        $door = $this->doors->create(new Door(0, 'loc', 'name', new HashedSearchable('token')));
Jacob Priddy's avatar
Jacob Priddy committed
29

30
31
32
33
34
        $found = $this->doors->getByToken(new HashedSearchable('token'));

        $this->assertEquals('loc', $found->getLocation());
        $this->assertEquals('name', $found->getName());
        $this->assertNotNull($found->getLastSeenAt());
Jacob Priddy's avatar
Jacob Priddy committed
35

36
        $this->assertNull($this->doors->getByToken(new HashedSearchable('i am autistic')));
Jacob Priddy's avatar
Jacob Priddy committed
37
38
    }
}