Remove phpstan-ignores from tests

[MAILPOET-3235]
This commit is contained in:
Jan Lysý
2021-01-14 18:29:04 +01:00
committed by Veljko V
parent 8001cd1336
commit df794425b7
4 changed files with 18 additions and 14 deletions

View File

@ -28,10 +28,11 @@ class AbandonedCartPageVisitTrackerTest extends \MailPoetTest {
$this->currentTime = Carbon::now();
Carbon::setTestNow($this->currentTime);
// @phpstan-ignore-next-line
$this->wp = $this->makeEmpty(WPFunctions::class, [
/** @var WPFunctions|MockObject $wp - for phpstan*/
$wp = $this->makeEmpty(WPFunctions::class, [
'currentTime' => $this->currentTime->getTimestamp(),
]);
$this->wp = $wp;
$wooCommerceMock = $this->mockWooCommerceClass(WooCommerce::class, []);
$wooCommerceMock->session = $this->createWooCommerceSessionMock();

View File

@ -49,8 +49,8 @@ class AbandonedCartTest extends \MailPoetTest {
$this->currentTime = Carbon::createFromTimestamp((new WPFunctions())->currentTime('timestamp'));
Carbon::setTestNow($this->currentTime);
// @phpstan-ignore-next-line
$this->wp = $this->makeEmpty(WPFunctions::class, [
/** @var WPFunctions|MockObject $wp - for phpstan */
$wp = $this->makeEmpty(WPFunctions::class, [
'currentTime' => function ($arg) {
if ($arg === 'timestamp') {
return $this->currentTime->getTimestamp();
@ -59,18 +59,21 @@ class AbandonedCartTest extends \MailPoetTest {
}
},
]);
$this->wp = $wp;
WPFunctions::set($this->wp);
$this->wooCommerceMock = $this->mockWooCommerceClass(WooCommerce::class, []);
$this->wooCommerceCartMock = $this->mockWooCommerceClass(WC_Cart::class, ['is_empty', 'get_cart']);
$this->wooCommerceMock->cart = $this->wooCommerceCartMock;
// @phpstan-ignore-next-line
$this->wooCommerceHelperMock = $this->make(WooCommerceHelper::class, [
/** @var WooCommerceHelper|MockObject $wooCommerceHelperMock - for phpstan */
$wooCommerceHelperMock = $this->make(WooCommerceHelper::class, [
'isWooCommerceActive' => true,
'WC' => $this->wooCommerceMock,
]);
// @phpstan-ignore-next-line
$this->pageVisitTrackerMock = $this->makeEmpty(AbandonedCartPageVisitTracker::class);
$this->wooCommerceHelperMock = $wooCommerceHelperMock;
/** @var AbandonedCartPageVisitTracker|MockObject $pageVisitTrackerMock - for phpstan */
$pageVisitTrackerMock = $this->makeEmpty(AbandonedCartPageVisitTracker::class);
$this->pageVisitTrackerMock = $pageVisitTrackerMock;
}
public function testItGetsEventDetails() {

View File

@ -17,7 +17,7 @@ class DatabaseTest extends \MailPoetTest {
public function _before() {
parent::_before();
ORM::set_db(null); // @phpstan-ignore-line
ORM::reset_db();
}
public function testItDefinesTables() {

View File

@ -66,7 +66,7 @@ class ShortcodesTest extends \MailPoetTest {
expect((new WPFunctions)->isUserLoggedIn())->true();
$subscriber = Subscriber::create();
$subscriber->hydrate(Fixtures::get('subscriber_template'));
$subscriber->email = $wpUser->data->user_email; // @phpstan-ignore-line
$subscriber->email = $wpUser->user_email; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$subscriber->wpUserId = $wpUser->ID;
$subscriber->save();
@ -83,7 +83,7 @@ class ShortcodesTest extends \MailPoetTest {
expect($wp->isUserLoggedIn())->true();
$subscriber = Subscriber::create();
$subscriber->hydrate(Fixtures::get('subscriber_template'));
$subscriber->email = $wpUser->data->user_email; // @phpstan-ignore-line
$subscriber->email = $wpUser->user_email; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$subscriber->wpUserId = $wpUser->ID;
$subscriber->save();
@ -102,7 +102,7 @@ class ShortcodesTest extends \MailPoetTest {
public function testItDoesNotDisplayManageSubscriptionFormForLoggedinNonexistentSubscribers() {
$wpUser = wp_set_current_user(1);
expect((new WPFunctions)->isUserLoggedIn())->true();
expect(Subscriber::findOne($wpUser->data->user_email))->false(); // @phpstan-ignore-line
expect(Subscriber::findOne($wpUser->user_email))->false(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$shortcodes = ContainerWrapper::getInstance()->get(Shortcodes::class);
$shortcodes->init();
@ -125,7 +125,7 @@ class ShortcodesTest extends \MailPoetTest {
expect((new WPFunctions)->isUserLoggedIn())->true();
$subscriber = Subscriber::create();
$subscriber->hydrate(Fixtures::get('subscriber_template'));
$subscriber->email = $wpUser->data->user_email; // @phpstan-ignore-line
$subscriber->email = $wpUser->user_email; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$subscriber->wpUserId = $wpUser->ID;
$subscriber->save();
@ -138,7 +138,7 @@ class ShortcodesTest extends \MailPoetTest {
public function testItDoesNotDisplayLinkToManageSubscriptionPageForLoggedinNonexistentSubscribers() {
$wpUser = wp_set_current_user(1);
expect((new WPFunctions)->isUserLoggedIn())->true();
expect(Subscriber::findOne($wpUser->data->user_email))->false(); // @phpstan-ignore-line
expect(Subscriber::findOne($wpUser->user_email))->false(); // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps
$shortcodes = ContainerWrapper::getInstance()->get(Shortcodes::class);
$shortcodes->init();