awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
864 stars 475 forks source link

Add Unit Tests for the REST API #3113

Open chriscct7 opened 9 years ago

chriscct7 commented 9 years ago

Normally I'd advocate against opening tickets regarding code coverage, but the EDD API class which people are starting to use and rely on has only 24% coverage, so low that we're starting to get reports of issues as people and extensions start using it more frequently like https://github.com/easydigitaldownloads/Easy-Digital-Downloads/issues/2979. For being the main API, we should try to get it to at least 80% for 2.4.

pippinsplugins commented 9 years ago

Agreed.

evertiro commented 9 years ago

Can do!

chriscct7 commented 9 years ago

Assigning to Dan per above. Might take back towards the end if it needs help

cklosowski commented 8 years ago

While release/2.6 is going through beta I'm going to try and get some more unit tests for the API in place, specifically with the differences between v1 and v2 (introduced in 2.6)

cklosowski commented 8 years ago

First pass at getting our API able to be unit tested. Now that I have it working locally, will see if Travis likes it, and keep working from here to see if we can get some more coverage on it prior to 2.6 release.

cklosowski commented 8 years ago

Not quite sure why, this passes locally 100% but on Travis any tests that require the API Authentication fail. I'd say it's related to $wp_query not getting correctly passed, however, other parts of the $wp_query variable end in the right place. I'll come back to this a bit later.

pippinsplugins commented 8 years ago

Could you try using the go_to() helper instead of manually setting query vars?

On Friday, May 27, 2016, Chris Klosowski notifications@github.com wrote:

Not quite sure why, this passes locally 100% but on Travis any tests that require the API Authentication fail. I'd say it's related to $wp_query not getting correctly passed, however, other parts of the $wp_query variable end in the right place. I'll come back to this a bit later.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/easydigitaldownloads/easy-digital-downloads/issues/3113#issuecomment-222274938, or mute the thread https://github.com/notifications/unsubscribe/AA_HfUhRVcwUxtLNqtVNRWE1IcBLtaK0ks5qF3_vgaJpZM4DgibQ .

cklosowski commented 8 years ago

@pippinsplugins I'll give that a shot next.

cklosowski commented 8 years ago

@pippinsplugins go_to() doesn't work because it's outside the context of the unit test's instantiation of the API. It basically just returns data like the API was never called.

pippinsplugins commented 8 years ago

Boo

cklosowski commented 8 years ago

Punting this from 2.6...I need to build a local docker container of the Travis Environment so I can mess with this to figure out why it'll pass locally, and not on Travis.