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:
AbstractController

Public Member Functions

 testNewAction ()
 
 testNewActionUnusedEmail ()
 
 testNewActionUsedEmail ()
 
 testNewActionOwnerEmail ()
 
- Public Member Functions inherited from AbstractController
 getRequest ()
 
 getResponse ()
 
 assert404NotFound ()
 
 assertHeaderPcre ($headerName, $valueRegex)
 
 assertRedirect (\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)
 

Protected Member Functions

 setUp ()
 
- Protected Member Functions inherited from AbstractController
 _getBootstrap ()
 
 setUp ()
 
 tearDown ()
 
 assertPostConditions ()
 
 getMessages ( $messageType=null, $messageManagerClass=\Magento\Framework\Message\Manager::class)
 

Additional Inherited Members

- Protected Attributes inherited from AbstractController
 $_runCode = ''
 
 $_runScope = 'store'
 
 $_runOptions = []
 
 $_request
 
 $_response
 
 $_objectManager
 
 $_assertSessionErrors = false
 

Detailed Description

Test Subscriber

Definition at line 14 of file SubscriberTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 16 of file SubscriberTest.php.

17  {
18  parent::setUp();
19  }

◆ testNewAction()

testNewAction ( )

Definition at line 21 of file SubscriberTest.php.

22  {
23  $this->getRequest()->setMethod('POST');
24 
25  $this->dispatch('newsletter/subscriber/new');
26 
27  $this->assertSessionMessages($this->isEmpty());
28  $this->assertRedirect($this->anything());
29  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)

◆ testNewActionOwnerEmail()

testNewActionOwnerEmail ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 68 of file SubscriberTest.php.

69  {
70  $this->getRequest()->setMethod('POST');
71  $this->getRequest()->setPostValue([
72  'email' => '[email protected]',
73  ]);
74  $this->login(1);
75 
76  $this->dispatch('newsletter/subscriber/new');
77 
78  $this->assertSessionMessages($this->equalTo(['Thank you for your subscription.']));
79  $this->assertRedirect($this->anything());
80  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)

◆ testNewActionUnusedEmail()

testNewActionUnusedEmail ( )

@magentoDbIsolation enabled

Definition at line 34 of file SubscriberTest.php.

35  {
36  $this->getRequest()->setMethod('POST');
37  $this->getRequest()->setPostValue([
38  'email' => '[email protected]',
39  ]);
40 
41  $this->dispatch('newsletter/subscriber/new');
42 
43  $this->assertSessionMessages($this->equalTo(['Thank you for your subscription.']));
44  $this->assertRedirect($this->anything());
45  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)

◆ testNewActionUsedEmail()

testNewActionUsedEmail ( )

@magentoDataFixture Magento/Customer/_files/customer.php

Definition at line 50 of file SubscriberTest.php.

51  {
52  $this->getRequest()->setMethod('POST');
53  $this->getRequest()->setPostValue([
54  'email' => '[email protected]',
55  ]);
56 
57  $this->dispatch('newsletter/subscriber/new');
58 
59  $this->assertSessionMessages($this->equalTo([
60  'There was a problem with the subscription: This email address is already assigned to another user.',
61  ]));
62  $this->assertRedirect($this->anything());
63  }
assertRedirect(\PHPUnit\Framework\Constraint\Constraint $urlConstraint=null)

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