7
7
namespace Magento \Setup \Test \Unit \Model ;
8
8
9
9
use \Magento \Setup \Model \AdminAccount ;
10
+ use Magento \Framework \Serialize \Serializer \Json ;
10
11
11
12
class AdminAccountTest extends \PHPUnit_Framework_TestCase
12
13
{
@@ -30,6 +31,11 @@ class AdminAccountTest extends \PHPUnit_Framework_TestCase
30
31
*/
31
32
private $ adminAccount ;
32
33
34
+ /**
35
+ * @var Json|\PHPUnit_Framework_MockObject_MockObject
36
+ */
37
+ private $ serializer ;
38
+
33
39
public function setUp ()
34
40
{
35
41
$ this ->setUpMock = $ this ->getMock (\Magento \Setup \Module \Setup::class, [], [], '' , false );
@@ -53,6 +59,12 @@ function ($table) {
53
59
$ this ->encryptor = $ this ->getMockBuilder (\Magento \Framework \Encryption \EncryptorInterface::class)
54
60
->getMockForAbstractClass ();
55
61
62
+ $ this ->serializer = $ this ->getMockBuilder (Json::class)
63
+ ->getMock ();
64
+ $ this ->serializer ->expects ($ this ->any ())->method ('serialize ' )->willReturnCallback (function ($ param ) {
65
+ return json_encode ($ param );
66
+ });
67
+
56
68
$ data = [
57
69
AdminAccount::KEY_FIRST_NAME => 'John ' ,
58
70
AdminAccount::KEY_LAST_NAME => 'Doe ' ,
@@ -61,7 +73,12 @@ function ($table) {
61
73
AdminAccount::KEY_USER => 'admin ' ,
62
74
];
63
75
64
- $ this ->adminAccount = new AdminAccount ($ this ->setUpMock , $ this ->encryptor , $ data );
76
+ $ this ->adminAccount = new AdminAccount (
77
+ $ this ->setUpMock ,
78
+ $ this ->encryptor ,
79
+ $ data ,
80
+ $ this ->serializer
81
+ );
65
82
}
66
83
67
84
public function testSaveUserExistsAdminRoleExists ()
0 commit comments