function test_setName() { $name = "Nike"; $test_brand = new Brand($name, $id); $test_brand->setName("Foot Action"); $result = $test_brand->getName(); $this->assertEquals("Foot Action", $result); }
function testSetName() { //Arrange $brand_name = "nike"; $test_brand = new Brand($brand_name); //Act $test_brand->setName("puma"); $result = $test_brand->getName(); //Assert $this->assertEquals("puma", $result); }
function testSetName() { //Arrange $brand_name = "La Sportiva"; $test_brand = new Brand($brand_name); //Act $test_brand->setName("Evolv"); $result = $test_brand->getName(); //Assert $this->assertEquals("Evolv", $result); }
function testSetName() { //Arrange $name = "addidas"; $test_brand = new Brand($name); $new_name = "nike"; //Act $test_brand->setName($new_name); $result = $test_brand->getName(); //Assert $this->assertEquals($new_name, $result); }
function test_setName() { //Arrange $name = "Running"; $id = 1; $test_brand = new Brand($name, $id); //Act $test_brand->setName("work"); $result = $test_brand->getName(); //Assert $this->assertEquals($result, "work"); }
function testSetName() { //Arrange $name = "Adidas"; $id = 1; $test_brand = new Brand($name, $id); //Act $test_brand->setName("Nike"); $result = $test_brand->getName(); //Assert $this->assertEquals("Nike", $result); }
public function importBrands(Import $entity, $output) { $em = $this->container->get('doctrine')->getManager(); $sql = ' SELECT m.id_marca, m.nombre, m.slug FROM `marca` AS m ' . ' ORDER BY m.id_marca '; // . ' LIMIT '.$entity->getLimitStart().', '.$entity->getLimitEnd(); $link = mysqli_connect($entity->getServer(), $entity->getUsername(), $entity->getPassword(), $entity->getDbname()) or die('No se pudo conectar: ' . mysqli_error($link)); $resultado = $link->query($sql); $arrayBrand = array(); if (mysqli_num_rows($resultado) > 0) { while ($fila = mysqli_fetch_assoc($resultado)) { if (!in_array(utf8_encode($fila['nombre']), $arrayBrand)) { //Create Brands $brand = new Brand(); $brand->setName(utf8_encode($fila['nombre'])); $brand->setAvailable(true); $em->persist($brand); $arrayBrand[] = utf8_encode($fila['nombre']); } } $em->flush(); } }
/** * @param $name * @param $description * @param array $errors * @return object * @throws Exception */ public function create($name, $description, $errors = array()) { $brand = new Brand($this->db); try { $brand->setName($name); } catch (Exception $e) { $errors[] = $e->getMessage(); } try { $brand->setDescription($description); } catch (Exception $e) { $errors[] = $e->getMessage(); } if (count($errors) == 0) { $name = $this->db->quote($brand->getName()); $description = $this->db->quote($brand->getDescription()); $query = "INSERT INTO brand (name, description) VALUES(" . $name . ", " . $description . ")"; $data = $this->db->exec($query); if ($data) { $id = $this->db->lastInsertId(); if ($id) { try { $brand = $this->findById($id); return $brand; } catch (Exception $e) { $errors[] = $e->getMessage(); return $errors; } } else { throw new Exception('Last insert error'); } } else { throw new Exception('Insert error'); } } else { return $errors; } }