Skip to content

Commit

Permalink
Mozzila Sync: Change status check to Equals function
Browse files Browse the repository at this point in the history
  • Loading branch information
bartv2 committed Oct 26, 2012
1 parent 3189514 commit 942e385
Showing 1 changed file with 33 additions and 33 deletions.
66 changes: 33 additions & 33 deletions mozilla_sync/tests/storageservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ public function test_BasicScenario() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === "[]\n");

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

//
Expand Down Expand Up @@ -80,7 +80,7 @@ public function test_BasicScenario() {
$inputData = new OCA_mozilla_sync\InputData(json_encode($inputArray));
$this->request('/1.1/' . $this->userHash . '/storage/history/', $inputData);
$result = '{"modified":' . OCA_mozilla_sync\Utils::getMozillaTimestamp() . ',"success":["history1","history2","history3"],"failed":[]}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

//
Expand All @@ -92,7 +92,7 @@ public function test_BasicScenario() {
$result[] = '{"payload":"payload1","id":"history1","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp() .'","parentid":"3","predecessorid":"123","sortindex":"1","ttl":"5"}';
$result[] = '{"payload":"payload2","id":"history2","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp() .'","parentid":"3","predecessorid":"123","sortindex":"2","ttl":"5"}';
$result[] = '{"payload":"payload3","id":"history3","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp() .'","parentid":"3","predecessorid":"123","sortindex":"3","ttl":"5"}';
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue($this->outputContainInput($result, OCA_mozilla_sync\OutputData::$outputBuffer));

//
Expand All @@ -101,7 +101,7 @@ public function test_BasicScenario() {
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$result = '{"history":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

//
Expand All @@ -110,7 +110,7 @@ public function test_BasicScenario() {
$this->clearRequest();
OCA_mozilla_sync\Utils::$requestMethod = 'DELETE';
$this->request('/1.1/' . $this->userHash . '/storage/history/history1');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === strval(OCA_mozilla_sync\Utils::getMozillaTimestamp()));

//
Expand All @@ -121,15 +121,15 @@ public function test_BasicScenario() {
$result = array();
$result[] = '{"payload":"payload2","id":"history2","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp() .'","parentid":"3","predecessorid":"123","sortindex":"2","ttl":"5"}';
$result[] = '{"payload":"payload3","id":"history3","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp() .'","parentid":"3","predecessorid":"123","sortindex":"3","ttl":"5"}';
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue($this->outputContainInput($result, OCA_mozilla_sync\OutputData::$outputBuffer));

//
// get wbo
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/bookmarks/bookmark1');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

//
Expand All @@ -138,7 +138,7 @@ public function test_BasicScenario() {
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$result = '{"history":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

//
Expand All @@ -154,7 +154,7 @@ public function test_BasicScenario() {
'predecessorid' => '123');
$inputData = new OCA_mozilla_sync\InputData(json_encode($inputArray));
$this->request('/1.1/' . $this->userHash . '/storage/bookmarks/bookmark1', $inputData);
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === strval(OCA_mozilla_sync\Utils::getMozillaTimestamp()));

//
Expand All @@ -165,7 +165,7 @@ public function test_BasicScenario() {
$result = array();
$result[] = '"history":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"';
$result[] = '"bookmarks":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"';
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue($this->outputContainInput($result, OCA_mozilla_sync\OutputData::$outputBuffer));

//
Expand All @@ -174,7 +174,7 @@ public function test_BasicScenario() {
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/bookmarks/bookmark1');
$result = '{"sortindex":"1","payload":"bookmarkpayload","id":"bookmark1","modified":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

//
Expand All @@ -183,7 +183,7 @@ public function test_BasicScenario() {
$this->clearRequest();
OCA_mozilla_sync\Utils::$requestMethod = 'DELETE';
$this->request('/1.1/' . $this->userHash . '/storage/bookmarks');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === strval(OCA_mozilla_sync\Utils::getMozillaTimestamp()));

//
Expand All @@ -192,7 +192,7 @@ public function test_BasicScenario() {
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$result = '{"history":"'.OCA_mozilla_sync\Utils::getMozillaTimestamp().'"}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

//
Expand All @@ -202,31 +202,31 @@ public function test_BasicScenario() {
$_SERVER['HTTP_X_CONFIRM_DELETE'] = '1';
OCA_mozilla_sync\Utils::$requestMethod = 'DELETE';
$this->request('/1.1/' . $this->userHash . '/storage/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === strval(OCA_mozilla_sync\Utils::getMozillaTimestamp()));

//
// info collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '[]'."\n");

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?full=1');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/bookmarks');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

}
Expand All @@ -243,7 +243,7 @@ public function test_Modifiers() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === "[]\n");

//
Expand Down Expand Up @@ -271,7 +271,7 @@ public function test_Modifiers() {
$inputData = new OCA_mozilla_sync\InputData(json_encode($inputArray));
$this->request('/1.1/' . $this->userHash . '/storage/history/', $inputData);
$result = '{"modified":' . OCA_mozilla_sync\Utils::getMozillaTimestamp() . ',"success":[' . $successString . '],"failed":[]}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);
}

Expand All @@ -284,15 +284,15 @@ public function test_Modifiers() {
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$result = array();
$result[] = '"history":"'.$testTime[0].'"';
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue($this->outputContainInput($result, OCA_mozilla_sync\OutputData::$outputBuffer));

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?ids=history0,history2,history19,history110');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$result = array();
$result[] = '"history0"';
$result[] = '"history2"';
Expand All @@ -306,31 +306,31 @@ public function test_Modifiers() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?index_above=3&sort=index&limit=4&offset=2');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '["history27","history26","history25","history24"]'. "\n");

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?index_above=3&sort=index&limit=4&offset=50');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?index_below=1');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '["history0"]' . "\n");

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?older='. $testTime[1] . '&sort=oldest');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$result = array();
for($i = 10; $i < 20; $i++) {
$result[] = '"history' . $i . '"';
Expand All @@ -351,7 +351,7 @@ public function test_Modifiers() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?newer='. $testTime[2] . '&sort=newest');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);

$result = array();
for($i = 0; $i < 10; $i++) {
Expand All @@ -373,23 +373,23 @@ public function test_Modifiers() {
$this->clearRequest();
OCA_mozilla_sync\Utils::$requestMethod = 'DELETE';
$this->request('/1.1/' . $this->userHash . '/storage/history?older='. $testTime[1]);
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === strval(OCA_mozilla_sync\Utils::getMozillaTimestamp()));

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?older='. $testTime[1]. '&sort=oldest');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_NOT_FOUND);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_NOT_FOUND, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '');

//
// get collection
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/storage/history?newer='. $testTime[2]. '&sort=newest');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);

$result = array();
for($i = 0; $i < 10; $i++) {
Expand Down Expand Up @@ -417,7 +417,7 @@ public function test_DeleteOldWbo() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === "[]\n");

//
Expand All @@ -441,7 +441,7 @@ public function test_DeleteOldWbo() {
$inputData = new OCA_mozilla_sync\InputData(json_encode($inputArray));
$this->request('/1.1/' . $this->userHash . '/storage/history/', $inputData);
$result = '{"modified":' . OCA_mozilla_sync\Utils::getMozillaTimestamp() . ',"success":[' . $successString . '],"failed":[]}'."\n";
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === $result);

OCA_mozilla_sync\Utils::$testTime = $currentTime;
Expand All @@ -451,7 +451,7 @@ public function test_DeleteOldWbo() {
//
$this->clearRequest();
$this->request('/1.1/' . $this->userHash . '/info/collections/');
$this->assertTrue(OCA_mozilla_sync\Utils::$lastStatus == OCA_mozilla_sync\Utils::STATUS_OK);
$this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
$this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '[]' . "\n");
}

Expand Down

0 comments on commit 942e385

Please sign in to comment.