Пример #1
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, $testUserId1, $testUserId1;
     // create the 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());
     $old_hash = $object->getHash();
     // change values and update the object
     $object->setRole('role-2');
     $object->setMessage('message 2');
     $object->setDeleted('Y');
     $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 = TripUser::findByHash($old_hash);
     $this->assertNotNull($object);
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testUserId1, $object->getUserId());
     $this->assertEquals('role-1', $object->getRole());
     $this->assertEquals('message', $object->getMessage());
     $this->assertEquals('N', $object->getDeleted());
     $this->assertEquals($old_hash, $object->getHash());
     // read the new object from the database and confirm that the new
     // values are returned
     $object = TripUser::findByHash($new_hash);
     $this->assertNotNull($object);
     $this->assertEquals($testTripId1, $object->getTripId());
     $this->assertEquals($testUserId1, $object->getUserId());
     $this->assertEquals('role-2', $object->getRole());
     $this->assertEquals('message 2', $object->getMessage());
     $this->assertEquals('Y', $object->getDeleted());
     $this->assertEquals($new_hash, $object->getHash());
 }
Пример #2
0
 /**
  * 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());
 }