Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
SubscriberTest Class Reference
Inheritance diagram for SubscriberTest:

Public Member Functions

 testLoadByCustomerId ()
 
 testUnsubscribeSubscribe ()
 
 testUnsubscribeSubscribeByCustomerId ()
 
 testConfirm ()
 

Protected Member Functions

 setUp ()
 

Detailed Description

Definition at line 10 of file SubscriberTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 17 of file SubscriberTest.php.

18  {
20  \Magento\Newsletter\Model\Subscriber::class
21  );
22  }

◆ testConfirm()

testConfirm ( )

@magentoDataFixture Magento/Newsletter/_files/subscribers.php @magentoConfigFixture current_store newsletter/subscription/confirm 1

Definition at line 87 of file SubscriberTest.php.

88  {
90  $this->model->subscribe($customerEmail);
91  $this->model->loadByEmail($customerEmail);
92  $this->model->confirm($this->model->getSubscriberConfirmCode());
93 
95  \Magento\TestFramework\Mail\Template\TransportBuilderMock::class
96  );
97 
98  $this->assertContains(
99  'You have been successfully subscribed to our newsletter.',
100  $transportBuilder->getSentMessage()->getRawMessage()
101  );
102  }

◆ testLoadByCustomerId()

testLoadByCustomerId ( )

@magentoDataFixture Magento/Newsletter/_files/subscribers.php

Definition at line 46 of file SubscriberTest.php.

47  {
48  $this->assertSame($this->model, $this->model->loadByCustomerId(1));
49  $this->assertEquals('[email protected]', $this->model->getSubscriberEmail());
50  }

◆ testUnsubscribeSubscribe()

testUnsubscribeSubscribe ( )

@magentoDataFixture Magento/Newsletter/_files/subscribers.php @magentoAppArea frontend

Definition at line 56 of file SubscriberTest.php.

57  {
58  // Unsubscribe and verify
59  $this->assertSame($this->model, $this->model->loadByCustomerId(1));
60  $this->assertEquals($this->model, $this->model->unsubscribe());
61  $this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->model->getSubscriberStatus());
62 
63  // Subscribe and verify
64  $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->model->subscribe('[email protected]'));
65  $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->model->getSubscriberStatus());
66  }

◆ testUnsubscribeSubscribeByCustomerId()

testUnsubscribeSubscribeByCustomerId ( )

@magentoDataFixture Magento/Newsletter/_files/subscribers.php @magentoAppArea frontend

Definition at line 72 of file SubscriberTest.php.

73  {
74  // Unsubscribe and verify
75  $this->assertSame($this->model, $this->model->unsubscribeCustomerById(1));
76  $this->assertEquals(Subscriber::STATUS_UNSUBSCRIBED, $this->model->getSubscriberStatus());
77 
78  // Subscribe and verify
79  $this->assertSame($this->model, $this->model->subscribeCustomerById(1));
80  $this->assertEquals(Subscriber::STATUS_SUBSCRIBED, $this->model->getSubscriberStatus());
81  }

The documentation for this class was generated from the following file: