コード例 #1
0
 /**
  * Tests the update funtion in the MeasureController
  * 
  * @return void
  */
 public function testIfUpdateWorks()
 {
     //Save again because teardown() dropped the db :(
     $this->runStore($this->inputNumeric);
     $this->runStore($this->inputAlphanumeric);
     $this->runStore($this->inputAutocomplete);
     $this->runStore($this->inputFreetext);
     $measurestored = Measure::orderBy('id', 'desc')->take(4)->get()->toArray();
     $measureUricAcid = Measure::where('name', 'LIKE', '%uric%')->orderBy('id', 'desc')->first();
     $uricMeasureRanges = array();
     $alphanumericRanges = array();
     $autoCompleteRanges = array();
     foreach ($measureUricAcid->measureRanges as $range) {
         $uricMeasureRanges[] = $range->id;
     }
     foreach (Measure::find($measurestored[2]['id'])->measureRanges as $range) {
         $alphanumericRanges[] = $range->id;
     }
     foreach (Measure::find($measurestored[1]['id'])->measureRanges as $range) {
         $autoCompleteRanges[] = $range->id;
     }
     // Update the Measure Types
     // The second argument is the test type ID
     $this->runUpdate($this->inputNumericUpdate, $measureUricAcid->id, $uricMeasureRanges);
     $this->runUpdate($this->inputAlphanumericUpdate, $measurestored[2]['id'], $alphanumericRanges);
     $this->runUpdate($this->inputAutocompleteUpdate, $measurestored[1]['id'], $autoCompleteRanges);
     $this->runUpdate($this->inputFreetextUpdate, $measurestored[0]['id'], 0);
     $measureupdated = Measure::orderBy('id', 'desc')->take(4)->get()->toArray();
     $measureNewUricAcid = Measure::find($measureUricAcid->id);
     // Check that the measure values for the uric acid measure were updated
     $this->assertEquals($measureNewUricAcid->name, $this->inputNumericUpdate[0]['name']);
     $this->assertEquals($measureNewUricAcid->measure_type_id, $this->inputNumericUpdate[0]['measure_type_id']);
     $this->assertEquals($measureNewUricAcid->unit, $this->inputNumericUpdate[0]['unit']);
     $this->assertEquals($measureNewUricAcid->description, $this->inputNumericUpdate[0]['description']);
     $this->assertEquals($measureupdated[2]['name'], $this->inputAlphanumericUpdate[0]['name']);
     $this->assertEquals($measureupdated[2]['measure_type_id'], $this->inputAlphanumericUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[2]['description'], $this->inputAlphanumericUpdate[0]['description']);
     $this->assertEquals($measureupdated[1]['name'], $this->inputAutocompleteUpdate[0]['name']);
     $this->assertEquals($measureupdated[1]['measure_type_id'], $this->inputAutocompleteUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[1]['description'], $this->inputAutocompleteUpdate[0]['description']);
     $this->assertEquals($measureupdated[0]['name'], $this->inputFreetextUpdate[0]['name']);
     $this->assertEquals($measureupdated[0]['measure_type_id'], $this->inputFreetextUpdate[0]['measure_type_id']);
     $this->assertEquals($measureupdated[0]['description'], $this->inputFreetextUpdate[0]['description']);
     $measurerangeupdated = MeasureRange::orderBy('id', 'desc')->take(6)->get()->toArray();
     $this->assertEquals($measurerangeupdated[5]['age_min'], $this->inputNumericUpdate[0]['agemin'][0]);
     $this->assertEquals($measurerangeupdated[5]['age_max'], $this->inputNumericUpdate[0]['agemax'][0]);
     $this->assertEquals($measurerangeupdated[5]['gender'], $this->inputNumericUpdate[0]['gender'][0]);
     $this->assertEquals($measurerangeupdated[5]['range_lower'], $this->inputNumericUpdate[0]['rangemin'][0]);
     $this->assertEquals($measurerangeupdated[5]['range_upper'], $this->inputNumericUpdate[0]['rangemax'][0]);
     $this->assertEquals($measurerangeupdated[4]['age_min'], $this->inputNumericUpdate[0]['agemin'][1]);
     $this->assertEquals($measurerangeupdated[4]['age_max'], $this->inputNumericUpdate[0]['agemax'][1]);
     $this->assertEquals($measurerangeupdated[4]['gender'], $this->inputNumericUpdate[0]['gender'][1]);
     $this->assertEquals($measurerangeupdated[4]['range_lower'], $this->inputNumericUpdate[0]['rangemin'][1]);
     $this->assertEquals($measurerangeupdated[4]['range_upper'], $this->inputNumericUpdate[0]['rangemax'][1]);
     $this->assertEquals($measurerangeupdated[3]['alphanumeric'], $this->inputAlphanumericUpdate[0]['val'][0]);
     $this->assertEquals($measurerangeupdated[2]['alphanumeric'], $this->inputAlphanumericUpdate[0]['val'][1]);
     $this->assertEquals($measurerangeupdated[1]['alphanumeric'], $this->inputAutocompleteUpdate[0]['val'][0]);
     $this->assertEquals($measurerangeupdated[0]['alphanumeric'], $this->inputAutocompleteUpdate[0]['val'][1]);
 }