N98\Magento\Command\Admin\User\ChangeStatusCommandTest::testCanToggleUserByEmail PHP Method

testCanToggleUserByEmail() public method

    public function testCanToggleUserByEmail()
    {
        $username = 'aydin';
        $this->userModel->expects($this->once())->method('loadByUsername')->with($username)->will($this->returnValue($this->userModel));
        $this->userModel->expects($this->at(1))->method('getId')->will($this->returnValue(0));
        $this->userModel->expects($this->once())->method('load')->will($this->returnValue($this->userModel));
        $this->userModel->expects($this->at(3))->method('getId')->will($this->returnValue(2));
        $this->userModel->expects($this->once())->method('validate');
        $this->userModel->expects($this->at(5))->method('getIsActive')->will($this->returnValue(0));
        $this->userModel->expects($this->once())->method('setIsActive')->with(1);
        $this->userModel->expects($this->once())->method('save');
        $this->userModel->expects($this->at(8))->method('getIsActive')->will($this->returnValue(1));
        $this->userModel->expects($this->once())->method('getUsername')->will($this->returnValue($username));
        $application = $this->getApplication();
        $application->add($this->command);
        $command = $this->getApplication()->find($this->commandName);
        $commandTester = new CommandTester($command);
        $commandTester->execute(array('command' => $command->getName(), 'id' => $username));
        $this->assertContains("User {$username} is now active", $commandTester->getDisplay());
    }