コード例 #1
0
ファイル: JournalTest.php プロジェクト: egrivel/vacationblog
 /**
  * Extra test
  * Make sure that a long text is saved in the journal, one that has
  * at least more than 256 characters.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  */
 public function testLongText()
 {
     global $testTripId1, $testJournalId1;
     $longText = "This is a long text. This is a very long text. This is a ver, very long text. In fact, this text will just go on and on and on, for up to 400 characters. So when we set and retrieve this text, we will know for sure that the system supports these long texts. Of course, if this fails, we won't know any such thing for sure. Would that be to happen, we will have to go and spend some quality debugging time with the system.";
     $object = new Journal($testTripId1, $testJournalId1);
     $object->setJournalText($longText);
     $this->assertTrue($object->save());
     $object = new Journal($testTripId1, $testJournalId1);
     $this->assertEquals($longText, $object->getJournalText());
 }
コード例 #2
0
 /**
  * Extra test. Make sure a large amount of text can be uploaded by
  * synch.
  * @depends testSynchPut
  */
 public function testSynchPutLarge()
 {
     global $testTripId1, $testJournalId1;
     global $synchAuthToken;
     $largeText = $this->getLargeText(15000);
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'journalId' => $testJournalId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'userId' => 'user', 'journalDate' => '2015-09-30', 'journalTitle' => 'Journal Title', 'journalText' => $largeText, 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchJournal.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new Journal($testTripId1, $testJournalId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals('user', $object->getUserId());
     $this->assertEquals('2015-09-30', $object->getJournalDate());
     $this->assertEquals('Journal Title', $object->getJournalTitle());
     $this->assertEquals($largeText, $object->getJournalText());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
コード例 #3
0
ファイル: getJournal.php プロジェクト: egrivel/vacationblog
    $journalId = '';
    if (isset($_GET['journalId'])) {
        $journalId = $_GET['journalId'];
    }
    if ($tripId === '' || $journalId === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST);
    } else {
        $object = new Journal($tripId, $journalId);
        if ($object->getCreated() === null) {
            $response = errorResponse(RESPONSE_NOT_FOUND);
        } else {
            $response = successResponse();
            $response['tripId'] = $object->getTripId();
            $response['journalId'] = $object->getJournalId();
            $response['created'] = $object->getCreated();
            $response['updated'] = $object->getUpdated();
            $response['userId'] = $object->getUserId();
            $response['journalDate'] = $object->getJournalDate();
            $response['journalTitle'] = $object->getJournalTitle();
            $response['journalText'] = $object->getJournalText();
            $response['deleted'] = $object->getDeleted();
            if ($temp = $object->getPreviousJournal()) {
                $response['prevId'] = $temp->getJournalId();
            }
            if ($temp = $object->getNextJournal()) {
                $response['nextId'] = $temp->getJournalId();
            }
        }
    }
}
echo json_encode($response);