public function OrderReportGenerateFormTest::testGenerateOrderReports in Commerce Reporting 8
Tests bulk order report processing for a single order report type.
File
- tests/
src/ Functional/ OrderReportGenerateFormTest.php, line 126
Class
- OrderReportGenerateFormTest
- Tests the OrderReportGenerateForm.
Namespace
Drupal\Tests\commerce_reports\FunctionalCode
public function testGenerateOrderReports() {
$this
->assertEquals(self::ORDER_COUNT, count($this->orders));
$report_count = self::ORDER_COUNT * 2 / 3;
$this
->drupalGet('/admin/commerce/config/reports/generate-reports');
$this
->assertSession()
->statusCodeEquals(200);
// Check the integrity of the form and set values.
$this
->assertSession()
->fieldExists('plugin_id');
$this
->getSession()
->getPage()
->selectFieldOption('plugin_id', 'order_report');
$this
->getSession()
->getPage()
->pressButton('Generate');
$this
->checkForMetaRefresh();
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains("Generated reports for {$report_count} orders.");
$order_reports = OrderReport::loadMultiple();
$this
->assertEquals($report_count, count($order_reports), 'Reports created');
foreach ($order_reports as $id => $order_report) {
$this
->assertEquals('order_report', $order_report
->bundle());
}
}