You are here

protected function CommerceReportsSalesOverviewTestCase::_test in Commerce Reporting 7.4

4 calls to CommerceReportsSalesOverviewTestCase::_test()
CommerceReportsSalesOverviewTestCase::testMonthlyOverview in src/Tests/CommerceReportsSalesOverviewTestCase.php
CommerceReportsSalesOverviewTestCase::testOutsideOverviewScope in src/Tests/CommerceReportsSalesOverviewTestCase.php
CommerceReportsSalesOverviewTestCase::testTodayOverview in src/Tests/CommerceReportsSalesOverviewTestCase.php
CommerceReportsSalesOverviewTestCase::testYesterdayOverview in src/Tests/CommerceReportsSalesOverviewTestCase.php

File

src/Tests/CommerceReportsSalesOverviewTestCase.php, line 15

Class

CommerceReportsSalesOverviewTestCase

Namespace

Drupal\commerce_reports\Tests

Code

protected function _test($data = array()) {
  foreach ($data as $display => $information) {
    $report = views_get_view_result('commerce_reports_sales_overview', $display);
    $line = reset($report);
    foreach ($information as &$metric) {
      if (empty($metric)) {
        $metric = NULL;
      }
    }
    if (empty($line->field_data_commerce_order_total_commerce_order_total_amount)) {
      $amount = 0;
    }
    else {
      $amount = $line->field_data_commerce_order_total_commerce_order_total_amount;
    }
    if (empty($line->order_id)) {
      $sales = NULL;
    }
    else {
      $sales = $line->order_id;
    }
    $this
      ->assertEqual($information['count'], $sales, t('The expected amount of orders is equal to the derived amount of orders.'));
    $this
      ->assertEqual($information['amount'], $amount, t('The expected total amount is equal to the derived total amount.'));
  }
}