Пример #1
0
 public function testFileBasedAttachmentStoreWorks()
 {
     $this->_model->delete(helper::getPasteId());
     $original = $paste = helper::getPasteWithAttachment(array('expire_date' => 1344803344));
     $paste['meta']['attachment'] = $paste['attachment'];
     $paste['meta']['attachmentname'] = $paste['attachmentname'];
     unset($paste['attachment'], $paste['attachmentname']);
     $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($original)), $this->_model->read(helper::getPasteId()));
 }
Пример #2
0
 /**
  * @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();
 }
Пример #3
0
 /**
  * @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');
 }
Пример #4
0
 /**
  * @runInSeparateProcess
  */
 public function testJsonLdInvalid()
 {
     $this->reset();
     $paste = helper::getPasteWithAttachment();
     $this->_model->create(helper::getPasteId(), $paste);
     $_GET['jsonld'] = '../cfg/conf.ini';
     ob_start();
     new zerobin();
     $content = ob_get_contents();
     $this->assertEquals('{}', $content, 'does not output nasty data');
 }