예제 #1
0
 /**
  * Extra test. Make sure a large amount of text can be uploaded by
  * synch.
  * @depends testSynchPut
  */
 public function testSynchPutLarge()
 {
     global $testTripId1;
     global $synchAuthToken;
     $largeText = $this->getLargeText(15000);
     $this->assertEquals(0, $this->countTestRows());
     $data = array('tripId' => $testTripId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'name' => 'Test Trip', 'description' => $largeText, 'bannerImg' => 'test-01.png', 'startDate' => '2015-09-01', 'endDate' => '2015-09-30', 'active' => 'Y', 'deleted' => 'Y', 'hash' => 'forced hash');
     $result = putApi('synchTrip.php', $data, $synchAuthToken);
     $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']);
     $this->assertEquals(1, $this->countTestRows());
     $object = new Trip($testTripId1);
     $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated());
     $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated());
     $this->assertEquals("Test Trip", $object->getName());
     $this->assertEquals($largeText, $object->getDescription());
     $this->assertEquals("test-01.png", $object->getBannerImg());
     $this->assertEquals("2015-09-01", $object->getStartDate());
     $this->assertEquals("2015-09-30", $object->getEndDate());
     $this->assertEquals("Y", $object->getActive());
     $this->assertEquals("Y", $object->getDeleted());
     $this->assertEquals('forced hash', $object->getHash());
 }
예제 #2
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());
 }