Skip to content

Commit 87109cf

Browse files
committed
add tests for dec38
1 parent 228f7d7 commit 87109cf

File tree

1 file changed

+38
-28
lines changed

1 file changed

+38
-28
lines changed

tests/dec38Test.php

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
11
<?php
2-
// require 'monetdb/php_monetdb.php';
3-
4-
// $db = monetdb_connect("sql", "localhost", $argv[1], "monetdb", "monetdb", $argv[2]) or die(monetdb_last_error());
5-
6-
// $res = monetdb_query('START TRANSACTION;') or die(monetdb_last_error());
7-
// while ( $row = monetdb_fetch_assoc($res) ) { print_r($row); }
8-
9-
// $res = monetdb_query('CREATE TABLE php_dec38 (d38_0 DECIMAL(38,0), d38_19 DECIMAL(38,19), d38_38 DECIMAL(38,38));') or die(monetdb_last_error());
10-
// while ( $row = monetdb_fetch_assoc($res) ) { print_r($row); }
11-
12-
// $res = monetdb_query('INSERT INTO php_dec38 VALUES (12345678901234567899876543210987654321, 1234567890123456789.9876543210987654321, .12345678901234567899876543210987654321);') or die(monetdb_last_error());
13-
// while ( $row = monetdb_fetch_assoc($res) ) { print_r($row); }
14-
15-
// $res = monetdb_query('SELECT * FROM php_dec38;') or die(monetdb_last_error());
16-
// while ( $row = monetdb_fetch_assoc($res) ) { print_r($row); }
17-
18-
// $res = monetdb_query('SELECT * FROM php_dec38;') or die(monetdb_last_error());
19-
// $cols = monetdb_num_fields($res);
20-
// for ($i = 0; $i < $cols; $i++) {
21-
// print(monetdb_field_name($res, $i)."\t");
22-
// }
23-
// print("\n");
24-
// while ($row = @monetdb_fetch_row($res)) {
25-
// for ($i = 0; $i < $cols; $i++) {
26-
// print($row[$i]."\t");
27-
// }
28-
// print("\n");
29-
// }
2+
use PHPUnit\Framework\TestCase;
3+
use MonetDB\Connection;
4+
5+
require_once(__DIR__. '../../src/include.php');
6+
7+
final class dec38Test extends TestCase {
8+
public $conn;
9+
10+
public function setUp(): void
11+
{
12+
$this->conn = new Connection("127.0.0.1", 50000, "monetdb", "monetdb", "temp");
13+
}
14+
15+
public function testBigIntTable(): void
16+
{
17+
$res = $this->conn->Query("CREATE TABLE php_dec38 (d38_0 DECIMAL(38,0), d38_19 DECIMAL(38,19), d38_38 DECIMAL(38,38));");
18+
19+
$this->assertCount(0, $res);
20+
}
21+
22+
public function testInsertBigInt(): void
23+
{
24+
$res = $this->conn->Query("INSERT INTO php_dec38 VALUES (12345678901234567899876543210987654321, 1234567890123456789.9876543210987654321, .12345678901234567899876543210987654321);");
25+
26+
$this->assertCount(0, $res);
27+
}
28+
29+
public function testSelectBigInt(): void
30+
{
31+
$res = $this->conn->Query("SELECT * FROM php_dec38");
32+
$res_arr = iterator_to_array($res);
33+
34+
$this->assertEquals($res_arr[1]["d38_0"], "12345678901234567899876543210987654321");
35+
$this->assertEquals($res_arr[1]["d38_19"], "1234567890123456789.9876543210987654321");
36+
$this->assertEquals($res_arr[1]["d38_38"], "0.12345678901234567899876543210987654321");
37+
}
38+
39+
}
3040
?>

0 commit comments

Comments
 (0)