Issues (57)

test/integration/Operation/AbstractTableTest.php (4 issues)

1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Operation;
5
6
use TBolier\RethinkQL\IntegrationTest\AbstractTestCase;
7
use TBolier\RethinkQL\Response\ResponseInterface;
8
9
abstract class AbstractTableTest extends AbstractTestCase
10
{
11
    public function setUp()
12
    {
13
        parent::setUp();
14
15
        $res = $this->r()->db()->tableList()->run();
16
        if (\is_array($res->getData()) && !\in_array('tabletest', $res->getData(), true)) {
0 ignored issues
show
The method getData() does not exist on TBolier\RethinkQL\Response\Cursor. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        if (\is_array($res->/** @scrutinizer ignore-call */ getData()) && !\in_array('tabletest', $res->getData(), true)) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
17
            $this->r()->db()->tableCreate('tabletest')->run();
18
        }
19
    }
20
21
    public function tearDown()
22
    {
23
        $res = $this->r()->db()->tableList()->run();
24
        if (\is_array($res->getData()) && \in_array('tabletest', $res->getData(), true)) {
25
            $this->r()->db()->tableDrop('tabletest')->run();
26
        }
27
    }
28
29
    /**
30
     * @param int|string $id
31
     * @return ResponseInterface
32
     */
33
    protected function insertDocument($id): ResponseInterface
34
    {
35
        $res = $this->r()
36
            ->table('tabletest')
37
            ->insert([
38
                'id' => $id,
39
                'title' => 'Test document '.$id,
40
                'description' => 'A document description.',
41
            ])
42
            ->run();
43
44
        return $res;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $res could return the type TBolier\RethinkQL\Response\Cursor which is incompatible with the type-hinted return TBolier\RethinkQL\Response\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
45
    }
46
47
    /**
48
     * @param int|string $id
49
     * @param int $number
50
     * @return ResponseInterface
51
     */
52
    protected function insertDocumentWithNumber($id, int $number): ResponseInterface
53
    {
54
        $res = $this->r()
55
            ->table('tabletest')
56
            ->insert([
57
                'id' => $id,
58
                'title' => 'Test document '.$id,
59
                'number' => $number,
60
                'description' => 'A document description.',
61
            ])
62
            ->run();
63
64
        return $res;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $res could return the type TBolier\RethinkQL\Response\Cursor which is incompatible with the type-hinted return TBolier\RethinkQL\Response\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
65
    }
66
67
    /**
68
     * @param int|string $id
69
     * @param \DateTimeInterface $dateTime
70
     * @return ResponseInterface
71
     */
72
    protected function insertDocumentWithDate($id, \DateTimeInterface $dateTime): ResponseInterface
73
    {
74
        $res = $this->r()
75
            ->table('tabletest')
76
            ->insert([
77
                'id' => $id,
78
                'title' => 'Test document '.$id,
79
                'date' => $dateTime->format(\Datetime::ATOM),
80
                'description' => 'A document description.',
81
            ])
82
            ->run();
83
84
        return $res;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $res could return the type TBolier\RethinkQL\Response\Cursor which is incompatible with the type-hinted return TBolier\RethinkQL\Response\ResponseInterface. Consider adding an additional type-check to rule them out.
Loading history...
85
    }
86
}
87