Skip to content

Commit

Permalink
Merge pull request #2543 from woocommerce/tweak/default-tax-2491
Browse files Browse the repository at this point in the history
Set default tax_rate to destination
  • Loading branch information
joemcgill authored Aug 22, 2024
2 parents 0bb6163 + d6f5658 commit c4bbdf0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ protected function get_schema_properties(): array {
'destination',
'manual',
],
'default' => 'destination',
],
'website_live' => [
'type' => 'boolean',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace Automattic\WooCommerce\GoogleListingsAndAds\Tests\Unit\API\Site\Controllers\MerchantCenter;

use Automattic\WooCommerce\GoogleListingsAndAds\API\Site\Controllers\MerchantCenter\SettingsController;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Tests\Framework\RESTControllerUnitTest;

/**
* Class SettingsControllerTest
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Tests\Unit\API\Site\Controllers\MerchantCenter
*/
class SettingsControllerTest extends RESTControllerUnitTest {

/** @var SettingsController $controller */
protected $controller;

/** @var MockObject|OptionsInterface $options */
protected $options;

protected const ROUTE = '/wc/gla/mc/settings';

public function setUp(): void {
parent::setUp();

$this->controller = new SettingsController( $this->server );

$this->options = $this->createMock( OptionsInterface::class );
$this->controller->set_options_object( $this->options );
$this->controller->register();
}

public function test_default_tax_rate_settings() {
$response = $this->do_request( self::ROUTE );

$this->assertEquals( 'destination', $response->get_data()['tax_rate'] );
$this->assertEquals( 200, $response->get_status() );
}

public function test_default_tax_rate_settings_post() {
$response = $this->do_request( self::ROUTE, 'POST', [] );

$this->assertEquals( 'destination', $response->get_data()['data']['tax_rate'] );
$this->assertEquals( 200, $response->get_status() );
}
}

0 comments on commit c4bbdf0

Please sign in to comment.