diff --git a/tasks/phpstan/bootstrap.php b/tasks/phpstan/bootstrap.php index c83c392cc4..6b4f429db1 100644 --- a/tasks/phpstan/bootstrap.php +++ b/tasks/phpstan/bootstrap.php @@ -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'; diff --git a/tasks/phpstan/function-stubs.php b/tasks/phpstan/function-stubs.php new file mode 100644 index 0000000000..287d16c89f --- /dev/null +++ b/tasks/phpstan/function-stubs.php @@ -0,0 +1,6 @@ +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); diff --git a/tests/integration/Config/UpdaterTest.php b/tests/integration/Config/UpdaterTest.php index 63cdd3153e..e5a701078d 100644 --- a/tests/integration/Config/UpdaterTest.php +++ b/tests/integration/Config/UpdaterTest.php @@ -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(); } } diff --git a/tests/integration/Models/NewsletterOptionFieldTest.php b/tests/integration/Models/NewsletterOptionFieldTest.php index 32a22d1d95..c5631a5f64 100644 --- a/tests/integration/Models/NewsletterOptionFieldTest.php +++ b/tests/integration/Models/NewsletterOptionFieldTest.php @@ -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(); } } diff --git a/tests/integration/Models/NewsletterPostTest.php b/tests/integration/Models/NewsletterPostTest.php index 0684b0e330..47daf145ab 100644 --- a/tests/integration/Models/NewsletterPostTest.php +++ b/tests/integration/Models/NewsletterPostTest.php @@ -22,7 +22,6 @@ class NewsletterPostTest extends \MailPoetTest { } public function _after() { - ORM::for_table(NewsletterPost::$_table) - ->deleteMany(); + NewsletterPost::deleteMany(); } } diff --git a/tests/integration/Models/NewsletterTemplateTest.php b/tests/integration/Models/NewsletterTemplateTest.php index 0e7659f2a5..674b5cc522 100644 --- a/tests/integration/Models/NewsletterTemplateTest.php +++ b/tests/integration/Models/NewsletterTemplateTest.php @@ -104,7 +104,6 @@ class NewsletterTemplateTest extends \MailPoetTest { } public function _after() { - ORM::for_table(NewsletterTemplate::$_table) - ->deleteMany(); + NewsletterTemplate::deleteMany(); } } diff --git a/tests/integration/Models/StatisticsUnsubscribesTest.php b/tests/integration/Models/StatisticsUnsubscribesTest.php index 3e4dc2deed..e20652d10c 100644 --- a/tests/integration/Models/StatisticsUnsubscribesTest.php +++ b/tests/integration/Models/StatisticsUnsubscribesTest.php @@ -27,7 +27,6 @@ class StatisticsUnsubscribesTest extends \MailPoetTest { } public function _after() { - ORM::for_table(StatisticsUnsubscribes::$_table) - ->deleteMany(); + StatisticsUnsubscribes::deleteMany(); } } diff --git a/tests/integration/Models/SubscriberCustomFieldTest.php b/tests/integration/Models/SubscriberCustomFieldTest.php index 37ffcd3cf1..043d8a241e 100644 --- a/tests/integration/Models/SubscriberCustomFieldTest.php +++ b/tests/integration/Models/SubscriberCustomFieldTest.php @@ -77,7 +77,6 @@ class SubscriberCustomFieldTest extends \MailPoetTest { } public function _after() { - ORM::forTable(SubscriberCustomField::$_table) - ->deleteMany(); + SubscriberCustomField::deleteMany(); } } diff --git a/tests/integration/Models/SubscriberTest.php b/tests/integration/Models/SubscriberTest.php index f97aba0fd8..d8767b346a 100644 --- a/tests/integration/Models/SubscriberTest.php +++ b/tests/integration/Models/SubscriberTest.php @@ -423,7 +423,7 @@ class SubscriberTest extends \MailPoetTest { } public function testItCanCreateOrUpdateMultipleRecords() { - ORM::forTable(Subscriber::$_table)->deleteMany(); + Subscriber::deleteMany(); $columns = [ 'first_name', 'last_name', diff --git a/tests/integration/Segments/WPUserWithExtraProps.php b/tests/integration/Segments/WPUserWithExtraProps.php new file mode 100644 index 0000000000..7946df24cf --- /dev/null +++ b/tests/integration/Segments/WPUserWithExtraProps.php @@ -0,0 +1,7 @@ +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;