示例#1
0
 public function test_DeleteOldWbo()
 {
     $currentTime = OCA_mozilla_sync\Utils::getMozillaTimestamp();
     $testTime = $currentTime - 1000;
     //
     // info collection
     //
     $this->clearRequest();
     $this->request('/1.1/' . $this->userHash . '/info/collections/');
     $this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
     $this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === "[]\n");
     //
     // post collection
     //
     $this->clearRequest();
     OCA_mozilla_sync\Utils::$testTime = $testTime;
     OCA_mozilla_sync\Utils::$requestMethod = 'POST';
     $successString = '';
     $inputArray = array();
     for ($i = 0; $i < 10; $i++) {
         $inputArray[] = array('payload' => 'payload' . $i, 'id' => 'history' . $i, 'sortindex' => $i + 1, 'ttl' => 100);
         if ($i > 0) {
             $successString .= ',';
         }
         $successString .= '"history' . $i . '"';
     }
     $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->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;
     //
     // info collection
     //
     $this->clearRequest();
     $this->request('/1.1/' . $this->userHash . '/info/collections/');
     $this->assertEquals(OCA_mozilla_sync\Utils::STATUS_OK, OCA_mozilla_sync\Utils::$lastStatus);
     $this->assertTrue(OCA_mozilla_sync\OutputData::$outputBuffer === '[]' . "\n");
 }