Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Tests
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Jan 2016 at 12:32 UTC
Updated:
3 Feb 2016 at 10:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
vasikeHere is the first work on Cart tests.
- (only) Tests for product Add to cart form
About this patch and this issue
- I used OrderTestBase as it seems it covers some setup aspects.
- Add to Setup - Create an cart order and a second variation/product (first is in the OrderTestBase) to be used for these tests
- testProductAddToCartForm - get the second product page, press add to cart button and check if the product is added in the cart.
Todo:
- testCartPage - some checks on cart page
- testCartOrder - some checks on the order and the products in the cart.
- testCartChangeQuantity - update quantities on cart page
- testCartRemove - remove products from cart.
- other tests?
About the Cart page it seems there are some requirements:
- Product variations need Prices - as the OrderTestBase is used, maybe the first product variation there needs to have price
- Cart it seems requires 'access content' permission, which is a Node module permission, is this correct?
This means the cart module should have node dependency?
Comment #3
vasikeUpdated the patch:
- testCartOrder - some checks on the order and the products in the cart.
- testCartPage - some checks on cart page
- testCartChangeQuantity - update quantities on cart page
- testCartRemove - remove products from cart.
- move the product variation and product creation to testProductAddToCartForm, instead of having in the setUp.
- Add price data for the order line item and product varation, as they are requested in the cart.
- add node module dependency and 'access content' for the permissions - requested by cart page.
Are there other tests needed here?
Comment #4
vasike"rebased" the previous patch (#3).
It seems there were some changes: for Remove button in cart and permissions implementation (commit) for the CommerceTestBase
Comment #5
bojanz commented1) We can remove commerce, block from the modules list cause they're enabled by the parent class. We can also remove inline_entity_form and commerce_price cause they're dependencies, should be enabled automatically.
2) testProductAddToCartForm is out of scope, needs to be removed. We're only testing the cart page.
3) setUp() should use the cart provider to create a cart, and assign it to $this->cart. It should also assign $this->cartManager for later tests.
4) We don't need testCartOrder, we should assume that the cart provider and manager are functional (they need their own tests).
5) The other test methods should be merged together (test the presence of the quantity and remove elements, use them) to avoid unnecessary Drupal reinstalls between them.
Comment #6
vasikeThere is an updated patch following @bojanz directions:
1) keep only commerce_cart and node as dependencies
2) testProductAddToCartForm - removed, create new issue #2652768: AddToCartForm tests
3) cart and cartManager in setUp using Cart module API
4) testCartOrder removed
5) merge all tests left into testCartPage method.
extra
6) Move the test "setup" to a base class CartTestBase for other uses, for example for AddToCartForm tests.
Comment #7
bojanz commentedAttaching what was supposed to be the final version.
However, I can't get it to pass on Travis, even though it passes for both mglaman and me locally (run-tests.sh and Simpletest UI).
Test output is here: https://travis-ci.org/drupalcommerce/commerce/jobs/103381205
The view is rendered, as is the row, but there is no views form. The handlers don't seem to be invoked at all, I placed a die() in the Quantity handler's viewsForm() method, and got no change.
https://github.com/drupalcommerce/commerce/commit/7252aac7b9ed2c4dabcfc0... shows some other changes I tried to introduce, but which had no effect.
Comment #9
bojanz commentedCommitted, the test fail was due to a case sensitivity issue, fixed in https://github.com/drupalcommerce/commerce/commit/f3da642f301d4ff3d2b764...