Skip to content

Commit

Permalink
Tests for GTIN Input Hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
puntope committed Nov 18, 2024
1 parent d243821 commit a4e8e22
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input\SizeInput;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input\SizeSystemInput;
use Automattic\WooCommerce\GoogleListingsAndAds\Admin\Product\Attributes\Input\SizeTypeInput;
use Automattic\WooCommerce\GoogleListingsAndAds\Jobs\MigrateGTIN;
use Automattic\WooCommerce\GoogleListingsAndAds\Options\OptionsInterface;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\Adult;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\AgeGroup;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\AvailabilityDate;
Expand All @@ -36,6 +38,7 @@
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\SizeSystem;
use Automattic\WooCommerce\GoogleListingsAndAds\Product\Attributes\SizeType;
use Automattic\WooCommerce\GoogleListingsAndAds\Tests\Framework\UnitTest;
use PHPUnit\Framework\MockObject\MockObject;

/**
* Class AttributeInputCollectionTest
Expand All @@ -45,6 +48,17 @@
* @package Automattic\WooCommerce\GoogleListingsAndAds\Tests\Unit\Admin\Product\Attributes
*/
class AttributeInputCollectionTest extends UnitTest {

/** @var MockObject|OptionsInterface $options */
protected $options;
/**
* Runs before each test is executed.
*/
public function setUp(): void {
parent::setUp();
$this->options = $this->createMock( OptionsInterface::class );
}

public function test_adult_input() {
$input = new AdultInput();
$input
Expand Down Expand Up @@ -353,6 +367,36 @@ public function test_gtin_input() {
);
}

public function test_gtin_input_not_hidden() {
$input = new GTINInput();
$input->set_options_object( $this->options );
$this->options
->expects( $this->any() )
->method( 'get' )
->with( OptionsInterface::INSTALL_VERSION )
->willReturn( '2.8.6' );
$input
->set_id( GTIN::get_id() )
->set_name( GTIN::get_id() );
$input->set_field_visibility();
$this->assertFalse( $input->is_hidden() );
}

public function test_gtin_input_hidden() {
$input = new GTINInput();
$input->set_options_object( $this->options );
$this->options
->expects( $this->any() )
->method( 'get' )
->with( OptionsInterface::INSTALL_VERSION )
->willReturn( '2.8.7' );
$input
->set_id( GTIN::get_id() )
->set_name( GTIN::get_id() );
$input->set_field_visibility();
$this->assertTrue( $input->is_hidden() );
}

public function test_is_bundle_input() {
$input = new IsBundleInput();
$input
Expand Down

0 comments on commit a4e8e22

Please sign in to comment.