예제 #1
0
 function test_getId()
 {
     $name = "Nike";
     $id = 1;
     $test_brand = new Brand($name, $id);
     $result = $test_brand->getId();
     $this->assertEquals(true, is_numeric($result));
 }
예제 #2
0
 /**
  * Get the Phone Model id from database
  * @param string|int $brand
  * @param string $phoneModel
  * @return int
  */
 public static function getId($brand, $phoneModel)
 {
     $brandId = is_numeric($brand) ? (int) $brand : \Brand::getId($brand);
     $model = static::fetchOne(array('brand_id' => $brandId, 'name' => $phoneModel));
     if ($model === false) {
         $model = static::create(array('brand_id' => $brandId, 'name' => $phoneModel));
     }
     return $model->id;
 }
예제 #3
0
 /**
  * Get the product ID from database
  * @param string|int $brand
  * @param string $productName
  * @return int
  */
 public static function getId($brand, $productName)
 {
     $brandId = is_numeric($brand) ? (int) $brand : \Brand::getId($brand);
     $product = static::fetchOne(array('brand_id' => $brandId, 'name' => $productName));
     if ($product === false) {
         $product = static::create(array('brand_id' => $brandId, 'name' => $productName));
     }
     return $product->id;
 }
예제 #4
0
 /**
  * Get the brand ID
  * @param string $brand
  * @return int
  */
 private function getBrandId($brand)
 {
     if ($brand === null || trim($brand) == '') {
         return null;
     }
     if (!isset($this->brandIds[$brand])) {
         $this->brandIds[$brand] = Brand::getId($brand);
     }
     return $this->brandIds[$brand];
 }
예제 #5
0
 public function insert(Category $category, Subcategory $subcategory, Brand $brand, Item $item)
 {
     //        $sql = "INSERT INTO item values (null, 'aalluu', 'asdfasd',true,true, '2015-10-10','asdfasf', 'asdfasd', 1, 1 ,1, 1)";
     $sql = "INSERT INTO item values (null, '" . $item->getTitle() . "','" . $item->getDetail() . "',true,false, '" . $item->getDate() . "', '" . $item->getLocation() . "','asfasf'," . $category->getId() . "," . $subcategory->getId() . ", 1 ," . $brand->getId() . ")";
     echo $sql;
     if ($this->conn->query($sql) === TRUE) {
         echo "Insert operation successful";
     } else {
         echo "Error inserting: ";
     }
 }
예제 #6
0
 function testFind()
 {
     $brand_name = "Air Jordan";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Nike";
     $test_brand2 = new Brand($brand_name2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }
예제 #7
0
 function testFind()
 {
     $name = "Clides";
     $test_brand = new Brand($name);
     $test_brand->save();
     $name2 = "Marthas";
     $test_brand2 = new Brand($name2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }
예제 #8
0
 function testGetId()
 {
     //Arrange
     $name = "addidas";
     $id = 1;
     $test_brand = new Brand($name, $id);
     //Act
     $result = $test_brand->getId();
     //Assert
     $this->assertEquals($id, $result);
 }
예제 #9
0
 function test_find()
 {
     //Arrange
     $brand_name = "Nike";
     $test_brand = new Brand($id, $brand_name);
     $test_brand->save();
     $brand_name2 = "Adidas";
     $test_brand2 = new Brand($id, $brand_name2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #10
0
 function testFind()
 {
     //Arrange
     $brand_name = "Nike";
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     $brand_name2 = "Reebok";
     $test_brand2 = new Brand($brand_name2, $id2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand2->getId());
     //assert
     $this->assertEquals($test_brand2, $result);
 }
예제 #11
0
 function testFind()
 {
     //Arrange
     $brand_name = "Feiyue";
     $test_brand = new Brand($brand_name, $id = null);
     $test_brand->save();
     $brand_name2 = "Kailai";
     $test_brand2 = new Brand($brand_name2, $id = null);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #12
0
 public function delete(Brand $brand)
 {
     $query = "DELETE FROM brand WHERE id = " . $brand->getId();
     $data = $this->db->exec($query);
     if ($data) {
         return true;
     } else {
         throw new Exception('Delete error');
     }
 }
예제 #13
0
 function test_brand_find()
 {
     //Arrange
     $brand_name = "Nike";
     $id1 = 1;
     $test_brand = new Brand($brand_name, $id1);
     $test_brand->save();
     $brand_name2 = "Converse";
     $id2 = 2;
     $test_brand2 = new Brand($brand_name2, $id2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #14
0
 function test_find()
 {
     //Arrange
     $brand_name = "La Sportiva";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Evolv";
     $test_brand2 = new Brand($brand_name2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #15
0
 function test_find()
 {
     //Arrange
     $name = "Nike";
     $website = "http://www.nike.com";
     $test_brand = new Brand($name, $website);
     $test_brand->save();
     $name2 = "Adidas";
     $website2 = "http://www.adidas.com";
     $test_brand2 = new Brand($name2, $website2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand2->getId());
     //Assert
     $this->assertEquals($test_brand2, $result);
 }
예제 #16
0
 function testFind()
 {
     $brand_name = "dr.martens";
     $new_brand = new Brand($brand_name);
     $new_brand->save();
     $brand_name2 = "adidas";
     $new_brand2 = new Brand($brand_name);
     $new_brand2->save();
     $result = Brand::find($new_brand->getId());
     $this->assertEquals($new_brand, $result);
 }
예제 #17
0
 function test_find()
 {
     //Arrange
     $brand_name = "SPEW BALANCE";
     $id = 1;
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     $brand_name2 = "LA SMEAR";
     $id2 = 2;
     $test_brand2 = new Brand($brand_name2, $id2);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #18
0
 function testFind()
 {
     //Arrange
     $brand_name = "Super Kicks";
     $test_brand = new Brand($brand_name);
     $test_brand->save();
     $brand_name2 = "Cool Shoes";
     $test_brand2 = new Brand($brand_name2);
     $test_brand->save();
     //Act
     $id = $test_brand->getId();
     $result = Brand::find($id);
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #19
0
 function testFindById()
 {
     //Arrange
     $name = "Brand 1";
     $test_brand = new Brand($name);
     $test_brand->save();
     $name2 = "Brand 2";
     $test_brand2 = new Brand($name2);
     $test_brand2->save();
     //Act
     $search_id = $test_brand->getId();
     $result = Brand::find($search_id);
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #20
0
 function test_getBrands()
 {
     //Arrange
     $brand_name = "Puma";
     $id = null;
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     $brand_name2 = "Adidas";
     $test_brand2 = new Brand($brand_name2, $id);
     $test_brand2->save();
     $store_name = "Footlocker";
     $test_store = new Store($store_name, $id);
     $test_store->save();
     //Act
     $test_store->addBrand($test_brand->getId());
     $test_store->addBrand($test_brand2->getId());
     //Assert
     $this->assertEquals($test_store->getBrands(), [$test_brand, $test_brand2]);
 }
예제 #21
0
 function test_deleteAllbrands()
 {
     $name = "Foot Locker";
     $test_store = new Store($name, $id);
     $test_store->save();
     $name = "Nike";
     $test_brand = new Brand($name, $id);
     $test_brand->save();
     $name2 = "Adidas";
     $test_brand2 = new Brand($name2, $id);
     $test_brand2->save();
     $test_store->addBrand($test_brand->getId());
     $test_store->addBrand($test_brand2->getId());
     $test_store->deleteAllBrands();
     $result = $test_store->getBrands();
     $this->assertEquals([], $result);
 }
예제 #22
0
 /**
  * Declares an association between this object and a Brand object.
  *
  * @param      Brand $v
  * @return     Series The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setBrand(Brand $v = null)
 {
     if ($v === null) {
         $this->setBrandId(NULL);
     } else {
         $this->setBrandId($v->getId());
     }
     $this->aBrand = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Brand object, it will not be re-added.
     if ($v !== null) {
         $v->addSeries($this);
     }
     return $this;
 }
예제 #23
0
 function test_find()
 {
     //arrange
     $name = "Running";
     $id = 1;
     $test_brand1 = new Brand($name, $id);
     $test_brand1->save();
     $name2 = "Walking";
     $id2 = 2;
     $test_brand2 = new Brand($name2, $id2);
     $test_brand2->save();
     //act
     $result = Brand::find($test_brand2->getId());
     //assert
     $this->assertEquals($test_brand2, $result);
 }
예제 #24
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Brand $value A Brand object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Brand $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
예제 #25
0
 function test_find()
 {
     //Arrange
     $brand_name = "Nike";
     $id = 1;
     $test_brand = new Brand($brand_name, $id);
     $test_brand->save();
     //Act
     $result = Brand::find($test_brand->getId());
     //Assert
     $this->assertEquals($test_brand, $result);
 }
예제 #26
0
 public function setBrand(Brand $brand)
 {
     $this->id_brand = $brand->getId();
     $this->brand = $brand;
     return true;
 }
예제 #27
0
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => false, 'store_update' => false));
});
// This route deletes specific store
$app->delete("/delete_store/{id}", function ($id) use($app) {
    $id = $_POST['store_id'];
    $store = Store::find($id);
    $store->delete();
    return $app['twig']->render('index.html.twig', array('stores' => Store::getAll(), 'form_check' => false));
});
$app->get("/form_brand", function () use($app) {
    $store = Store::find($_GET['store_id']);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => true, 'store_update' => false));
});
$app->post("/add_brand", function () use($app) {
    $name = $_POST['name'];
    $brand = new Brand($name, $id = null);
    $brand->save();
    $store_id = $_POST['store_id'];
    $store = Store::find($store_id);
    $store->addBrand($brand->getId());
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => false, 'store_update' => false));
});
// This route deletes a specific brand from a store
$app->delete("/delete_brand/{id}", function ($id) use($app) {
    $id = $_POST['brand_id'];
    $store_id = $_POST['store_id'];
    $store = Store::find($store_id);
    $store->deleteBrand($id);
    return $app['twig']->render('store.html.twig', array('store' => $store, 'brands' => $store->getBrands(), 'form_check' => false, 'store_update' => false));
});
return $app;
예제 #28
0
 function test_find()
 {
     //Arrange
     $name = "Nike";
     $id = null;
     $testbrande = new Brand($name, $id);
     $testbrande->save();
     $name2 = "Adidas";
     $test_brand2 = new Brand($name2, $id);
     $test_brand2->save();
     //Act
     $result = Brand::find($test_brand2->getId());
     //Assert
     $this->assertEquals($test_brand2, $result);
 }
 function testFind()
 {
     // Arrange
     $name = "Babbling Brooks";
     $test_Brand = new Brand($name);
     $test_Brand->save();
     $name2 = "Old Balance";
     $test_Brand2 = new Brand($name2);
     $test_Brand2->save();
     // Act
     $result = Brand::find($test_Brand2->getId());
     // Assert
     $this->assertEquals($test_Brand2, $result);
 }
예제 #30
0
 function test_find()
 {
     $test_name = "Helmut Lang";
     $test_id = 1;
     $test_brand = new Brand($test_name, $test_id);
     $test_brand->save();
     $test_name2 = "Y-3";
     $test_id2 = 2;
     $test_brand2 = new Brand($test_name2, $test_id2);
     $test_brand2->save();
     $result = Brand::find($test_brand->getId());
     $this->assertEquals($test_brand, $result);
 }