Fix phpunit

This commit is contained in:
Emili Castells Guasch 2025-03-26 11:31:38 +01:00
parent 7fdb10d53b
commit 5b9796832b
3 changed files with 37 additions and 45 deletions

View file

@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="tests/PHPUnit/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<directory suffix=".php">./modules/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./tests/PHPUnit</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/PHPUnit/bootstrap.php" backupGlobals="false" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./modules/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./tests/PHPUnit</directory>
</testsuite>
</testsuites>
</phpunit>

21
phpunit.xml.dist.bak Normal file
View file

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="tests/PHPUnit/bootstrap.php"
backupGlobals="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<directory suffix=".php">./modules/</directory>
</whitelist>
</filter>
<testsuites>
<testsuite name="unit">
<directory suffix="Test.php">./tests/PHPUnit</directory>
</testsuite>
</testsuites>
</phpunit>

View file

@ -11,42 +11,20 @@ use function Brain\Monkey\Functions\when;
class ActivationDetectorTest extends TestCase {
public function test_returns_direct_if_not_attached_via_woocommerce_paths() {
public function test_returns_direct_if_not_installed_via_woocommerce_paths() {
when( 'get_option' )->justReturn( [] );
$detector = new ActivationDetector();
$this->assertEquals( InstallationPathEnum::DIRECT, $detector->detect_activation_path() );
}
public function test_returns_core_profiler_if_attached_via_core_profiler() {
public function test_returns_core_profiler_if_installed_via_woocommerce_path() {
expect( 'get_option' )
->with( 'woocommerce_onboarding_profile', array() )
->andReturn( [
'business_extensions' => [
'woocommerce-paypal-payments'
],
] );
->with( 'woocommerce_paypal_branded' )
->andReturn('payments_settings' );
$detector = new ActivationDetector();
$this->assertEquals( InstallationPathEnum::CORE_PROFILER, $detector->detect_activation_path() );
}
public function test_returns_payment_settings_if_attached_via_payments_settings_page() {
expect( 'get_option' )
->with( 'woocommerce_payments_nox_profile', array() )
->andReturn( [
'extensions' => [
'attached' => [
[
'slug' => 'woocommerce-paypal-payments',
]
],
],
] );
$detector = new ActivationDetector();
$this->assertEquals( InstallationPathEnum::PAYMENT_SETTINGS, $detector->detect_activation_path() );
}
}