本文整理汇总了PHP中Curl::mockResult方法的典型用法代码示例。如果您正苦于以下问题:PHP Curl::mockResult方法的具体用法?PHP Curl::mockResult怎么用?PHP Curl::mockResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Curl
的用法示例。
在下文中一共展示了Curl::mockResult方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_mock
function test_mock()
{
Curl::initMock();
Curl::mockResult("helloworld");
$curl = new Curl();
$res = $curl->exec();
$this->assertEquals($res, "helloworld");
}
示例2: test_push
function test_push()
{
RemoteSyncPlugin::instance()->install();
$postId = wp_insert_post(array('post_content' => 'content', 'post_name' => 'the-slug', 'post_title' => "Hello Post"));
update_option("rs_remote_site_url", "http://example.com/");
Curl::mockResult(array());
Curl::mockResult(array());
Curl::mockResult(array());
$op = new RemoteSyncOperations();
$op->push();
wp_trash_post($postId);
Curl::initMock();
Curl::mockResult(array(array("slug" => 'the-slug', 'revision' => "hello")));
Curl::mockResult(array());
Curl::mockResult(array());
$op = new RemoteSyncOperations();
$op->push();
}
示例3: test_state
function test_state()
{
update_option("rs_remote_site_url", "helloworld");
RemoteSyncPlugin::instance()->syncers = array(new SRTestSyncer("testType"));
RemoteSyncPlugin::instance()->install();
$syncer = RemoteSyncPlugin::instance()->getSyncerByType("testType");
$data = $syncer->getResource("slug1");
$rev = md5(json_encode($data));
Curl::mockResult(array(array("slug" => "onlyremote", "revision" => "05a1ad082ad35cad7aac7b18e232feb3"), array("slug" => "slug1", "revision" => $rev)));
$syncResources = SyncResource::findAllForType("testType", SyncResource::POPULATE_REMOTE | SyncResource::POPULATE_LOCAL);
$a = array();
foreach ($syncResources as $syncResource) {
$a[$syncResource->getSlug()] = $syncResource;
}
//echo "l: ".sizeof($syncResources);
$syncResource = $syncResources[0];
$data = $syncResource->getData();
$rev = $syncResource->getLocalRevision();
$this->assertEquals($a["onlyremote"]->getState(), SyncResource::NEW_REMOTE);
$this->assertEquals($a["onlylocal"]->getState(), SyncResource::NEW_LOCAL);
$this->assertEquals($a["slug1"]->getState(), SyncResource::UP_TO_DATE);
}