public function testDesactivarCategoria() { //se genera una categoria para despues darla de baja $nombre_cat = self::RandomString(15, FALSE, FALSE, FALSE); $desc = self::RandomString(25, FALSE, FALSE, FALSE); $c = ProductosController::NuevaCategoria($nombre = $nombre_cat, $descripcion = $desc, $id_categoria_padre = null); $this->assertInternalType("int", $c["id_categoria"], "---- 'testNuevaCategoria' 'id_categoria' NO ES UN ENTERO"); ProductosController::DesactivarCategoria($c["id_categoria"]); //se busca el prod recien insertado para ver si esta activo = 0 $res = ClasificacionProductoDAO::getByPK($c['id_categoria']); $this->assertEquals(0, $res->getActiva(), "---- 'testDesactivarCategoria' LA CATEGORIA NO SE DESACTIVÓ id_categoria= " . $c["id_categoria"]); }
public function testBuscarCategoriaPorQuery() { //se genera una categoria para despues buscarla por su nombre $nombre_cat = self::RandomString(15, FALSE, FALSE, FALSE); $desc = self::RandomString(25, FALSE, FALSE, FALSE); $c = ProductosController::NuevaCategoria($nombre = $nombre_cat, $descripcion = $desc, $id_categoria_padre = null); $this->assertInternalType("int", $c["id_categoria"], "---- 'testNuevaCategoria' 'id_categoria' NO ES UN ENTERO"); $res = ProductosController::BuscarCategoria($id_categoria = null, $id_categoria_padre = null, $query = $nombre_cat); $this->assertGreaterThanOrEqual(1, count($res['categorias']), "---- 'testBuscarProductosPorID_Categoria' SE DEBIÓ DE ENCONTRAR ALMENOS 1 RESULTADO CON nombre = " . $nombre_cat); }
protected function GenerateResponse() { try { $this->response = ProductosController::NuevaCategoria(isset($_POST['nombre']) ? $_POST['nombre'] : null, isset($_POST['activa']) ? $_POST['activa'] : true, isset($_POST['descripcion']) ? $_POST['descripcion'] : null, isset($_POST['id_categoria_padre']) ? $_POST['id_categoria_padre'] : null); } catch (Exception $e) { //Logger::error($e); throw new ApiException($this->error_dispatcher->invalidDatabaseOperation($e->getMessage())); } }