1 | <?php |
||
2 | |||
3 | namespace TheCodingMachine\TDBM; |
||
4 | |||
5 | use PHPUnit\Framework\TestCase; |
||
6 | |||
7 | use function foo\func; |
||
8 | |||
9 | class AbstractTDBMObjectTest extends TestCase |
||
10 | { |
||
11 | public function testGetManyToManyRelationshipDescriptor() |
||
12 | { |
||
13 | $object = new TDBMObject(); |
||
14 | $this->expectException(TDBMException::class); |
||
15 | $this->expectExceptionMessage('Could not find many to many relationship descriptor key for "foo"'); |
||
16 | $object->_getManyToManyRelationshipDescriptor('foo'); |
||
17 | } |
||
18 | |||
19 | public function testEmptyResultIterator() |
||
20 | { |
||
21 | $a = ResultIterator::createEmpyIterator(); |
||
22 | foreach ($a as $empty) { |
||
23 | throw new \LogicException("Not supposed to iterate on an empty iterator."); |
||
24 | } |
||
25 | $this->assertEquals(0, $a->count()); |
||
26 | $this->assertEquals(null, $a->first()); |
||
0 ignored issues
–
show
|
|||
27 | $this->assertEquals(null, isset($a[0])); //an empty resultIterator must implement arrayAccess |
||
28 | $this->assertEquals([], $a->toArray()); |
||
29 | foreach ($a->map(function ($foo) { |
||
30 | }) as $empty) { |
||
31 | throw new \LogicException("Not supposed to iterate on an empty iterator."); |
||
32 | } |
||
33 | $c = $a->withOrder("who cares"); |
||
34 | foreach ($c as $empty) { |
||
35 | throw new \LogicException("Not supposed to iterate on an empty iterator."); |
||
36 | } |
||
37 | $this->assertEquals(0, $c->count()); |
||
38 | $d = $a->withParameters(["who cares"]); |
||
39 | foreach ($d as $empty) { |
||
40 | throw new \LogicException("Not supposed to iterate on an empty iterator."); |
||
41 | } |
||
42 | $this->assertEquals(0, $d->count()); |
||
43 | } |
||
44 | |||
45 | public function testEmptyPageIterator() |
||
46 | { |
||
47 | $a = ResultIterator::createEmpyIterator(); |
||
48 | $b = $a->take(0, 10); |
||
49 | foreach ($b as $empty) { |
||
50 | throw new \LogicException("Not supposed to iterate on an empty page iterator."); |
||
51 | } |
||
52 | $this->assertEquals(0, $b->count()); |
||
53 | $this->assertEquals([], $b->toArray()); |
||
54 | $this->assertEquals(0, $b->totalCount()); |
||
55 | $c = $b->map(function ($foo) { |
||
56 | }); |
||
57 | foreach ($c as $empty) { |
||
58 | throw new \LogicException("Not supposed to iterate on an empty iterator."); |
||
59 | } |
||
60 | $this->assertEquals([], $c->toArray()); |
||
61 | } |
||
62 | } |
||
63 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.