Exemple #1
0
 /**
  * Test #15.
  * The findByHash function returns null for an non-existing hash.
  * @depends testSetAttributes
  */
 public function getHashGetNull()
 {
     global $testUserId1;
     // create a random object and save it
     $object = new User($testUserId1);
     $object->setName('Test User');
     $object->setExternalType('externaltype');
     $object->setExternalId('externalid');
     $object->setAccess('access');
     $object->setEmail('*****@*****.**');
     $object->setNotification('Y');
     $object->setTempCode('tempcode');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $object = Trip::findByHash('non-existent hash');
     $this->assertNull($object);
     $this->assertEquals(1, $this->countTestRows());
 }
Exemple #2
0
 /**
  * Test #15.
  * The findByHash function returns null for an non-existing hash.
  * @depends testSetAttributes
  */
 public function getHashGetNull()
 {
     global $testTripId1, $testMediaId1;
     // create a random object and save it
     $object = new Media($testTripId1, $testMediaId1);
     $object->setType('photo');
     $object->setCaption('Caption 1');
     $object->setTimestamp('2015-09-30 12:03:45');
     $object->setLocation('location');
     $object->setWidth('900');
     $object->setHeight('600');
     $object->setDeleted('N');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $object = Trip::findByHash('non-existent hash');
     $this->assertNull($object);
     $this->assertEquals(1, $this->countTestRows());
 }
 /**
  * Test #15.
  * The findByHash function returns null for an non-existing hash.
  * @depends testSetAttributes
  */
 public function getHashGetNull()
 {
     global $testTripId1, $testUserId1, $testUserId1;
     // create a random object and save it
     $object = new TripUser($testTripId1, $testUserId1);
     $object->setRole('role-1');
     $object->setMessage('message');
     $object->setDeleted('N');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $object = Trip::findByHash('non-existent hash');
     $this->assertNull($object);
     $this->assertEquals(1, $this->countTestRows());
 }
Exemple #4
0
<?php

include_once dirname(__FILE__) . "/../common/common.php";
include_once dirname(__FILE__) . '/../business/AuthB.php';
include_once dirname(__FILE__) . '/../database/Trip.php';
$auth = new AuthB();
if (!$auth->canSynchTrip()) {
    $response = errorResponse(RESPONSE_UNAUTHORIZED);
} else {
    if (isGetMethod()) {
        if (isset($_GET['hash'])) {
            $hash = $_GET['hash'];
            if ($hash === '') {
                $response = errorResponse(RESPONSE_BAD_REQUEST, 'Empty hash');
            } else {
                $trip = Trip::findByHash($hash);
                if ($trip === null) {
                    $response = errorResponse(RESPONSE_NOT_FOUND);
                } else {
                    $response = successResponse();
                    $response['tripId'] = $trip->getTripId();
                    $response['created'] = $trip->getCreated();
                    $response['updated'] = $trip->getUpdated();
                    $response['name'] = $trip->getName();
                    $response['description'] = $trip->getDescription();
                    $response['bannerImg'] = $trip->getBannerImg();
                    $response['startDate'] = $trip->getStartDate();
                    $response['endDate'] = $trip->getEndDate();
                    $response['active'] = $trip->getActive();
                    $response['deleted'] = $trip->getDeleted();
                    $response['hash'] = $trip->getHash();
Exemple #5
0
 /**
  * Test #17.
  * The findByHash function returns an object populated with previous
  * values if a hash for a previous instance is given.
  * @depends testUpdate
  * @depends testHashGetInstance
  */
 public function testHashOldInstance()
 {
     global $testTripId1;
     // create the object and save it
     $object = new Trip($testTripId1);
     $object->setName('Test Trip');
     $object->setDescription('Test Description');
     $object->setBannerImg('test-01.png');
     $object->setStartDate('2015-08-01');
     $object->setEndDate('2015-09-30');
     $object->setActive('Y');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $old_hash = $object->getHash();
     // change values and update the object
     $object->setName('Test Trip 2');
     $object->setDescription('Test Description 2');
     $object->setBannerImg('test-02.png');
     $object->setStartDate('2014-08-01');
     $object->setEndDate('2014-09-30');
     $object->setActive('N');
     $object->setDeleted('N');
     $this->assertTrue($object->save());
     $this->assertEquals(2, $this->countTestRows());
     $new_hash = $object->getHash();
     // read the object from the database and confirm that the old
     // values are returned
     $object = Trip::findByHash($old_hash);
     $this->assertNotNull($object);
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals('Test Trip', $object->getName());
     $this->assertEquals('Test Description', $object->getDescription());
     $this->assertEquals('test-01.png', $object->getBannerImg());
     $this->assertEquals('2015-08-01', $object->getStartDate());
     $this->assertEquals('2015-09-30', $object->getEndDate());
     $this->assertEquals('Y', $object->getActive());
     $this->assertEquals('Y', $object->getDeleted());
     $this->assertEquals($old_hash, $object->getHash());
     // read the new object from the database and confirm that the new
     // values are returned
     $object = Trip::findByHash($new_hash);
     $this->assertNotNull($object);
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals('Test Trip 2', $object->getName());
     $this->assertEquals('Test Description 2', $object->getDescription());
     $this->assertEquals('test-02.png', $object->getBannerImg());
     $this->assertEquals('2014-08-01', $object->getStartDate());
     $this->assertEquals('2014-09-30', $object->getEndDate());
     $this->assertEquals('N', $object->getActive());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals($new_hash, $object->getHash());
 }
 /**
  * Test #15.
  * The findByHash function returns null for an non-existing hash.
  * @depends testSetAttributes
  */
 public function getHashGetNull()
 {
     global $testTripId1;
     // create a random object and save it
     $object = new TripAttribute($testTripId1, 'name');
     $object->setValue('value');
     $object->setDeleted('Y');
     $this->assertTrue($object->save());
     $this->assertEquals(1, $this->countTestRows());
     $object = Trip::findByHash('non-existent hash');
     $this->assertNull($object);
     $this->assertEquals(1, $this->countTestRows());
 }