예제 #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()));
 }
 protected function createProduct()
 {
     $description = "desc";
     $data = ["description" => $description, "code" => "code", "name" => "name", "slug" => "slug", "slug_lang" => "", "descrizione_long" => "", "in_evidenza" => 1];
     Product::create($data);
 }
예제 #3
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);
 }
 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]);
 }