Skip to content

Commit

Permalink
Merge pull request #298 from kidunot89/devops/stripe-test-skipped-pr
Browse files Browse the repository at this point in the history
Skip conditional added to stripe test
  • Loading branch information
kidunot89 authored Jun 15, 2020
2 parents 13a5bf0 + 71c53da commit 14f5316
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 168 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/testing-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ on:

jobs:
run:
env:
STRIPE_API_PUBLISHABLE_KEY: ${{ secrets.STRIPE_API_PUBLISHABLE_KEY }}
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -53,15 +56,13 @@ jobs:

- name: Run Tests w/ Docker.
env:
STRIPE_API_PUBLISHABLE_KEY: ${{ secrets.STRIPE_API_PUBLISHABLE_KEY }}
STRIPE_API_SECRET_KEY: ${{ secrets.STRIPE_API_SECRET_KEY }}
COVERAGE: ${{ matrix.coverage }}
DEBUG: ${{ matrix.debug }}
SKIP_TESTS_CLEANUP: ${{ matrix.coverage }}
run: bin/run-docker.sh run -t

- name: Push Codecoverage to Coveralls.io
if: matrix.coverage == 1
if: ${{ matrix.coverage == 1 && env.STRIPE_API_PUBLISHABLE_KEY != 0 }}
env:
COVERALLS_RUN_LOCALLY: 1
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions includes/data/class-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function resolve_crud_object( $id, AppContext $context ) {
if ( empty( $id ) || ! absint( $id ) ) {
return null;
}

$context->getLoader( 'wc_cpt' )->buffer( array( $id ) );
return new Deferred(
function () use ( $id, $context ) {
Expand Down Expand Up @@ -121,7 +121,7 @@ public static function resolve_order_item( $item ) {
*
* @param string $id - Tax rate ID.
* @param AppContext $context - AppContext object.
*
*
* @return Deferred object
*/
public static function resolve_tax_rate( $id, AppContext $context ) {
Expand Down Expand Up @@ -165,7 +165,7 @@ public static function resolve_shipping_method( $id ) {

/**
* Checks if the WooCommerce Session needs to be (re)initialized.
*
*
* @return bool True if (re)initialized.
*/
public static function maybe_initialize_session() {
Expand Down Expand Up @@ -208,7 +208,7 @@ public static function resolve_cart() {
*
* @param string $key Cart item key.
* @param AppContext $context AppContext object.
*
*
* @return Deferred object
*/
public static function resolve_cart_item( $key, AppContext $context ) {
Expand Down Expand Up @@ -244,7 +244,7 @@ public static function resolve_cart_fee( $id ) {
*
* @param int $id Downloadable item ID.
* @param AppContext $context AppContext object.
*
*
* @return Deferred object
*/
public static function resolve_downloadable_item( $id, AppContext $context ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/data/loader/class-wc-cpt-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function ( $split, \WP_Query $query ) {
$context = $this->context;
$customer_id = null;
$parent_id = null;

// Resolve post author for future capability checks.
switch ( $post_type ) {
case 'shop_order':
Expand Down
6 changes: 5 additions & 1 deletion tests/_support/Helper/crud-helpers/cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public function to_relay_id( $id ) {
}

public function add( ...$products ) {
$keys = array();

foreach( $products as $product ) {
if ( gettype( $product ) === 'array' ) {
if ( empty( $product['product_id'] ) ) {
Expand All @@ -16,7 +18,7 @@ public function add( ...$products ) {
continue;
}

WC()->cart->add_to_cart(
$keys[] = WC()->cart->add_to_cart(
$product['product_id'],
! empty( $product['quantity'] ) ? $product['quantity'] : 1,
! empty( $product['variation_id'] ) ? $product['variation_id'] : 0,
Expand All @@ -27,6 +29,8 @@ public function add( ...$products ) {
WC()->cart->add_to_cart( $product, 1 );
}
}

return $keys;
}

public function print_query( $id = 0 ) {
Expand Down
19 changes: 8 additions & 11 deletions tests/wpunit/CartMutationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@ public function setUp() {
$this->product = $this->getModule('\Helper\Wpunit')->product();
$this->variation = $this->getModule('\Helper\Wpunit')->product_variation();
$this->cart = $this->getModule('\Helper\Wpunit')->cart();

// Clear cart.
WC()->cart->empty_cart( true );
}

public function tearDown() {
\WC()->cart->empty_cart();
\WC()->cart->empty_cart( true );

parent::tearDown();
}
Expand Down Expand Up @@ -170,7 +167,7 @@ public function testAddToCartMutationWithProduct() {
$cart = WC()->cart;
$cart_item = $cart->get_cart_item( $key );
$this->assertNotEmpty( $cart_item );

// Check cart item data.
$expected = array(
'data' => array(
Expand Down Expand Up @@ -207,7 +204,7 @@ public function testAddToCartMutationWithProductVariation() {

// use --debug flag to view.
codecept_debug( $actual );

// Retrieve cart item key.
$this->assertArrayHasKey('data', $actual );
$this->assertArrayHasKey('addToCart', $actual['data'] );
Expand Down Expand Up @@ -319,7 +316,7 @@ public function testUpdateCartItemQuantitiesMutation() {

// use --debug flag to view.
codecept_debug( $actual );

// Check cart item data.
$expected = array(
'data' => array(
Expand Down Expand Up @@ -871,7 +868,7 @@ public function testApplyCouponMutationWithInvalidCoupons() {

/**
* Assertion One
*
*
* Can't pass coupon ID as coupon "code". Mutation should fail.
*/
$variables = array(
Expand All @@ -895,7 +892,7 @@ public function testApplyCouponMutationWithInvalidCoupons() {

/**
* Assertion Two
*
*
* Can't pass expired coupon code. Mutation should fail.
*/
$variables = array(
Expand All @@ -919,7 +916,7 @@ public function testApplyCouponMutationWithInvalidCoupons() {

/**
* Assertion Three
*
*
* Can't pass coupon already applied to the cart. Mutation should fail.
*/
$variables = array(
Expand Down Expand Up @@ -1117,4 +1114,4 @@ public function testAddFeeMutation() {

$this->assertEquals( $expected, $actual );
}
}
}
19 changes: 8 additions & 11 deletions tests/wpunit/CartQueriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,10 @@ public function setUp() {
$this->variation_helper = $this->getModule('\Helper\Wpunit')->product_variation();
$this->coupon_helper = $this->getModule('\Helper\Wpunit')->coupon();
$this->helper = $this->getModule('\Helper\Wpunit')->cart();

// Clear cart.
WC()->cart->empty_cart( true );
}

public function tearDown() {
// your tear down methods here
WC()->cart->empty_cart( true );

// then
parent::tearDown();
Expand Down Expand Up @@ -168,7 +165,7 @@ public function testCartItemConnection() {

/**
* Assertion Two
*
*
* Tests "needsShipping" parameter.
*/
$variables = array( 'needsShipping' => true );
Expand Down Expand Up @@ -203,7 +200,7 @@ public function testCartItemConnection() {

/**
* Assertion Three
*
*
* Tests "needsShipping" parameter reversed.
*/
$variables = array( 'needsShipping' => false );
Expand Down Expand Up @@ -333,7 +330,7 @@ public function testCartItemPagination() {

/**
* Assertion One
*
*
* Tests "first" parameter.
*/
$variables = array( 'first' => 2 );
Expand Down Expand Up @@ -370,7 +367,7 @@ function( $item ) {

/**
* Assertion Two
*
*
* Tests "after" parameter.
*/
$variables = array(
Expand Down Expand Up @@ -410,7 +407,7 @@ function( $item ) {

/**
* Assertion Three
*
*
* Tests "last" parameter.
*/
$variables = array( 'last' => 2 );
Expand Down Expand Up @@ -447,7 +444,7 @@ function( $item ) {

/**
* Assertion Four
*
*
* Tests "before" parameter.
*/
$variables = array( 'last' => 4, 'before' => $cart_items[4] );
Expand Down Expand Up @@ -482,4 +479,4 @@ function( $item ) {

$this->assertEquals( $expected, $actual );
}
}
}
Loading

0 comments on commit 14f5316

Please sign in to comment.