function test_query() { $infos = Test\Info::take(4); $first_info = $infos[0]; $this->assertEquals("info", $first_info->post_type); $this->assertEquals("publish", $first_info->post_status); $first_info->set_meta("show_at_home", true); $this->assertCount(1, Test\Info::all("meta_key=show_at_home&meta_value=1")); $rs = []; $query = ["meta_query" => [["key" => "show_at_home", "value" => "1"]]]; foreach (Test\Info::where($query) as $info) { $rs[] = $info->show_at_home; } $this->assertCount(1, $rs); $this->assertEquals("1", $rs[0]); $this->assertEquals("info", Test\Info::take([])->post_type); }
<?php require_once '/tmp/wordpress-tests-lib/includes/functions.php'; define("ART_LOGFILE", __DIR__ . "/db.log"); tests_add_filter('after_setup_theme', function () { require dirname(__DIR__) . "/vendor/autoload.php"; Test\Event::initialize(); Test\Info::initialize(); Test\Blog::initialize(); }); require '/tmp/wordpress-tests-lib/includes/bootstrap.php';