MCPcopy Create free account
hub / github.com/apecloud/myduckserver / run

Method run

compatibility/pg/php/pg_test.php:84–123  ·  view source on GitHub ↗
($conn)

Source from the content-addressed store, hash-verified

82 }
83
84 public function run($conn) {
85 try {
86 echo "Running test: " . $this->query . "\n";
87 $st = $conn->prepare($this->query);
88 $st->execute();
89 if ($st->columnCount() == 0) {
90 if (count($this->expectedResults) != 0) {
91 echo "Expected " . count($this->expectedResults) . " rows, got 0\n";
92 return false;
93 }
94 echo "Returns 0 rows\n";
95 return true;
96 }
97 $rows = $st->fetchAll(PDO::FETCH_NUM);
98 if (count($rows[0]) != count($this->expectedResults[0])) {
99 echo "Expected " . count($this->expectedResults[0]) . " columns, got " . count($rows[0]) . "\n";
100 return false;
101 }
102 foreach ($rows as $i => $row) {
103 $row = array_map('strval', $row);
104 foreach ($row as $j => $value) {
105 $value = trim($value);
106 $expectedValue = trim($this->expectedResults[$i][$j]);
107 if ($value !== $expectedValue) {
108 echo "Expected: " . $expectedValue . ", got: " . $value . "\n";
109 return false;
110 }
111 }
112 }
113 echo "Returns " . count($rows) . " rows\n";
114 if (count($rows) != count($this->expectedResults)) {
115 echo "Expected " . count($this->expectedResults) . " rows\n";
116 return false;
117 }
118 return true;
119 } catch (PDOException $e) {
120 echo $e->getMessage() . "\n";
121 return false;
122 }
123 }
124}
125
126PGTest::main(array_slice($argv, 1));

Callers 1

runTestsMethod · 0.45

Calls 1

executeMethod · 0.80

Tested by

no test coverage detected