$row->list = [$row->list->get()];
$row->update();
$this->assertEquals([[0,1,2]], $row->list->get());
- $this->setExpectedException("PHPUnit_Framework_Error_Notice", "Indirect modification of overloaded element of pq\Gateway\Cell has no effect");
+ $this->setExpectedException("PHPUnit_Framework_Error_Notice",
+ "Indirect modification of overloaded element of pq\Gateway\Cell has no effect");
$row->list[0][0] = -1;
}
}
}
-class Hstore implements \pq\ConverterInterface
+class Hstore implements \pq\Converter
{
protected $types;
function __construct(\pq\Types $types) {
- $this->types = $types;
+ $this->types = $types["hstore"]->oid;
}
function convertTypes() {
- return [$this->types["hstore"]->oid];
+ return [$this->types];
}
- function convertFromString($string) {
+ function convertFromString($string, $type) {
return eval("return [$string];");
}
- function convertToString($data) {
+ function convertToString($data, $type) {
$string = "";
foreach ($data as $k => $v) {
$string .= "\"".addslashes($k)."\"=>";
}
public function testJsonSerialize() {
- $json = sprintf('[{"id":"1","created":"%s","counter":"-1","number":"-1.1","data":"yesterday","list":[-1,0,1],"prop":null}'
- .',{"id":"2","created":"%s","counter":"0","number":"0","data":"today","list":[0,1,2],"prop":null}'
- .',{"id":"3","created":"%s","counter":"1","number":"1.1","data":"tomorrow","list":[1,2,3],"prop":null}]',
- new \pq\DateTime("yesterday"),
- new \pq\DateTime("today"),
- new \pq\DateTime("tomorrow")
+ $yday = new \pq\DateTime("yesterday");
+ $tday = new \pq\DateTime("today");
+ $tmrw = new \pq\DateTime("tomorrow");
+
+ $yday->format = $tday->format = $tmrw->format = "Y-m-d H:i:s.u";
+
+ $json = sprintf('[{"id":1,"created":"%s","counter":-1,"number":-1.1,"data":"yesterday","list":[-1,0,1],"prop":null}'
+ .',{"id":2,"created":"%s","counter":0,"number":0,"data":"today","list":[0,1,2],"prop":null}'
+ .',{"id":3,"created":"%s","counter":1,"number":1.1,"data":"tomorrow","list":[1,2,3],"prop":null}]',
+ $yday, $tday, $tmrw
);
$this->assertJsonStringEqualsJsonString($json, json_encode($this->table->find()));
}