/** * A basic test example. * * @return void */ public function testSamplingCreationWithPost() { $product = App\Product::with('sensors')->get()->random(); $generic_sensors = App\GenericSensor::all(); $generic_sensor_with_random_function = array(); foreach ($generic_sensors as $generic_sensor) { // Humidity, Pressure, Temperature switch ($generic_sensor->alias) { case "Humidity": $generic_sensor_with_random_function[$generic_sensor->getKey()] = 'getRandomHumidityValue'; break; case "Temperature": $generic_sensor_with_random_function[$generic_sensor->getKey()] = 'getRandomTemperatureValue'; break; case "Pressure": $generic_sensor_with_random_function[$generic_sensor->getKey()] = 'getRandomPressureValue'; break; } } $newSamplings = array(); foreach ($product->sensors as $sensor) { $gs_id = $sensor->generic_sensor_id; if (!array_has($generic_sensor_with_random_function, $gs_id)) { continue; } $sensor_random_value = call_user_func(array($this, $generic_sensor_with_random_function[$gs_id])); array_push($newSamplings, array('generic_sensor_id' => $gs_id, 'value' => $sensor_random_value)); } $request_body = array('product_id' => App\Product::all()->random()->getkey(), 'samplings' => $newSamplings); $this->post('api/samplings/create', $request_body)->see('Created ' . count($newSamplings) . ' sampling(s)'); }
$series = [$producto]; } else { $series = App\Product::with('colors')->where('tags', $producto->tags)->get(); } $ids = array($producto->id); foreach ($series as $item) { $ids[] = $item->id; } $relacionados = array(); $prodCat = App\Product::with('colors')->where('category_id', $producto->category_id)->whereNotIn('id', $ids)->take(3)->get(); foreach ($prodCat as $item) { $ids[] = $item->id; $relacionados[] = $item; } if (count($relacionados) < 3) { $prodLast = App\Product::with('colors')->whereNotIn('id', $ids)->take(3 - count($relacionados))->get(); foreach ($prodLast as $item) { $ids[] = $item->id; $relacionados[] = $item; } } return view('pages.product-single', ['producto' => $producto, 'productos_relacionados' => $relacionados, 'series' => $series]); }); Route::get('/team', function () { $team = App\Person::with('gallery')->get(); return view('pages.team', ['team' => $team])->render(); }); Route::get('/garantia', function () { return view('pages.garantia')->render(); }); Route::get('/about', function () {