Ejemplo n.º 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']);
 }
Ejemplo n.º 2
0
         $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();
     } else {
         $response = errorResponse(RESPONSE_INTERNAL_ERROR);
     }
 } else {
     $response = errorResponse(RESPONSE_BAD_REQUEST, 'tripId or journalId not set');
 }
Ejemplo n.º 3
0
 /**
  * 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());
 }