public function commit() { $this->order->getConnection()->getPdo()->beginTransaction(); try { $this->order->save(); $this->storeOrderInSession(); $this->sendEmailToClient(); $this->sendEmailToAdmin(); $this->clearSession(); } catch (LoginRequiredException $e) { $this->logMailErrors(); } catch (Swift_TransportException $e) { $this->logMailErrors(); } catch (ValidationException $e) { $this->order->getConnection()->getPdo()->rollback(); $this->errors = $this->order->getErrors(); throw new InvalidException(); } $this->order->getConnection()->getPdo()->commit(); return $this; }
/** * @test * @expectedException Palmabit\Authentication\Exceptions\LoginRequiredException **/ public function it_throws_exception_if_no_user_is_logged() { $order = new Order(); $product = new Product(["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" => "10.00"]); $mock_row = m::mock('Palmabit\\Catalog\\Models\\RowOrder')->makePartial()->shouldReceive('setItem')->once()->with($product, 10)->andReturn(true)->getMock(); $mock_row->product_id = 10; $mock_row->quantity = 1; $mock_row->total_price = 1.0; $order->addRow($product, 10, $mock_row); $order->save(); }