-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathAbstractTDBMObjectTest.php
62 lines (56 loc) · 2.17 KB
/
AbstractTDBMObjectTest.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace TheCodingMachine\TDBM;
use PHPUnit\Framework\TestCase;
use function foo\func;
class AbstractTDBMObjectTest extends TestCase
{
public function testGetManyToManyRelationshipDescriptor()
{
$object = new TDBMObject();
$this->expectException(TDBMException::class);
$this->expectExceptionMessage('Could not find many to many relationship descriptor key for "foo"');
$object->_getManyToManyRelationshipDescriptor('foo');
}
public function testEmptyResultIterator()
{
$a = ResultIterator::createEmpyIterator();
foreach ($a as $empty) {
throw new \LogicException("Not supposed to iterate on an empty iterator.");
}
$this->assertEquals(0, $a->count());
$this->assertEquals(null, $a->first());
$this->assertEquals(null, isset($a[0])); //an empty resultIterator must implement arrayAccess
$this->assertEquals([], $a->toArray());
foreach ($a->map(function ($foo) {
}) as $empty) {
throw new \LogicException("Not supposed to iterate on an empty iterator.");
}
$c = $a->withOrder("who cares");
foreach ($c as $empty) {
throw new \LogicException("Not supposed to iterate on an empty iterator.");
}
$this->assertEquals(0, $c->count());
$d = $a->withParameters(["who cares"]);
foreach ($d as $empty) {
throw new \LogicException("Not supposed to iterate on an empty iterator.");
}
$this->assertEquals(0, $d->count());
}
public function testEmptyPageIterator()
{
$a = ResultIterator::createEmpyIterator();
$b = $a->take(0, 10);
foreach ($b as $empty) {
throw new \LogicException("Not supposed to iterate on an empty page iterator.");
}
$this->assertEquals(0, $b->count());
$this->assertEquals([], $b->toArray());
$this->assertEquals(0, $b->totalCount());
$c = $b->map(function ($foo) {
});
foreach ($c as $empty) {
throw new \LogicException("Not supposed to iterate on an empty iterator.");
}
$this->assertEquals([], $c->toArray());
}
}