Fix undefined classes and functions [MAILPOET-2488]
This commit is contained in:
@ -4,6 +4,7 @@ define('ABSPATH', getenv('WP_ROOT') . '/');
|
||||
|
||||
require_once ABSPATH . 'wp-load.php';
|
||||
require_once ABSPATH . 'wp-admin/includes/admin.php';
|
||||
require_once(ABSPATH . 'wp-admin/includes/ms.php');
|
||||
require_once ABSPATH . 'wp-includes/class-phpmailer.php';
|
||||
|
||||
if (!class_exists('\MailPoet\Premium\DI\ContainerConfigurator')) {
|
||||
@ -13,3 +14,5 @@ if (!class_exists('\MailPoet\Premium\DI\ContainerConfigurator')) {
|
||||
if (!class_exists(WooCommerce::class)) {
|
||||
require_once __DIR__ . '/woocommerce.php';
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/function-stubs.php';
|
||||
|
6
tasks/phpstan/function-stubs.php
Normal file
6
tasks/phpstan/function-stubs.php
Normal file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
if (!function_exists('members_get_cap_group')) {
|
||||
function members_get_cap_group($name) {
|
||||
}
|
||||
}
|
@ -73,6 +73,8 @@ class WC_Order { // phpcs:ignore
|
||||
* @method int get_product_id(string $context = 'view')
|
||||
*/
|
||||
class WC_Order_Item_Product { // phpcs:ignore
|
||||
function get_product_id() { // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,3 +82,13 @@ class WC_Order_Item_Product { // phpcs:ignore
|
||||
*/
|
||||
class WC_Product { // phpcs:ignore
|
||||
}
|
||||
|
||||
class WC_Cart { // phpcs:ignore
|
||||
}
|
||||
|
||||
class WC_Mailer { // phpcs:ignore
|
||||
function email_header() { // phpcs:ignore
|
||||
}
|
||||
function email_footer() { // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class InstallerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItGetsPluginInformation() {
|
||||
$args = new \StdClass;
|
||||
$args = new \stdClass;
|
||||
$args->slug = $this->slug;
|
||||
$installer = Stub::construct(
|
||||
$this->installer,
|
||||
@ -69,11 +69,11 @@ class InstallerTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItIgnoresNonMatchingRequestsWhenGettingPluginInformation() {
|
||||
$data = new \StdClass;
|
||||
$data = new \stdClass;
|
||||
$data->some_property = '123';
|
||||
$result = $this->installer->getPluginInformation($data, 'some_action', null);
|
||||
expect($result)->equals($data);
|
||||
$args = new \StdClass;
|
||||
$args = new \stdClass;
|
||||
$args->slug = 'different-slug';
|
||||
$result = $this->installer->getPluginInformation($data, 'plugin_information', $args);
|
||||
expect($result)->equals($data);
|
||||
|
@ -37,7 +37,7 @@ class UpdaterTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItChecksForUpdates() {
|
||||
$update_transient = new \StdClass;
|
||||
$update_transient = new \stdClass;
|
||||
$update_transient->last_checked = time();
|
||||
$updater = Stub::construct(
|
||||
$this->updater,
|
||||
@ -75,6 +75,6 @@ class UpdaterTest extends \MailPoetTest {
|
||||
|
||||
public function testItReturnsObjectIfPassedNonObjectWhenCheckingForUpdates() {
|
||||
$result = $this->updater->checkForUpdate(null);
|
||||
expect($result instanceof \StdClass)->true();
|
||||
expect($result instanceof \stdClass)->true();
|
||||
}
|
||||
}
|
||||
|
@ -121,11 +121,8 @@ class NewsletterOptionFieldTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
ORM::forTable(NewsletterOption::$_table)
|
||||
->deleteMany();
|
||||
ORM::forTable(NewsletterOptionField::$_table)
|
||||
->deleteMany();
|
||||
ORM::forTable(Newsletter::$_table)
|
||||
->deleteMany();
|
||||
NewsletterOption::deleteMany();
|
||||
NewsletterOptionField::deleteMany();
|
||||
Newsletter::deleteMany();
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ class NewsletterPostTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
ORM::for_table(NewsletterPost::$_table)
|
||||
->deleteMany();
|
||||
NewsletterPost::deleteMany();
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ class NewsletterTemplateTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
ORM::for_table(NewsletterTemplate::$_table)
|
||||
->deleteMany();
|
||||
NewsletterTemplate::deleteMany();
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ class StatisticsUnsubscribesTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
ORM::for_table(StatisticsUnsubscribes::$_table)
|
||||
->deleteMany();
|
||||
StatisticsUnsubscribes::deleteMany();
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,6 @@ class SubscriberCustomFieldTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
ORM::forTable(SubscriberCustomField::$_table)
|
||||
->deleteMany();
|
||||
SubscriberCustomField::deleteMany();
|
||||
}
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ class SubscriberTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItCanCreateOrUpdateMultipleRecords() {
|
||||
ORM::forTable(Subscriber::$_table)->deleteMany();
|
||||
Subscriber::deleteMany();
|
||||
$columns = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
|
7
tests/integration/Segments/WPUserWithExtraProps.php
Normal file
7
tests/integration/Segments/WPUserWithExtraProps.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace MailPoet\Test\Segments;
|
||||
|
||||
class WPUserWithExtraProps extends \WP_User {
|
||||
public $order_id;
|
||||
}
|
@ -15,6 +15,8 @@ use MailPoet\Subscribers\Source;
|
||||
use MailPoetVendor\Carbon\Carbon;
|
||||
use MailPoetVendor\Idiorm\ORM;
|
||||
|
||||
require_once('WPUserWithExtraProps.php');
|
||||
|
||||
class WooCommerceTest extends \MailPoetTest {
|
||||
public $customerRoleAdded;
|
||||
|
||||
@ -585,7 +587,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
* Those tests are testing user synchronisation, so we need data in wp_users table which has not been synchronised to
|
||||
* mailpoet database yet. We cannot use wp_insert_user functions because they would do the sync on insert.
|
||||
*
|
||||
* @return \WP_User
|
||||
* @return WPUserWithExtraProps
|
||||
*/
|
||||
private function insertRegisteredCustomer($number = null) {
|
||||
global $wpdb;
|
||||
@ -603,7 +605,7 @@ class WooCommerceTest extends \MailPoetTest {
|
||||
)', $wpdb->users));
|
||||
$id = $db->lastInsertId();
|
||||
// add customer role
|
||||
$user = new \WP_User($id);
|
||||
$user = new WPUserWithExtraProps($id);
|
||||
$user->add_role('customer');
|
||||
$this->userEmails[] = $user->user_email;
|
||||
return $user;
|
||||
|
Reference in New Issue
Block a user