|
5 | 5 | */
|
6 | 6 | namespace Magento\User\Model\ResourceModel;
|
7 | 7 |
|
| 8 | +use Magento\Authorization\Model\ResourceModel\Role\Collection as UserRoleCollection; |
| 9 | +use Magento\Authorization\Model\UserContextInterface; |
8 | 10 | use Magento\TestFramework\Helper\Bootstrap;
|
9 |
| -use Magento\User\Model\User; |
10 | 11 | use Magento\User\Model\ResourceModel\User as UserResourceModel;
|
| 12 | +use Magento\User\Model\User; |
11 | 13 |
|
12 | 14 | /**
|
13 | 15 | * @magentoAppArea adminhtml
|
@@ -46,6 +48,33 @@ public function testGetLatestPasswordWhenZeroPasswordLifetime()
|
46 | 48 | );
|
47 | 49 | }
|
48 | 50 |
|
| 51 | + /** |
| 52 | + * Test that user role is not deleted after deleting empty user |
| 53 | + */ |
| 54 | + public function testDelete() |
| 55 | + { |
| 56 | + $this->checkRoleCollectionSize(); |
| 57 | + /** @var User $user */ |
| 58 | + $user = Bootstrap::getObjectManager()->create( |
| 59 | + User::class |
| 60 | + ); |
| 61 | + $this->model->delete($user); |
| 62 | + $this->checkRoleCollectionSize(); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Ensure that role collection size is correct |
| 67 | + */ |
| 68 | + private function checkRoleCollectionSize() |
| 69 | + { |
| 70 | + /** @var UserRoleCollection $roleCollection */ |
| 71 | + $roleCollection = Bootstrap::getObjectManager()->create( |
| 72 | + UserRoleCollection::class |
| 73 | + ); |
| 74 | + $roleCollection->setUserFilter(0, UserContextInterface::USER_TYPE_ADMIN); |
| 75 | + $this->assertEquals(1, $roleCollection->getSize()); |
| 76 | + } |
| 77 | + |
49 | 78 | public function testCountAll()
|
50 | 79 | {
|
51 | 80 | $this->assertSame(1, $this->model->countAll());
|
|
0 commit comments