Skip to content

Commit 50c0403

Browse files
committed
Replaced PHPUnit attributes with annotations
1 parent e8a1982 commit 50c0403

File tree

4 files changed

+58
-42
lines changed

4 files changed

+58
-42
lines changed

tests/Html/Input/BooleanInputTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
namespace Rollbar\WordPress\Tests\Html\Input;
44

5-
use PHPUnit\Framework\Attributes\CoversClass;
6-
use Rollbar\WordPress\Html\Input\AbstractInput;
75
use Rollbar\WordPress\Html\Input\BooleanInput;
86
use Rollbar\WordPress\Tests\BaseTestCase;
97

10-
#[CoversClass(BooleanInput::class)]
11-
#[CoversClass(AbstractInput::class)]
128
class BooleanInputTest extends BaseTestCase
139
{
1410
private BooleanInput $subject;

tests/PluginTest.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace Rollbar\WordPress\Tests;
44

5-
use PHPUnit\Framework\Attributes\DataProvider;
6-
use PHPUnit\Framework\Attributes\PreserveGlobalState;
7-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
85
use Rollbar\Payload\Level;
96
use Rollbar\Rollbar;
107
use Rollbar\WordPress\Plugin;
@@ -56,26 +53,32 @@ public function testConfigure(): void
5653
self::assertEquals($expected, $output->getEnvironment());
5754
}
5855

59-
#[RunInSeparateProcess]
60-
#[PreserveGlobalState(false)]
56+
/**
57+
* @runInSeparateProcess
58+
* @preserveGlobalState disabled
59+
*/
6160
public function testDisableAdmin(): void
6261
{
6362
self::assertFalse(Plugin::disabledAdmin());
6463
define('ROLLBAR_DISABLE_ADMIN', true);
6564
self::assertTrue(Plugin::disabledAdmin());
6665
}
6766

68-
#[RunInSeparateProcess]
69-
#[PreserveGlobalState(false)]
67+
/**
68+
* @runInSeparateProcess
69+
* @preserveGlobalState disabled
70+
*/
7071
public function testDisableAdmin2(): void
7172
{
7273
self::assertFalse(Plugin::disabledAdmin());
7374
define('ROLLBAR_DISABLE_ADMIN', false);
7475
self::assertFalse(Plugin::disabledAdmin());
7576
}
7677

77-
#[RunInSeparateProcess]
78-
#[PreserveGlobalState(false)]
78+
/**
79+
* @runInSeparateProcess
80+
* @preserveGlobalState disabled
81+
*/
7982
public function testHideAdmin(): void
8083
{
8184
add_action('rollbar_disable_admin', '__return_false');
@@ -89,7 +92,9 @@ public function testGetAssetUrl(): void
8992
self::assertStringEndsWith('/wp-content/plugins/rollbar/test.js', Plugin::getAssetUrl('test.js'));
9093
}
9194

92-
#[DataProvider('loggingLevelTestDataProvider')]
95+
/**
96+
* @dataProvider loggingLevelTestDataProvider
97+
*/
9398
public function testIncludedErrno(
9499
$loggingLevel,
95100
$errorLevel,

tests/SettingsTest.php

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace Rollbar\WordPress\Tests;
44

5-
use PHPUnit\Framework\Attributes\DataProvider;
6-
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
7-
use PHPUnit\Framework\Attributes\TestWith;
85
use Rollbar\WordPress\Lib\AbstractSingleton;
96
use Rollbar\WordPress\Settings;
107
use Rollbar\WordPress\Settings\SettingType;
@@ -59,7 +56,9 @@ public function testGetDefaultSetting(): void
5956
self::assertTrue($settings->getDefaultOption('capture_error_stacktraces'));
6057
}
6158

62-
#[DataProvider('preUpdateProvider')]
59+
/**
60+
* @dataProvider preUpdateProvider
61+
*/
6362
public function testPreUpdate($expected, $data): void
6463
{
6564
self::assertEquals(
@@ -77,26 +76,31 @@ public function testSet(): void
7776
self::assertSame('bar', $settings->get('foo'));
7877
}
7978

80-
#[TestWith([true, true])]
81-
#[TestWith([false, false])]
82-
#[TestWith(['false', false])]
83-
#[TestWith(['true', true])]
84-
#[TestWith(['1', true])]
85-
#[TestWith(['0', false])]
86-
#[TestWith(['', false])]
87-
#[TestWith(['yes', true])]
88-
#[TestWith(['no', false])]
89-
#[TestWith(['on', true])]
90-
#[TestWith(['off', false])]
91-
#[TestWith([0, false])]
92-
#[TestWith([1, true])]
93-
#[TestWith([-1, true])]
79+
/**
80+
* @testWith [true, true]
81+
* @testWith [false, false]
82+
* @testWith ['false', false]
83+
* @testWith ['true', true]
84+
* @testWith ['1', true]
85+
* @testWith ['0', false]
86+
* @testWith ['', false]
87+
* @testWith ['yes', true]
88+
* @testWith ['no', false]
89+
* @testWith ['on', true]
90+
* @testWith ['off', false]
91+
* @testWith [0, false]
92+
* @testWith [1, true]
93+
* @testWith [-1, true]
94+
*/
9495
public function testToBoolean($value, $expected): void
9596
{
9697
self::assertSame($expected, Settings::toBoolean($value));
9798
}
9899

99-
#[RunInSeparateProcess]
100+
/**
101+
* @runInSeparateProcess
102+
* @preserveGlobalState disabled
103+
*/
100104
public function testRollbarSettingsConstant(): void
101105
{
102106
define('ROLLBAR_SETTINGS', [
@@ -110,7 +114,10 @@ public function testRollbarSettingsConstant(): void
110114
self::assertSame(['bar'], Settings::getInstance()->get('scrub_fields'));
111115
}
112116

113-
#[RunInSeparateProcess]
117+
/**
118+
* @runInSeparateProcess
119+
* @preserveGlobalState disabled
120+
*/
114121
public function testRollbarSettingsConstantPriority(): void
115122
{
116123
define('ROLLBAR_SETTINGS', [

tests/Telemetry/ListenerTest.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Rollbar\WordPress\Tests\Telemetry;
44

5-
use PHPUnit\Framework\Attributes\TestWith;
65
use Rollbar\Rollbar;
76
use Rollbar\Telemetry\EventLevel;
87
use Rollbar\Telemetry\EventType;
@@ -59,13 +58,9 @@ public function testInstrumentAction(): void
5958
self::assertTrue(has_action('delete_user'));
6059
}
6160

62-
#[TestWith(['delete_user', [true], 'delete_user: true'])]
63-
#[TestWith(['register_post', [true, 1], 'register_post: true, 1'])]
64-
#[TestWith(['wpmu_new_user', ['foo', 'bar'], 'wpmu_new_user: foo, bar'])]
65-
#[TestWith(['check_admin_referer', [false], 'check_admin_referer: false'])]
66-
#[TestWith(['admin_init', [[1, 2, 3, 'four']], 'admin_init: Array(4)'])]
67-
#[TestWith(['wp_footer', [null], 'wp_footer: null'])]
68-
#[TestWith(['edit_link', [5.84], 'edit_link: 5.84'])]
61+
/**
62+
* @dataProvider dataProviderConcatExtraArgs
63+
*/
6964
public function testConcatExtraArgs(string $action, array $args, string $expected): void
7065
{
7166
self::assertSame($expected, Listener::concatExtraArgs($action, ...$args));
@@ -93,4 +88,17 @@ public function testLog(): void
9388
self::assertSame('test', $last->body->message);
9489
self::assertSame(EventLevel::Critical, $last->level);
9590
}
91+
92+
public static function dataProviderConcatExtraArgs(): array
93+
{
94+
return [
95+
['delete_user', [true], 'delete_user: true'],
96+
['register_post', [true, 1], 'register_post: true, 1'],
97+
['wpmu_new_user', ['foo', 'bar'], 'wpmu_new_user: foo, bar'],
98+
['check_admin_referer', [false], 'check_admin_referer: false'],
99+
['admin_init', [[1, 2, 3, 'four']], 'admin_init: Array(4)'],
100+
['wp_footer', [null], 'wp_footer: null'],
101+
['edit_link', [5.84], 'edit_link: 5.84'],
102+
];
103+
}
96104
}

0 commit comments

Comments
 (0)