コード例 #1
0
 /**
  * Test #11. SYNCH get an existent object.
  * @depends testDataWipedBeforeTest
  * @depends testGetExistent
  */
 public function testSynchGet()
 {
     global $testTripId1;
     global $testJournalId1;
     global $synchAuthToken;
     // Create the object and set attributes
     $object = new Journal($testTripId1, $testJournalId1);
     $object->setUserId('user');
     $object->setJournalDate('2015-09-30');
     $object->setJournalTitle('Journal Title');
     $object->setJournalText('Journal Text');
     $object->setDeleted('Y');
     // Save the object and confirm a row is added to the database
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $data = array('hash' => $object->getHash());
     $result = getApi('synchJournal.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertTrue(isset($result['tripId']));
     $this->assertTrue(isset($result['journalId']));
     $this->assertTrue(isset($result['created']));
     $this->assertTrue(isset($result['updated']));
     $this->assertTrue(isset($result['userId']));
     $this->assertTrue(isset($result['journalDate']));
     $this->assertTrue(isset($result['journalTitle']));
     $this->assertTrue(isset($result['journalText']));
     $this->assertTrue(isset($result['deleted']));
     $this->assertTrue(isset($result['hash']));
     $this->assertEquals($testTripId1, $result['tripId']);
     $this->assertEquals($testJournalId1, $result['journalId']);
     $this->assertEquals($object->getCreated(), $result['created']);
     $this->assertEquals($object->getUpdated(), $result['updated']);
     $this->assertEquals('user', $result['userId']);
     $this->assertEquals('2015-09-30', $result['journalDate']);
     $this->assertEquals('Journal Title', $result['journalTitle']);
     $this->assertEquals('Journal Text', $result['journalText']);
     $this->assertEquals('Y', $result['deleted']);
     $this->assertEquals($object->getHash(), $result['hash']);
 }
コード例 #2
0
ファイル: synchJournal.php プロジェクト: egrivel/vacationblog
 $data = getPostData();
 if (isset($data['tripId']) && isset($data['journalId']) && $data['tripId'] !== '' && $data['journalId'] !== '') {
     $tripId = $data['tripId'];
     $journalId = $data['journalId'];
     $object = new Journal($tripId, $journalId);
     if (isset($data['created'])) {
         $object->setCreated($data['created']);
     }
     if (isset($data['updated'])) {
         $object->setUpdated($data['updated']);
     }
     if (isset($data['userId'])) {
         $object->setUserId($data['userId']);
     }
     if (isset($data['journalDate'])) {
         $object->setJournalDate($data['journalDate']);
     }
     if (isset($data['journalTitle'])) {
         $object->setJournalTitle($data['journalTitle']);
     }
     if (isset($data['journalText'])) {
         $object->setJournalText($data['journalText']);
     }
     if (isset($data['deleted'])) {
         $object->setDeleted($data['deleted']);
     }
     if (isset($data['hash'])) {
         $object->setHash($data['hash']);
     }
     if ($object->save()) {
         $response = successResponse();
コード例 #3
0
ファイル: JournalTest.php プロジェクト: egrivel/vacationblog
 /**
  * Test #19. 
  * Iteration functions, when the journal entries have the same date
  * @depends testIterationDifferentDates
  */
 public function testIterationSameDate()
 {
     global $testTripId1;
     global $testJournalId1, $testJournalId2;
     global $testJournalId3, $testJournalId4;
     // Creat journal entries. For testing purposes, the entries will
     // be ordered in sequence (Id1, Id2, Id3, Id4). They are created
     // in this order, since we're testing on creation timestamp
     $journal1 = new Journal($testTripId1, $testJournalId1);
     $journal1->setJournalDate('2015-10-01');
     $this->assertTrue($journal1->save());
     $journal2 = new Journal($testTripId1, $testJournalId2);
     $journal2->setJournalDate('2015-10-01');
     $this->assertTrue($journal2->save());
     $journal3 = new Journal($testTripId1, $testJournalId3);
     $journal3->setJournalDate('2015-10-01');
     $this->assertTrue($journal3->save());
     $journal4 = new Journal($testTripId1, $testJournalId4);
     $journal4->setJournalDate('2015-10-01');
     $this->assertTrue($journal4->save());
     $test = Journal::getFirstJournal($testTripId1);
     $this->assertEquals($testTripId1, $test->getTripId());
     $this->assertEquals($testJournalId1, $test->getJournalId());
     $test = Journal::getLastJournal($testTripId1);
     $this->assertEquals($testTripId1, $test->getTripId());
     $this->assertEquals($testJournalId4, $test->getJournalId());
     $test = $journal1->getPreviousJournal();
     $this->assertNull($test);
     $test = $journal1->getNextJournal();
     $this->assertEquals($testJournalId2, $test->getJournalId());
     $test = $journal2->getPreviousJournal();
     $this->assertEquals($testJournalId1, $test->getJournalId());
     $test = $journal2->getNextJournal();
     $this->assertEquals($testJournalId3, $test->getJournalId());
     $test = $journal3->getPreviousJournal();
     $this->assertEquals($testJournalId2, $test->getJournalId());
     $test = $journal3->getNextJournal();
     $this->assertEquals($testJournalId4, $test->getJournalId());
     $test = $journal4->getPreviousJournal();
     $this->assertEquals($testJournalId3, $test->getJournalId());
     $test = $journal4->getNextJournal();
     $this->assertNull($test);
 }