/** * @test * @group 1 **/ public function it_gets_the_product_presenter() { $row = new RowOrder(); $product = $this->getStandardProduct(); $product->save(); $row->product_id = $product->id; $presenter = $row->getProductPresenter(); $this->assertInstanceOf('Palmabit\\Catalog\\Presenters\\PresenterProducts', $presenter); $this->assertEquals($product->id, $presenter->id); }
/** * @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())); }
private function createTwoOrderWithPrice($price1, $price2) { $fist_row = ["order_id" => 1, "product_id" => 1, "quantity" => 1, "total_price" => $price1, "single_price" => $price1]; $second_row = ["order_id" => 1, "product_id" => 1, "quantity" => 1, "total_price" => $price2, "single_price" => $price2]; RowOrder::create($fist_row); RowOrder::create($second_row); }