OrderByTest::testOrderByDesc()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 15
c 0
b 0
f 0
rs 9.9332
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
4
namespace TBolier\RethinkQL\IntegrationTest\Transformation;
5
6
use TBolier\RethinkQL\IntegrationTest\Operation\AbstractTableTest;
7
use TBolier\RethinkQL\Response\ResponseInterface;
8
9
class OrderByTest extends AbstractTableTest
10
{
11
    /**
12
     * @return void
13
     * @throws \Exception
14
     */
15
    public function testOrderByDesc(): void
16
    {
17
        $this->insertDocument(5);
18
        $this->insertDocument(4);
19
        $this->insertDocument(3);
20
        $this->insertDocument(2);
21
        $this->insertDocument(1);
22
23
        /** @var ResponseInterface $res */
24
        $res = $this->r()
25
            ->table('tabletest')
26
            ->orderBy($this->r()->desc('id'))
27
            ->run();
28
29
        $this->assertArraySubset(['id' => 5], $res->getData()[0]);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

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

29
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset(['id' => 5], $res->getData()[0]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
30
    }
31
32
    /**
33
     * @return void
34
     * @throws \Exception
35
     */
36
    public function testOrderByAsc(): void
37
    {
38
        $this->insertDocument(5);
39
        $this->insertDocument(4);
40
        $this->insertDocument(3);
41
        $this->insertDocument(2);
42
        $this->insertDocument(1);
43
44
        /** @var ResponseInterface $res */
45
        $res = $this->r()
46
            ->table('tabletest')
47
            ->orderBy($this->r()->asc('id'))
48
            ->run();
49
50
        $this->assertArraySubset(['id' => 1], $res->getData()[0]);
0 ignored issues
show
Deprecated Code introduced by
The function PHPUnit\Framework\Assert::assertArraySubset() has been deprecated: https://github.com/sebastianbergmann/phpunit/issues/3494 ( Ignorable by Annotation )

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

50
        /** @scrutinizer ignore-deprecated */ $this->assertArraySubset(['id' => 1], $res->getData()[0]);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
51
    }
52
}
53