/** * Extra test. Make sure a large amount of text can be uploaded by * synch. * @depends testSynchPut */ public function testSynchPutLarge() { global $testTripId1, $testJournalId1; global $synchAuthToken; $largeText = $this->getLargeText(15000); $this->assertEquals(0, $this->countTestRows()); $data = array('tripId' => $testTripId1, 'journalId' => $testJournalId1, 'created' => '2015-10-01', 'updated' => '2015-10-02', 'userId' => 'user', 'journalDate' => '2015-09-30', 'journalTitle' => 'Journal Title', 'journalText' => $largeText, 'deleted' => 'Y', 'hash' => 'forced hash'); $result = putApi('synchJournal.php', $data, $synchAuthToken); $this->assertEquals(RESPONSE_SUCCESS, $result['resultCode']); $this->assertEquals(1, $this->countTestRows()); $object = new Journal($testTripId1, $testJournalId1); $this->assertEquals('2015-10-01 00:00:00.000000', $object->getCreated()); $this->assertEquals('2015-10-02 00:00:00.000000', $object->getUpdated()); $this->assertEquals('user', $object->getUserId()); $this->assertEquals('2015-09-30', $object->getJournalDate()); $this->assertEquals('Journal Title', $object->getJournalTitle()); $this->assertEquals($largeText, $object->getJournalText()); $this->assertEquals("Y", $object->getDeleted()); $this->assertEquals('forced hash', $object->getHash()); }
/** * 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, $testJournalId1, $testUserId1; global $testUserId2; // create the object and save it $object = new Journal($testTripId1, $testJournalId1); $object->setUserId($testUserId1); $object->setJournalDate('2015-09-30'); $object->setJournalTitle('Journal Title'); $object->setJournalText('journal text'); $object->setDeleted('N'); $this->assertTrue($object->save()); $this->assertEquals(1, $this->countTestRows()); $old_hash = $object->getHash(); // change values and update the object $object->setUserId($testUserId2); $object->setJournalDate('2015-10-01'); $object->setJournalTitle('Journal Title 2'); $object->setJournalText('journal text 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 = Journal::findByHash($old_hash); $this->assertNotNull($object); $this->assertEquals($testTripId1, $object->getTripId()); $this->assertEquals($testJournalId1, $object->getJournalId()); $this->assertEquals($testUserId1, $object->getUserId()); $this->assertEquals('2015-09-30', $object->getJournalDate()); $this->assertEquals('Journal Title', $object->getJournalTitle()); $this->assertEquals('journal text', $object->getJournalText()); $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 = Journal::findByHash($new_hash); $this->assertNotNull($object); $this->assertEquals($testTripId1, $object->getTripId()); $this->assertEquals($testJournalId1, $object->getJournalId()); $this->assertEquals($testUserId2, $object->getUserId()); $this->assertEquals('2015-10-01', $object->getJournalDate()); $this->assertEquals('Journal Title 2', $object->getJournalTitle()); $this->assertEquals('journal text 2', $object->getJournalText()); $this->assertEquals('Y', $object->getDeleted()); $this->assertEquals($new_hash, $object->getHash()); }