Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kagg-design committed Jan 31, 2025
1 parent 89b4f9b commit 2ed0fed
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
1 change: 1 addition & 0 deletions .tests/php/integration/Admin/Events/EventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ public function test_get_forms(): void {
'source' => '[]',
'form_id' => '0',
'served' => '2',
'id' => '1',
],
],
'total' => 1,
Expand Down
11 changes: 11 additions & 0 deletions .tests/php/unit/Settings/EventsPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public function test_admin_enqueue_scripts( bool $allowed ): void {
$unit = 'day';
$language_code = 'en';
$times = $allowed ? 1 : 0;
$nonce = 'some nonce';

$subject = Mockery::mock( EventsPage::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
Expand Down Expand Up @@ -245,6 +246,12 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) {
ListPageBase::HANDLE,
ListPageBase::OBJECT,
[
'ajaxUrl' => 'admin-ajax.php',
'bulkAction' => ListPageBase::BULK_ACTION,
'bulkNonce' => $nonce,
'noAction' => 'Please select a bulk action.',
'noItems' => 'Please select at least one item to perform this action on.',
'DoingBulk' => 'Doing bulk action...',
'delimiter' => ListPageBase::TIMESPAN_DELIMITER,
'locale' => $language_code,
]
Expand Down Expand Up @@ -275,6 +282,8 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) {
)
->times( $times );

WP_Mock::passthruFunction( 'admin_url' );
WP_Mock::userFunction( 'wp_create_nonce' )->andReturn( $nonce );
WP_Mock::userFunction( 'get_user_locale' )->andReturn( $language_code );

$subject->admin_enqueue_scripts();
Expand Down Expand Up @@ -305,6 +314,7 @@ public function test_section_callback(): void {
Events </h2>
</div>
' . $datepicker . ' </div>
<div id="hcaptcha-message"></div>
<div id="hcaptcha-events-chart">
<canvas id="eventsChart" aria-label="The hCaptcha Events Chart" role="img">
<p>
Expand Down Expand Up @@ -349,6 +359,7 @@ public function test_section_callback_when_not_allowed(): void {
Events </h2>
</div>
</div>
<div id="hcaptcha-message"></div>
<div class="hcaptcha-events-sample-bg"></div>
<div class="hcaptcha-events-sample-text">
Expand Down
11 changes: 11 additions & 0 deletions .tests/php/unit/Settings/FormsPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ public function test_admin_enqueue_scripts( bool $allowed ): void {
$unit = 'hour';
$language_code = 'en';
$times = $allowed ? 1 : 0;
$nonce = 'some nonce';

$subject = Mockery::mock( FormsPage::class )->makePartial();
$subject->shouldAllowMockingProtectedMethods();
Expand Down Expand Up @@ -236,6 +237,12 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) {
ListPageBase::HANDLE,
ListPageBase::OBJECT,
[
'ajaxUrl' => 'admin-ajax.php',
'bulkAction' => ListPageBase::BULK_ACTION,
'bulkNonce' => $nonce,
'noAction' => 'Please select a bulk action.',
'noItems' => 'Please select at least one item to perform this action on.',
'DoingBulk' => 'Doing bulk action...',
'delimiter' => ListPageBase::TIMESPAN_DELIMITER,
'locale' => $language_code,
]
Expand Down Expand Up @@ -264,6 +271,8 @@ static function ( $name ) use ( $plugin_url, $plugin_version ) {
)
->times( $times );

WP_Mock::passthruFunction( 'admin_url' );
WP_Mock::userFunction( 'wp_create_nonce' )->andReturn( $nonce );
WP_Mock::userFunction( 'get_user_locale' )->andReturn( $language_code );

$subject->admin_enqueue_scripts();
Expand Down Expand Up @@ -294,6 +303,7 @@ public function test_section_callback(): void {
Forms </h2>
</div>
' . $datepicker . ' </div>
<div id="hcaptcha-message"></div>
<div id="hcaptcha-forms-chart">
<canvas id="formsChart" aria-label="The hCaptcha Forms Chart" role="img">
<p>
Expand Down Expand Up @@ -338,6 +348,7 @@ public function test_section_callback_when_not_allowed(): void {
Forms </h2>
</div>
</div>
<div id="hcaptcha-message"></div>
<div class="hcaptcha-forms-sample-bg"></div>
<div class="hcaptcha-forms-sample-text">
Expand Down
12 changes: 6 additions & 6 deletions .tests/php/unit/Settings/ListPageBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public function test_date_picker_display(): void {
<div class="hcaptcha-datepicker-calendar">
<label for="hcaptcha-datepicker">
<input
type="text"
name="date"
tabindex="-1"
aria-hidden="true"
id="hcaptcha-datepicker"
value="2024-04-27 - 2024-05-27">
type="text"
name="date"
tabindex="-1"
aria-hidden="true"
id="hcaptcha-datepicker"
value="2024-04-27 - 2024-05-27">
</label>
</div>
<div class="hcaptcha-datepicker-action">
Expand Down

0 comments on commit 2ed0fed

Please sign in to comment.