本文整理汇总了PHP中helper::getPaste方法的典型用法代码示例。如果您正苦于以下问题:PHP helper::getPaste方法的具体用法?PHP helper::getPaste怎么用?PHP helper::getPaste使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper
的用法示例。
在下文中一共展示了helper::getPaste方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTemplateRendersCorrectly
public function testTemplateRendersCorrectly()
{
$this->assertTag(array('id' => 'cipherdata', 'content' => htmlspecialchars(helper::getPaste()['data'], ENT_NOQUOTES)), $this->_content, 'outputs data correctly');
$this->assertTag(array('id' => 'errormessage', 'content' => self::$error), $this->_content, 'outputs error correctly');
$this->assertTag(array('id' => 'password'), $this->_content, 'password available if configured');
$this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('checked' => 'checked')), $this->_content, 'checked discussion if configured');
$this->assertTag(array('id' => 'opendisc'), $this->_content, 'discussions available if configured');
// testing version number in JS address, since other instances may not be present in different templates
$this->assertTag(array('tag' => 'script', 'attributes' => array('src' => 'js/zerobin.js?' . rawurlencode(self::$version))), $this->_content, 'outputs version correctly');
}
示例2: testFileBasedDataStoreWorks
public function testFileBasedDataStoreWorks()
{
$this->_model->delete(helper::getPasteId());
// storing pastes
$paste = helper::getPaste(array('expire_date' => 1344803344));
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste does not yet exist');
$this->assertTrue($this->_model->create(helper::getPasteId(), $paste), 'store new paste');
$this->assertTrue($this->_model->exists(helper::getPasteId()), 'paste exists after storing it');
$this->assertFalse($this->_model->create(helper::getPasteId(), $paste), 'unable to store the same paste twice');
$this->assertEquals(json_decode(json_encode($paste)), $this->_model->read(helper::getPasteId()));
// storing comments
$this->assertFalse($this->_model->existsComment(helper::getPasteId(), helper::getPasteId(), helper::getCommentId()), 'comment does not yet exist');
$this->assertTrue($this->_model->createComment(helper::getPasteId(), helper::getPasteId(), helper::getCommentId(), helper::getComment()) !== false, 'store comment');
$this->assertTrue($this->_model->existsComment(helper::getPasteId(), helper::getPasteId(), helper::getCommentId()), 'comment exists after storing it');
$comment = json_decode(json_encode(helper::getComment()));
$comment->id = helper::getCommentId();
$comment->parentid = helper::getPasteId();
$this->assertEquals(array($comment->meta->postdate => $comment), $this->_model->readComments(helper::getPasteId()));
// deleting pastes
$this->_model->delete(helper::getPasteId());
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste successfully deleted');
$this->assertFalse($this->_model->existsComment(helper::getPasteId(), helper::getPasteId(), helper::getCommentId()), 'comment was deleted with paste');
$this->assertFalse($this->_model->read(helper::getPasteId()), 'paste can no longer be found');
}
示例3: testCommentDeletion
/**
* @expectedException Exception
* @expectedExceptionCode 64
*/
public function testCommentDeletion()
{
$pasteData = helper::getPaste();
$this->_model->getPaste(helper::getPasteId())->delete();
$paste = $this->_model->getPaste();
$paste->setData($pasteData['data']);
$paste->store();
$paste->getComment(helper::getPasteId())->delete();
}
示例4: testDeleteExpired
/**
* @runInSeparateProcess
*/
public function testDeleteExpired()
{
$this->reset();
$expiredPaste = helper::getPaste(array('expire_date' => 1000));
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste does not exist before being created');
$this->_model->create(helper::getPasteId(), $expiredPaste);
$this->assertTrue($this->_model->exists(helper::getPasteId()), 'paste exists before deleting data');
$_GET['pasteid'] = helper::getPasteId();
$_GET['deletetoken'] = 'does not matter in this context, but has to be set';
ob_start();
new zerobin();
$content = ob_get_contents();
$this->assertTag(array('id' => 'errormessage', 'content' => 'Paste does not exist'), $content, 'outputs error correctly');
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste successfully deleted');
}
示例5: testDeleteWithPost
/**
* @runInSeparateProcess
*/
public function testDeleteWithPost()
{
$this->reset();
$this->_model->create(helper::getPasteId(), helper::getPaste());
$this->assertTrue($this->_model->exists(helper::getPasteId()), 'paste exists before deleting data');
$_POST = array('action' => 'delete', 'deletetoken' => hash_hmac('sha1', helper::getPasteId(), serversalt::get()));
$_SERVER['QUERY_STRING'] = helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST';
ob_start();
new zerobin();
$content = ob_get_contents();
$response = json_decode($content, true);
$this->assertEquals(0, $response['status'], 'outputs status');
$this->assertFalse($this->_model->exists(helper::getPasteId()), 'paste successfully deleted');
}