Skip to content

Commit

Permalink
test(wploadersuite) fix WC+Ajax issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lucatume committed Jan 23, 2024
1 parent edbe0cc commit 719efca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
30 changes: 15 additions & 15 deletions tests/_support/_generated/WploaderTesterActions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php //[STAMP] 78c0fea8c98ec2d182b5db7ffedc0a1e
<?php //[STAMP] 544d779e0fd8c7b70b0b5c1d37bb4034
// phpcs:ignoreFile
namespace _generated;

Expand Down Expand Up @@ -47,16 +47,16 @@ public function getWpRootFolder(?string $path = NULL): string {
* The value will first look at the `WP_PLUGIN_DIR` constant, then the `pluginsFolder` configuration parameter
* and will, finally, look in the default path from the WordPress root directory.
*
* @param string $path A relative path to append to te plugins directory absolute path.
*
* @return string The absolute path to the `pluginsFolder` path or the same with a relative path appended if `$path`
* is provided.
* @example
* ```php
* $plugins = $this->getPluginsFolder();
* $hello = $this->getPluginsFolder('hello.php');
* ```
*
* @param string $path A relative path to append to te plugins directory absolute path.
*
* @return string The absolute path to the `pluginsFolder` path or the same with a relative path appended if `$path`
* is provided.
* @see \lucatume\WPBrowser\Module\WPLoader::getPluginsFolder()
*/
public function getPluginsFolder(string $path = ""): string {
Expand All @@ -69,16 +69,16 @@ public function getPluginsFolder(string $path = ""): string {
*
* Returns the absolute path to the themes directory.
*
* @param string $path A relative path to append to te themes directory absolute path.
*
* @return string The absolute path to the `themesFolder` path or the same with a relative path appended if `$path`
* is provided.
* @example
* ```php
* $themes = $this->getThemesFolder();
* $twentytwenty = $this->getThemesFolder('/twentytwenty');
* ```
*
* @param string $path A relative path to append to te themes directory absolute path.
*
* @return string The absolute path to the `themesFolder` path or the same with a relative path appended if `$path`
* is provided.
* @see \lucatume\WPBrowser\Module\WPLoader::getThemesFolder()
*/
public function getThemesFolder(string $path = ""): string {
Expand All @@ -93,15 +93,15 @@ public function getThemesFolder(string $path = ""): string {
* This method gives access to the same factories provided by the
* [Core test suite](https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/).
*
* @return FactoryStore A factory store, proxy to get hold of the Core suite object
* factories.
*
* @example
* ```php
* $postId = $I->factory()->post->create();
* $userId = $I->factory()->user->create(['role' => 'administrator']);
* ```
*
* @return FactoryStore A factory store, proxy to get hold of the Core suite object
* factories.
*
* @link https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/
* @see \lucatume\WPBrowser\Module\WPLoader::factory()
*/
Expand All @@ -115,16 +115,16 @@ public function factory(): \lucatume\WPBrowser\Module\WPLoader\FactoryStore {
*
* Returns the absolute path to the WordPress content directory.
*
* @param string $path An optional path to append to the content directory absolute path.
*
* @return string The content directory absolute path, or a path in it.
* @example
* ```php
* $content = $this->getContentFolder();
* $themes = $this->getContentFolder('themes');
* $twentytwenty = $this->getContentFolder('themes/twentytwenty');
* ```
*
* @param string $path An optional path to append to the content directory absolute path.
*
* @return string The content directory absolute path, or a path in it.
* @see \lucatume\WPBrowser\Module\WPLoader::getContentFolder()
*/
public function getContentFolder(string $path = ""): string {
Expand Down
3 changes: 3 additions & 0 deletions tests/wploadersuite/AjaxTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
<?php

use lucatume\WPBrowser\TestCase\WPAjaxTestCase;
use lucatume\WPBrowser\Tests\Traits\UopzFunctions;

class AjaxTest extends WPAjaxTestCase
{
use UopzFunctions;

public function ajaxCallback(): void
{
if (
Expand Down
9 changes: 9 additions & 0 deletions tests/wploadersuite/_bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@
if (!class_exists(WP_Post::class)) {
throw new RuntimeException('WP_Post class not found');
}

// Work around WooCommerce enqueueing this only on admin requests.
if (!function_exists('wc_get_page_screen_id')) {
function wc_get_page_screen_id(): string
{
return '';
}
}

0 comments on commit 719efca

Please sign in to comment.