Files
wp-graphql-woocommerce/tests/wpunit/ReportQueriesTest.php
T

190 lines
2.8 KiB
PHP
Raw Normal View History

2019-03-14 23:55:34 -04:00
<?php
2019-03-21 21:43:24 -04:00
class ReportQueriesTest extends \Codeception\TestCase\WPTestCase {
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function setUp() {
// before
parent::setUp();
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
// your set up methods here
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function tearDown() {
// your tear down methods here
// then
parent::tearDown();
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
// tests
public function testSalesReportQuery() {
$query = '
query {
report(type: "sales") {
totalSales
netSales
averageSales
totalOrder
totalItems
totalTax
totalShipping
totalRefunds
totalDiscount
totalsGroupedBy
totals
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testTopSellersReportQuery() {
$query = '
query {
report(type: "top") {
title
product {
id
}
quantity
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testCouponsTotalsQuery() {
$query = '
query {
report(type: "coupon") {
slug
name
total
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testCustomersTotalsQuery() {
$query = '
query {
report(type: "customer") {
slug
name
total
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testOrdersTotalsQuery() {
$query = '
query {
report(type: "order") {
slug
name
total
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testProductsTotalsQuery() {
$query = '
query {
report(type: "product") {
slug
name
total
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
public function testReviewsTotalsQuery() {
$query = '
query {
report(type: "review") {
slug
name
total
}
}
';
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$actual = do_graphql_request( $query );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
/**
* use --debug flag to view
*/
\Codeception\Util\Debug::debug( $actual );
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$expected = [];
2019-03-14 23:55:34 -04:00
2019-03-21 21:43:24 -04:00
$this->assertEquals( $expected, $actual );
}
}