2019-09-23 18:07:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Automattic\WooCommerce\Blocks\Tests\Domain\Package;
|
|
|
|
|
|
|
|
use \WP_UnitTestCase;
|
|
|
|
use Automattic\WooCommerce\Blocks\Domain\Package as TestedPackage;
|
2020-11-17 07:46:12 +00:00
|
|
|
use Automattic\WooCommerce\Blocks\Domain\Services\FeatureGating;
|
2019-09-23 18:07:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tests the Package class
|
|
|
|
*
|
|
|
|
* @since $VID:$
|
|
|
|
*/
|
|
|
|
class Package extends WP_UnitTestCase {
|
|
|
|
|
|
|
|
private function get_package() {
|
2020-11-17 07:46:12 +00:00
|
|
|
return new TestedPackage( '1.0.0', __DIR__, new FeatureGating() );
|
2019-09-23 18:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function test_get_version() {
|
|
|
|
$this->assertEquals( '1.0.0', $this->get_package()->get_version() );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_get_path() {
|
|
|
|
$package = $this->get_package();
|
|
|
|
// test without relative
|
2019-12-09 16:44:28 +00:00
|
|
|
$this->assertEquals( __DIR__ . '/', $package->get_path() );
|
2019-09-23 18:07:13 +00:00
|
|
|
|
|
|
|
//test with relative
|
2019-12-09 16:44:28 +00:00
|
|
|
$expect = __DIR__ . '/build/test';
|
2019-09-23 18:07:13 +00:00
|
|
|
$this->assertEquals( $expect, $package->get_path( 'build/test') );
|
|
|
|
}
|
|
|
|
|
|
|
|
public function test_get_url() {
|
|
|
|
$package = $this->get_package();
|
|
|
|
$test_url = plugin_dir_url( __FILE__ );
|
|
|
|
// test without relative
|
|
|
|
$this->assertEquals( $test_url, $package->get_url() );
|
|
|
|
|
|
|
|
//test with relative
|
|
|
|
$this->assertEquals(
|
|
|
|
$test_url . 'build/test',
|
|
|
|
$package->get_url( 'build/test' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|