Пример #1
0
 /**
  * Create product test.
  *
  * @return Product
  */
 public function testCreateProduct()
 {
     $product = new Product(null, 'ean2', 'test222');
     $productDao = new ProductDao(self::$pdo);
     $this->assertTrue($productDao->create($product));
     $this->assertFalse($productDao->create($product));
     $resultProduct = $productDao->getByEan('ean2');
     $this->assertEquals($product->getName(), $resultProduct->getName());
     return $resultProduct;
 }
Пример #2
0
<?php

require_once '../../vendor/autoload.php';
use Kata\Legacy\Product;
use Kata\Legacy\ProductDao;
try {
    //- add my product
    $product = new Product(null, '1234', 'Chicken');
    $productDao = new ProductDao();
    $result = $productDao->create($product);
    var_export($result);
    //- add my product - will delete
    $product = new Product(null, '878789', 'Turkey');
    $result = $productDao->create($product);
    var_export($result);
    //    $productToUpdate = ProductDao::getByEan('878789');
    //    $productToUpdate->name = 'Updated product turkey';
    //    $productToUpdate->ean = '9999';
    //    $result = ProductDao::modify($productToUpdate);
    //    var_export($result);
    //
    //    $result = ProductDao::getByEan('9999');
    //    var_export($result);
    //
    //    $result = ProductDao::getById(9);
    //    var_export($result);
    //
    //    $result = ProductDao::getById(1);
    //    var_export($result);
    //
    //    $productToDelete = ProductDao::getByEan('878789');