protected $_created; } THCFrame\Core\Test::add(function () use($database) { $example = new Example(); return $database->sync($example) instanceof THCFrame\Database\Connector\Mysql; }, "Model syncs", "Model"); THCFrame\Core\Test::add(function () use($database) { $example = new Example(array("name" => "foo", "created" => date("Y-m-d H:i:s"))); return $example->save() > 0; }, "Model inserts rows", "Model"); THCFrame\Core\Test::add(function () use($database) { return Example::count() == 1; }, "Model fetches number of rows", "Model"); THCFrame\Core\Test::add(function () use($database) { $example = new Example(array("name" => "foo", "created" => date("Y-m-d H:i:s"))); $example->save(); $example->save(); $example->save(); return Example::count() == 2; }, "Model saves single row multiple times", "Model"); THCFrame\Core\Test::add(function () use($database) { $example = new Example(array("id" => 1, "name" => "hello", "created" => date("Y-m-d H:i:s"))); $example->save(); return Example::first()->name == "hello"; }, "Model updates rows", "Model"); THCFrame\Core\Test::add(function () use($database) { $example = new Example(array("id" => 2)); $example->delete(); return Example::count() == 1; }, "Model deletes rows", "Model"); unset($database);
return $example->save() > 0; }, 'Model inserts rows', 'Model'); Test::add(function () { return Example::count() == 1; }, 'Model fetches number of rows', 'Model'); Test::add(function () { $example = new Example(array('name' => 'foo', 'created' => date("Y-m-d H:i:s"))); $example->save(); $example->save(); $example->save(); return Example::count() == 2; }, 'Model saves single row multiple times', 'Model'); Test::add(function () { $example = new Example(array('id' => 1, 'name' => 'hello', 'created' => date("Y-m-d H:i:s"))); $example->save(); return Example::first()->name == 'hello'; }, 'Model updates rows', 'Model'); Test::add(function () { $example = new Example(array('id' => 2)); $example->delete(); return Example::count() == 1; }, 'Model deletes rows', 'Model'); /////////////// Templates test $template = new Template(array("implementation" => new Template\Implementation\Standard())); Test::add(function () use($template) { return $template instanceof Template; }, "Template instantiates", "Template"); Test::add(function () use($template) { $template->parse("{echo 'hello world'}"); $processed = $template->process(); return $processed == "hello world";