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

Public Member Functions

 testRetrieve ()
 
 testRetrieveGroup0 ()
 
 testRetrieveCached ()
 
 testRetrieveException ()
 
 testRemove ()
 

Data Fields

const GROUP_CODE = 'custom_group'
 

Protected Member Functions

 setUp ()
 

Protected Attributes

 $_model
 

Detailed Description

Test for \Magento\Customer\Model\GroupRegistry

Definition at line 12 of file GroupRegistryTest.php.

Member Function Documentation

◆ setUp()

setUp ( )
protected

Definition at line 24 of file GroupRegistryTest.php.

25  {
27  ->create(\Magento\Customer\Model\GroupRegistry::class);
28  }

◆ testRemove()

testRemove ( )

@magentoDataFixture Magento/Customer/_files/customer_group.php @expectedException \Magento\Framework\Exception\NoSuchEntityException

Definition at line 105 of file GroupRegistryTest.php.

106  {
107  $groupId = $this->_findGroupIdWithCode(self::GROUP_CODE);
108  $group = $this->_model->retrieve($groupId);
109  $this->assertInstanceOf(\Magento\Customer\Model\Group::class, $group);
110  $group->delete();
111  $this->_model->remove($groupId);
112  $this->_model->retrieve($groupId);
113  }
$group
Definition: sections.phtml:16

◆ testRetrieve()

testRetrieve ( )

@magentoDataFixture Magento/Customer/_files/customer_group.php

Definition at line 56 of file GroupRegistryTest.php.

57  {
58  $groupId = $this->_findGroupIdWithCode(self::GROUP_CODE);
59  $group = $this->_model->retrieve($groupId);
60  $this->assertInstanceOf(\Magento\Customer\Model\Group::class, $group);
61  $this->assertEquals($groupId, $group->getId());
62  }
$group
Definition: sections.phtml:16

◆ testRetrieveCached()

testRetrieveCached ( )

@magentoDataFixture Magento/Customer/_files/customer_group.php

Definition at line 78 of file GroupRegistryTest.php.

79  {
80  $groupId = $this->_findGroupIdWithCode(self::GROUP_CODE);
81  $groupBeforeDeletion = $this->_model->retrieve($groupId);
83  ->create(\Magento\Customer\Model\Group::class);
84  $group2->load($groupId)
85  ->delete();
86  $groupAfterDeletion = $this->_model->retrieve($groupId);
87  $this->assertEquals($groupBeforeDeletion, $groupAfterDeletion);
88  $this->assertInstanceOf(\Magento\Customer\Model\Group::class, $groupAfterDeletion);
89  $this->assertEquals($groupId, $groupAfterDeletion->getId());
90  }

◆ testRetrieveException()

testRetrieveException ( )

@expectedException \Magento\Framework\Exception\NoSuchEntityException

Definition at line 95 of file GroupRegistryTest.php.

96  {
97  $groupId = $this->_findGroupIdWithCode(self::GROUP_CODE);
98  $this->_model->retrieve($groupId);
99  }

◆ testRetrieveGroup0()

testRetrieveGroup0 ( )

Ensure can retrieve group with id 0 which is a valid group ID.

Definition at line 67 of file GroupRegistryTest.php.

68  {
69  $groupId = 0;
70  $group = $this->_model->retrieve($groupId);
71  $this->assertInstanceOf(\Magento\Customer\Model\Group::class, $group);
72  $this->assertEquals($groupId, $group->getId());
73  }
$group
Definition: sections.phtml:16

Field Documentation

◆ $_model

$_model
protected

Definition at line 22 of file GroupRegistryTest.php.

◆ GROUP_CODE

const GROUP_CODE = 'custom_group'

The group code from the fixture data.

Definition at line 17 of file GroupRegistryTest.php.


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