Example #1
0
 /**
  * @test
  **/
 public function it_saves_db_data_on_commit_and_clear_session()
 {
     $service = new OrderServiceStub();
     $product = Product::create(["description" => "desc", "code" => "code", "name" => "name", "slug" => "slug", "slug_lang" => "", "description_long" => "", "featured" => 1, "public" => 1, "offer" => 1, "stock" => 4, "video_link" => "http://www.google.com/video/12312422313", "price" => "1.12"]);
     $user_stub = new User();
     $user_stub->id = 1;
     // mock authenticator
     $mock_auth = m::mock('StdClass')->shouldReceive('check')->once()->andReturn(true)->shouldReceive('getLoggedUser')->andReturn($user_stub)->shouldReceive('getLoggedUserProfile')->andReturn([])->getMock();
     $quantity = 10;
     App::instance('authenticator', $mock_auth);
     $service->addRow($product, $quantity);
     // mock mailer
     $mock_mailer = m::mock('Palmabit\\Library\\Email\\MailerInterface')->shouldReceive('sendTo')->andReturn(true)->getMock();
     App::instance('palmamailer', $mock_mailer);
     // mock auth helper
     $mock_auth_helper = m::mock('StdClass')->shouldReceive('getNotificationRegistrationUsersEmail')->once()->andReturn([""])->getMock();
     App::instance('authentication_helper', $mock_auth_helper);
     $service->commit();
     $row = RowOrder::first();
     $this->assertEquals(1, $row->id);
     $this->assertFalse(Session::has($service->getSessionKey()));
     $this->assertFalse(Session::has($service->getSessionMailOrder()));
 }
Example #2
0
 function get_product_select_arr()
 {
     return Product::whereLang(L::get_admin())->lists('name', 'id');
 }
 protected function createProduct()
 {
     $description = "desc";
     $data = ["description" => $description, "code" => "code", "name" => "name", "slug" => "slug", "slug_lang" => "", "descrizione_long" => "", "in_evidenza" => 1];
     Product::create($data);
 }
Example #4
0
 /**
  * @test
  **/
 public function it_change_quantity_of_an_order()
 {
     $order = new Order();
     $product = Product::create(["description" => "desc", "code" => "code", "name" => "name", "slug" => "slug", "slug_lang" => "", "description_long" => "", "featured" => 1, "public" => 1, "offer" => 1, "stock" => 4, "with_vat" => 1, "video_link" => "http://www.google.com/video/12312422313", "professional" => 1, "price1" => "1.00", "quantity_pricing_quantity" => 10, "quantity_pricing_enabled" => 1]);
     $mock_row = m::mock('Palmabit\\Catalog\\Models\\RowOrder')->makePartial()->shouldReceive('setItem')->once()->andReturn(true)->getMock();
     $mock_row->product_id = 1;
     $mock_row->quantity = 1;
     $mock_row->total_price = 1.0;
     $order->addRow($product, 10, $mock_row);
     // mock price calculation
     $mock_auth = m::mock('StdClass')->shouldReceive('check')->once()->andReturn(true)->getMock();
     App::instance("authenticator", $mock_auth);
     $order->changeRowQuantity(1, 3);
     $this->assertEquals(3, $order->getRowOrders()->first()->quantity);
 }
Example #5
0
 /**
  * changes a row quantity
  * @param $product_id
  * @param $quantity
  * @throws Palmabit\Library\Exceptions\NotFoundException
  */
 public function changeRowQuantity($product_id, $quantity)
 {
     $success = false;
     foreach ($this->row_orders as $order_row) {
         if ($order_row->product_id == $product_id) {
             $order_row->quantity = $quantity;
             try {
                 $order_row->total_price = $order_row->calculatePrice(Product::findOrFail($product_id), $quantity);
             } catch (ModelNotFoundException $e) {
                 throw new NotFoundException();
             }
             $success = true;
         }
     }
     if (!$success) {
         throw new NotFoundException();
     }
     return $this;
 }
 protected function createProductsForSearch()
 {
     Product::create(["code" => "1234", "name" => "name1", "slug" => "slug1", "slug_lang" => "slug_lang1", "lang" => 'it', "description" => "description", "description_long" => "description_long", "featured" => true, "public" => true, "offer" => true, "professional" => true, 'order' => 2]);
     Product::create(["code" => "1235", "name" => "name1", "slug" => "slug2", "slug_lang" => "slug_lang2", "lang" => 'it', "description" => "description", "description_long" => "description_long", "featured" => false, "public" => false, "offer" => false, "professional" => false, "order" => 1]);
 }
$body['order'] = Session::get($body['session_order_key']);
?>
<html lang="it">
<head>
    <meta charset="utf-8">
</head>
<body>
<h2>{{Config::get('authentication::app_name')}}: {{L::t('Order submitted successfully')}}</h2>
<div>
    {{L::t('Hello')}} {{ $body['email'] }}
    <strong>{{L::t('Order number')}}: {{$body['order']->id}} {{L::t('submitted successfully')}}.</strong>
    <br/>
    <strong>{{L::t('Order details')}}:</strong>
    @foreach($body['order']->getRowOrders() as $order)
            <?php 
$product = Product::find($order->product_id);
?>
        <ul>
            <li>
                <strong>{{L::t('Name')}}: </strong>{{$product->name}}
            </li>
            <li>
                <strong>{{L::t('Code')}}: </strong>{{$product->code}}
            </li>
            <li>
                <strong>{{L::t('Quantity')}}: </strong>{{$order->quantity}}
            </li>
            <li>
                <strong>{{L::t('Unitary price')}} </strong>{{round($order->total_price / $order->quantity, 2)}}
            </li>
            <li>