Example #1
0
 public function testLoadByUsername()
 {
     $returnData = [1, 2, 3];
     $this->resourceMock->expects($this->once())->method('getConnection')->willReturn($this->dbAdapterMock);
     $this->dbAdapterMock->expects($this->once())->method('select')->willReturn($this->selectMock);
     $this->selectMock->expects($this->once())->method('from')->willReturn($this->selectMock);
     $this->selectMock->expects($this->atLeastOnce())->method('where')->willReturn($this->selectMock);
     $this->dbAdapterMock->expects($this->once())->method('fetchRow')->willReturn($returnData);
     $this->assertEquals($returnData, $this->model->loadByUsername('user1'));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $adminUserName = $input->getArgument(self::ARGUMENT_ADMIN_USERNAME);
     $userData = $this->adminUser->loadByUsername($adminUserName);
     $outputMessage = sprintf('Couldn\'t find the user account "%s"', $adminUserName);
     if ($userData) {
         if (isset($userData[self::USER_ID]) && $this->adminUser->unlock($userData[self::USER_ID])) {
             $outputMessage = sprintf('The user account "%s" has been unlocked', $adminUserName);
         } else {
             $outputMessage = sprintf('The user account "%s" was not locked or could not be unlocked', $adminUserName);
         }
     }
     $output->writeln('<info>' . $outputMessage . '</info>');
 }