| 1 |
<?php |
| 2 |
/** |
| 3 |
* Test Services Order module functionality |
| 4 |
* |
| 5 |
* @package Orderable/Tests |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace OrderableTest; |
| 9 |
|
| 10 |
use WP_UnitTestCase; |
| 11 |
|
| 12 |
/** |
| 13 |
* Checkout module test class |
| 14 |
* |
| 15 |
* Tests for inc/modules/class-services-order.php |
| 16 |
*/ |
| 17 |
class TestServiceOrders extends WP_UnitTestCase { |
| 18 |
/** |
| 19 |
* Test services_filter function |
| 20 |
*/ |
| 21 |
public function test_services_filter() { |
| 22 |
ob_start(); |
| 23 |
|
| 24 |
\Orderable_Services_Order::services_filter(); |
| 25 |
|
| 26 |
$output = ob_get_clean(); |
| 27 |
|
| 28 |
$this->assertStringContainsString( 'name="orderable_service"', $output, 'The name of the field should be `orderable_service`' ); |
| 29 |
|
| 30 |
$this->assertStringContainsString( 'value=""', $output, 'An empty value attribute is required to show all services' ); |
| 31 |
$this->assertStringContainsString( 'All services', $output, '`All services` label is required' ); |
| 32 |
|
| 33 |
$this->assertStringContainsString( 'value="delivery"', $output, 'It should exist an option with value attribute set to `delivery`' ); |
| 34 |
$this->assertStringContainsString( 'Delivery', $output, 'It should exist an option with label set to `Delivery`' ); |
| 35 |
|
| 36 |
$this->assertStringContainsString( 'value="pickup"', $output, 'It should exist an option with value attribute set to `pickup`' ); |
| 37 |
$this->assertStringContainsString( 'Pickup', $output, 'It should exist an option with label set to `Pickup`' ); |
| 38 |
|
| 39 |
add_filter( |
| 40 |
'orderable_services_filter_options', |
| 41 |
function( $options ) { |
| 42 |
$options[] = 'table'; |
| 43 |
|
| 44 |
return $options; |
| 45 |
} |
| 46 |
); |
| 47 |
|
| 48 |
ob_start(); |
| 49 |
|
| 50 |
\Orderable_Services_Order::services_filter(); |
| 51 |
|
| 52 |
$output = ob_get_clean(); |
| 53 |
|
| 54 |
$this->assertStringContainsString( 'value="table"', $output, 'It should exist an option with a custom value added via `orderable_services_filter_options` filter' ); |
| 55 |
} |
| 56 |
} |
| 57 |
|