/**
  * Test #13. SYNCH request write new object.
  */
 public function testSynchPut()
 {
     global $testTripId1, $testUserId1;
     global $synchAuthToken;
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'userId' => $testUserId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'role' => 'maintainer', 'message' => 'Message TripUser 1', 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchTripUser.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new TripUser($testTripId1, $testUserId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals('maintainer', $object->getRole());
     $this->assertEquals('Message TripUser 1', $object->getMessage());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
Beispiel #2
0
 /**
  * Extra test
  * Make sure that a long text is saved in the comment, one that has
  * at least more than 256 characters.
  * @depends testSaveEmptyObject
  * @depends testSetAttributes
  */
 public function testLongText()
 {
     global $testTripId1, $testUserId1;
     $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 TripUser($testTripId1, $testUserId1);
     $object->setMessage($longText);
     $this->assertTrue($object->save());
     $object = new TripUser($testTripId1, $testUserId1);
     $this->assertEquals($longText, $object->getMessage());
 }
Beispiel #3
0
$auth = new AuthB();
if (!$auth->canGetMedia()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    $tripId = '';
    if (isset($_GET['tripId'])) {
        $tripId = $_GET['tripId'];
    }
    $userId = '';
    if (isset($_GET['userId'])) {
        $userId = $_GET['userId'];
    }
    if ($tripId === '' || $userId === '') {
        $response = errorResponse(RESPONSE_BAD_REQUEST);
    } else {
        $object = new TripUser($tripId, $userId);
        if ($object->getCreated() === null) {
            $response = errorResponse(RESPONSE_NOT_FOUND);
        } else {
            $response = successResponse();
            $response['tripId'] = $object->getTripId();
            $response['userId'] = $object->getUserId();
            $response['created'] = $object->getCreated();
            $response['updated'] = $object->getUpdated();
            $response['role'] = $object->getRole();
            $response['message'] = $object->getMessage();
            $response['deleted'] = $object->getDeleted();
        }
    }
}
echo json_encode($response);