1212namespace FOS \UserBundle \Tests \Command ;
1313
1414use FOS \UserBundle \Command \CreateUserCommand ;
15+ use FOS \UserBundle \Util \UserManipulator ;
1516use PHPUnit \Framework \TestCase ;
1617use Symfony \Component \Console \Application ;
1718use Symfony \Component \Console \Tester \CommandTester ;
18- use Symfony \Component \DependencyInjection \ContainerInterface ;
1919
2020class CreateUserCommandTest extends TestCase
2121{
2222 public function testExecute ()
2323 {
24- $ commandTester = $ this ->createCommandTester ($ this ->getContainer ('user ' , 'pass ' , 'email ' , true , false ));
24+ $ commandTester = $ this ->createCommandTester ($ this ->getManipulator ('user ' , 'pass ' , 'email ' , true , false ));
2525 $ exitCode = $ commandTester ->execute (array (
2626 'username ' => 'user ' ,
2727 'email ' => 'email ' ,
@@ -58,7 +58,7 @@ public function testExecuteInteractiveWithQuestionHelper()
5858 $ application ->getHelperSet ()->set ($ helper , 'question ' );
5959
6060 $ commandTester = $ this ->createCommandTester (
61- $ this ->getContainer ('user ' , 'pass ' , 'email ' , true , false ), $ application
61+ $ this ->getManipulator ('user ' , 'pass ' , 'email ' , true , false ), $ application
6262 );
6363 $ exitCode = $ commandTester ->execute (array (), array (
6464 'decorated ' => false ,
@@ -70,21 +70,20 @@ public function testExecuteInteractiveWithQuestionHelper()
7070 }
7171
7272 /**
73- * @param ContainerInterface $container
73+ * @param UserManipulator $manipulator
7474 * @param Application|null $application
7575 *
7676 * @return CommandTester
7777 */
78- private function createCommandTester (ContainerInterface $ container , Application $ application = null )
78+ private function createCommandTester (UserManipulator $ manipulator , Application $ application = null )
7979 {
8080 if (null === $ application ) {
8181 $ application = new Application ();
8282 }
8383
8484 $ application ->setAutoExit (false );
8585
86- $ command = new CreateUserCommand ();
87- $ command ->setContainer ($ container );
86+ $ command = new CreateUserCommand ($ manipulator );
8887
8988 $ application ->add ($ command );
9089
@@ -100,10 +99,8 @@ private function createCommandTester(ContainerInterface $container, Application
10099 *
101100 * @return mixed
102101 */
103- private function getContainer ($ username , $ password , $ email , $ active , $ superadmin )
102+ private function getManipulator ($ username , $ password , $ email , $ active , $ superadmin )
104103 {
105- $ container = $ this ->getMockBuilder ('Symfony\Component\DependencyInjection\ContainerInterface ' )->getMock ();
106-
107104 $ manipulator = $ this ->getMockBuilder ('FOS\UserBundle\Util\UserManipulator ' )
108105 ->disableOriginalConstructor ()
109106 ->getMock ();
@@ -114,12 +111,6 @@ private function getContainer($username, $password, $email, $active, $superadmin
114111 ->with ($ username , $ password , $ email , $ active , $ superadmin )
115112 ;
116113
117- $ container
118- ->expects ($ this ->once ())
119- ->method ('get ' )
120- ->with ('fos_user.util.user_manipulator ' )
121- ->will ($ this ->returnValue ($ manipulator ));
122-
123- return $ container ;
114+ return $ manipulator ;
124115 }
125116}
0 commit comments