woocommerce/plugins/woocommerce-blocks/tests/php/StoreApi/Routes/CartExtensions.php

40 lines
1.0 KiB
PHP

<?php
/**
* Cart extensions route tests.
*/
namespace Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes;
use Automattic\WooCommerce\Blocks\Tests\StoreApi\Routes\ControllerTestCase;
use Automattic\WooCommerce\Blocks\StoreApi\Routes\RouteException;
use Automattic\WooCommerce\Blocks\Tests\Helpers\ValidateSchema;
/**
* Cart Controller Tests.
*/
class CartExtensions extends ControllerTestCase {
/**
* Test route registration.
*/
public function test_register_routes() {
$routes = rest_get_server()->get_routes();
$this->assertArrayHasKey( '/wc/store/cart/extensions', $routes );
}
/**
* Test getting cart with invalid namespace.
*/
public function test_post() {
$request = new \WP_REST_Request( 'POST', '/wc/store/cart/extensions' );
$request->set_header( 'X-WC-Store-API-Nonce', wp_create_nonce( 'wc_store_api' ) );
$request->set_body_params(
array(
'namespace' => 'test-plugin',
)
);
$response = rest_get_server()->dispatch( $request );
$this->assertEquals( 400, $response->get_status() );
}
}