public function testInsertDuplicateMeasurement()
 {
     // No two measurements should have the same index
     $myDb = DBMaker::create('sensordatarepotest');
     Database::clearDB();
     $db = Database::getDB('sensordatarepotest', 'C:\\xampp\\myConfig.ini');
     $duplicateTest = array('measurement_index' => 1, 'measurement_value' => 0.0, 'measurement_timestamp' => '', 'sensor_id' => 1, 'sensorType' => 'HEADING', 'sequenceType' => 'SEQUENTIAL');
     $duplicateMeasurement = new Measurement($duplicateTest);
     $beforeCount = count(MeasurementsDB::getMeasurementsBy());
     $newMeasurement = MeasurementsDB::addMeasurement($duplicateMeasurement);
     $this->assertGreaterThan(0, $newMeasurement->getErrorCount(), 'The inserted measurement should return with an error');
     $afterCount = count(MeasurementsDB::getMeasurementsBy());
     $this->assertEquals($afterCount, $beforeCount, 'The database should have no additional measurements after the insertion attempt');
 }
 private function newMeasurement()
 {
     $measurement = null;
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $measurement = new Measurement($_POST);
     }
     $_SESSION['measurement'] = $measurement;
     if (is_null($measurement) || $measurement->getErrorCount() != 0) {
         MeasurementView::showNew();
     } else {
         $newMeasurement = MeasurementsDB::addMeasurement($measurement);
         if ($newMeasurement->getErrorCount() == 0) {
             $_SESSION['measurement'] = $newMeasurement;
         }
         SensorView::show();
         header('Location: /' . $_SESSION['base'] . '/sensor/show/' . $_SESSION['sensor']->getSensorId());
     }
 }