-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
result.phpt
73 lines (50 loc) · 1.62 KB
/
result.phpt
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
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* @testCase
* @dataProvider? ../../databases.ini
*/
namespace NextrasTests\Dbal;
use Nextras\Dbal\InvalidStateException;
use Nextras\Dbal\Utils\DateTimeImmutable;
use Tester\Assert;
require_once __DIR__ . '/../../bootstrap.php';
class ResultIntegrationTest extends IntegrationTestCase
{
public function testEmptyResult()
{
$result = $this->connection->query('SELECT * FROM books WHERE 1=2');
Assert::equal([], iterator_to_array($result));
}
public function testSetupNormalization()
{
$this->initData($this->connection);
$result = $this->connection->query('SELECT * FROM tag_followers ORDER BY tag_id, author_id');
$result->setValueNormalization(FALSE); // test reenabling
$result->setValueNormalization(TRUE);
$follower = $result->fetch();
Assert::same(1, $follower->tag_id);
Assert::same(1, $follower->author_id);
Assert::type(DateTimeImmutable::class, $follower->created_at);
Assert::same('2014-01-01 00:10:00', $follower->created_at->format('Y-m-d H:i:s'));
$result->setValueNormalization(FALSE);
$follower = $result->fetch();
if (defined('HHVM_VERSION')) {
Assert::same(2, $follower->tag_id);
Assert::same(2, $follower->author_id);
} else {
Assert::same('2', $follower->tag_id);
Assert::same('2', $follower->author_id);
}
Assert::type('string', $follower->created_at);
}
public function testSeek()
{
$this->initData($this->connection);
$result = $this->connection->query('SELECT * FROM books');
Assert::exception(function() use ($result) {
$result->seek(10);
}, InvalidStateException::class);
}
}
$test = new ResultIntegrationTest();
$test->run();