예제 #1
0
 public static function setUpBeforeClass()
 {
     global $testTripId1, $testTripId2;
     $testTripId1 = '-test-trip-1';
     $testTripId2 = '-test-trip-2';
     $query = "DELETE FROM blogTrip " . "WHERE tripId='{$testTripId1}'" . "OR tripId='{$testTripId2}'";
     mysql_query($query);
     $trip = new Trip($testTripId1);
     $trip->setName('Test Trip 1');
     $trip->save();
     $trip = new Trip($testTripId2);
     $trip->setName('Test Trip 2');
     $trip->save();
 }
예제 #2
0
 public function testFindAllAuth()
 {
     global $testTripId1, $testTripId2;
     global $visitorAuthToken, $contribAuthToken;
     global $adminAuthToken, $synchAuthToken;
     $object = new Trip($testTripId1);
     $object->setName("Trip 1");
     $this->assertTrue($object->save());
     $object = new Trip($testTripId2);
     $object->setName("Trip 2");
     $this->assertTrue($object->save());
     $data = array();
     // general public is able to access this
     $result = getApi('findTrip.php', $data);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     // visitor is able to access this
     $result = getApi('findTrip.php', $data, $visitorAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     // contributor is able to access this
     $result = getApi('findTrip.php', $data, $contribAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     // admin is able to access this
     $result = getApi('findTrip.php', $data, $adminAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     // synch is not able to access this
     $result = getApi('findTrip.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_UNAUTHORIZED, $result['resultCode']);
 }
예제 #3
0
         $response = errorResponse(RESPONSE_BAD_REQUEST, 'Missing hash');
     }
 } else {
     if (isPutMethod()) {
         $data = getPostData();
         if (isset($data['tripId']) && $data['tripId'] !== '') {
             $tripId = $data['tripId'];
             $trip = new Trip($tripId);
             if (isset($data['created'])) {
                 $trip->setCreated($data['created']);
             }
             if (isset($data['updated'])) {
                 $trip->setUpdated($data['updated']);
             }
             if (isset($data['name'])) {
                 $trip->setName($data['name']);
             }
             if (isset($data['description'])) {
                 $trip->setDescription($data['description']);
             }
             if (isset($data['bannerImg'])) {
                 $trip->setBannerImg($data['bannerImg']);
             }
             if (isset($data['startDate'])) {
                 $trip->setStartDate($data['startDate']);
             }
             if (isset($data['endDate'])) {
                 $trip->setEndDate($data['endDate']);
             }
             if (isset($data['active'])) {
                 $trip->setActive($data['active']);
예제 #4
0
$auth = new AuthB();
if (!$auth->canPutTrip()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    if (isPutMethod()) {
        $data = getPostData();
        $tripId = '';
        if (isset($data['tripId'])) {
            $tripId = $data['tripId'];
        }
        if ($tripId === '') {
            $response = errorResponse(RESPONSE_BAD_REQUEST);
        } else {
            $object = new Trip($tripId);
            if (isset($data['name'])) {
                $object->setName($data['name']);
            }
            if (isset($data['description'])) {
                $object->setDescription($data['description']);
            }
            if (isset($data['bannerImg'])) {
                $object->setBannerImg($data['bannerImg']);
            }
            if (isset($data['startDate'])) {
                $object->setStartDate($data['startDate']);
            }
            if (isset($data['endDate'])) {
                $object->setEndDate($data['endDate']);
            }
            if (isset($data['active'])) {
                $object->setActive($data['active']);
예제 #5
0
 /**
  * Extra test. Different trips can have different values for the same
  * attribute.
  * @depends testSetAttributes
  * @depends testSaveEmptyObject
  * @depends testLoadExistent
  * @depends testSetAttributeValues
  */
 public function testSetAttributesOnSeparateTrips()
 {
     global $testTripId1;
     global $testTripId2;
     // Setting attributes for first trip
     $object = new Trip($testTripId1);
     $object->setName("Trip Name 1");
     $object->save();
     $object->setAttribute("attrib1", "value1");
     $object->setAttribute("attrib2", "value2");
     $this->assertEquals("value1", $object->getAttribute("attrib1"));
     $this->assertEquals("value2", $object->getAttribute("attrib2"));
     // Setting attributes for second trip
     $object = new Trip($testTripId2);
     $object->setName("Trip Name 2");
     $object->save();
     $object->setAttribute("attrib1", "value3");
     $object->setAttribute("attrib2", "value4");
     $this->assertEquals("value3", $object->getAttribute("attrib1"));
     $this->assertEquals("value4", $object->getAttribute("attrib2"));
     $object = new Trip($testTripId1);
     $this->assertEquals("value1", $object->getAttribute("attrib1"));
     $this->assertEquals("value2", $object->getAttribute("attrib2"));
     $object = new Trip($testTripId2);
     $this->assertEquals("value3", $object->getAttribute("attrib1"));
     $this->assertEquals("value4", $object->getAttribute("attrib2"));
 }