function it_should_return_the_total_price_as_unit_price_times_the_quantity(Product $product) { $product->getPrice()->willReturn(10.0); $this->beConstructedWith($product, 2); $this->getTotalPrice()->shouldReturn(20.0); }
<body class="add-product"> <div class="container"> <div id="header"> <a href="/../shop/" class="btn btn-default">Shop</a> <a href="/../user/" class="btn btn-default">Users</a> <a href="/../user/AddUser.php" class="btn btn-default">Add User</a> <a href="/../products/index.php" class="btn btn-default">Products</a> <a href="/../products/AddProduct.php" class="btn btn-default">Add Product</a> <a href="/../orders/index.php" class="btn btn-default">Orders</a> </div> <?php if (isset($_POST['name']) && isset($_POST['price'])) { $product = new Product(); $product->setName($_POST['name']); $product->setPrice($_POST['price']); $date = new DateTime('now'); $product->setCreatedAt($date->getTimestamp()); $product_insert = new EntityManager(); $product_insert->insert($product); header("Location: index.php"); exit; } ?> <form method="post"> <div class="form-group"> <label for="name">Name</label> <input type="text" class="form-control" id="name" placeholder="Name" name="name">
/** * Set the distribution if applicable. * * @param Product $product * @param array $data */ protected function createDistribution(sosProduct $product, array $data) { if (isset($data['custom']) && $data['custom'] == 'on') { $product->groep_flag = 1; $product->distributies()->attach(static::DISTRIBUTION_ID, array('custom_prod' => '1')); //saving happens at the end of the creation process } }
<div class="container"> <div id="header"> <a href="/../shop/" class="btn btn-default">Shop</a> <a href="/../user/" class="btn btn-default">Users</a> <a href="/../user/AddUser.php" class="btn btn-default">Add User</a> <a href="/../products/index.php" class="btn btn-default">Products</a> <a href="/../products/AddProduct.php" class="btn btn-default">Add Product</a> <a href="/../orders/index.php" class="btn btn-default">Orders</a> </div> <?php if (isset($_POST['name']) && isset($_POST['price'])) { $date = new DateTime('now'); $date = $date->getTimestamp(); $product = new Product(); $product->setId($_GET['id']); $product->setName($_POST['name']); $product->setPrice($_POST['price']); $product->setUpdatedAt($date); $product_update = new EntityManager(); $product_update->update($product); header("Location: index.php"); exit; } if (isset($_GET['id'])) { $get_product = new EntityManager(); $product = $get_product->find('product', $_GET['id']); } ?>