Closed (fixed)
Project:
Commerce Core
Version:
8.x-2.x-dev
Component:
Tests
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Sep 2015 at 09:16 UTC
Updated:
11 Oct 2016 at 21:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
imiksuComment #3
bojanz commentedAmong other things, we need a unit test for the CartProvider.
Comment #4
jefuri commentedComment #5
jefuri commentedPHPUnit test created for the cartprovider. First try ever on creating unit test, so please don't hate :P.
Comment #6
mglamanPR: https://github.com/commerceguys/commerce/pull/259
Tests failing. Cart also got added.
Comment #7
mglamanClosed PR; here is original patch from PR.
Comment #8
kekkisWorking on this as part of the Finnish monthly Drupal sprint.
Comment #9
imiksuI couldn't run the test. I'm not sure yet is it just me or the patch.
I was able to run OrderTest, but not the new
However, I was able to find the test on the list:
But not run it:
Comment #10
kekkisThe patch applies cleanly but as the namespace is wrong in the test class file, run-tests.sh cannot find the class. I will see if I can find the time to provide a PR for that.
Additionally, after fixing the namespace issue, the test fails because the StoreInterface does not provide a method called
id.Comment #11
borisson_I did a little bit of extra work on the test, it still fails - but went from 20+ messages to 4 - so that's an improvement I'd say.
Comment #12
borisson_Comment #13
borisson_Unit test is now green.
Comment #14
borisson_Went trough the test again to see if I could improve / add documentation, so attached is that.
I can open a pull-request as well if that's preferred?
Comment #15
bojanz commentedRetitling for clarity.
Reviewed the patch and consulted with mglaman.
The amount of mocking involved makes me think that the test is too bound to the actual implementation, and therefore not useful enough.
Our general policy has been to use kernel tests for functionality that's tied to the entity api, and I think we'd benefit a lot from doing the same here.
Comment #16
borisson_Changed this to a kernel test. Only contains the anonymous user part.
Comment #17
borisson_This should now test the same things as #14.
Comment #18
borisson_As discussed on irc, now uses
EntityKernelTestBaseas a baseclass.Comment #19
borisson_I changed the user creation with
$this->createUser();, this revealed that I actually loaded the anonymous user twice in the previous tests. So this now fails.Comment #20
mglamanAdded PR: https://github.com/drupalcommerce/commerce/pull/504
Comment #21
bojanz commentedTravis build failed:
https://travis-ci.org/drupalcommerce/commerce/jobs/162042536
Drupal\Core\Entity\Query\QueryException: 'cart' not found
Comment #22
mglamanPosted updated fix. Worked locally. There's a hack to install commerce_cart in kernel tests.
Comment #24
bojanz commentedCleaned up some more and added coverage for finalizeCart().