public function testIndexActionManualKeys()
 {
     $this->_softwareManager->expects($this->once())->method('getNumManualProductKeys')->willReturn(1);
     $this->dispatch('/console/licenses/index/');
     $this->assertResponseStatusCode(200);
     $this->assertXPathQueryContentContains('//p/a[@href="/console/client/index/?' . 'columns=Name,OsName,Windows.ProductKey,Windows.ManualProductKey&' . 'filter=Windows.ManualProductKey&order=Name&direction=asc"]', "\n1\n");
 }
 public function testIndexActionManualKeys()
 {
     // Nonzero manual product keys produce <dd><a...>n</a></dd>.
     $this->_softwareManager = $this->getMockBuilder('Model\\SoftwareManager')->disableOriginalConstructor()->getMock();
     $this->_softwareManager->expects($this->once())->method('getNumManualProductKeys')->willReturn(1);
     $this->dispatch('/console/licenses/index/');
     $this->assertResponseStatusCode(200);
     $this->assertXPathQueryContentContains('//dd/a[@href="/console/client/index/?' . 'columns=Name,OsName,Windows.ProductKey,Windows.ManualProductKey&' . 'filter=Windows.ManualProductKey&order=Name&direction=asc"]', "\n1\n");
 }
 protected function _testManageActionPostYes($action, $display)
 {
     $tmBad = chr(0xc2) . chr(0x99);
     // Incorrect representation of TM symbol
     $this->_softwareManager->expects($this->once())->method('setDisplay')->with($tmBad, $display);
     $session = new \Zend\Session\Container('ManageSoftware');
     $session->filter = 'test';
     $this->dispatch("/console/software/{$action}/?name={$tmBad}", 'POST', array('yes' => 'Yes'));
     $this->assertRedirectTo('/console/software/index/?filter=test');
 }
 public function testWindowsActionPostValid()
 {
     $postData = array('Key' => 'entered_key');
     $form = $this->getApplicationServiceLocator()->get('FormElementManager')->get('Console\\Form\\ProductKey');
     $form->expects($this->once())->method('setData')->with($postData);
     $form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $form->expects($this->once())->method('getData')->will($this->returnValue($postData));
     $map = array(array('Id', 1));
     $client = $this->createMock('Model\\Client\\Client');
     $client->method('offsetGet')->will($this->returnValueMap($map));
     $this->_clientManager->method('getClient')->willReturn($client);
     $this->_softwareManager->expects($this->once())->method('setProductKey')->with($client, 'entered_key');
     $this->dispatch('/console/client/windows/?id=1', 'POST', $postData);
     $this->assertRedirectTo('/console/client/windows/?id=1');
 }
 /**
  * Information about a client's Windows installation
  *
  * @return array client, windows, form (Product key form)
  */
 public function windowsAction()
 {
     $windows = $this->_currentClient['Windows'];
     $form = $this->_formManager->get('Console\\Form\\ProductKey');
     if ($this->getRequest()->isPost()) {
         $form->setData($this->params()->fromPost());
         if ($form->isValid()) {
             $data = $form->getData();
             $this->_softwareManager->setProductKey($this->_currentClient, $data['Key']);
             return $this->redirectToRoute('client', 'windows', array('id' => $this->_currentClient['Id']));
         }
     } else {
         $form->setData(array('Key' => $windows['ManualProductKey']));
     }
     return array('client' => $this->_currentClient, 'windows' => $windows, 'form' => $form);
 }
 /**
  * Accept or ignore selected software
  *
  * @param bool $display Display status to set
  * @return mixed array(name) or redirect response
  */
 protected function _manage($display)
 {
     $name = $this->params()->fromQuery('name');
     if ($name === null) {
         throw new \RuntimeException('Missing name parameter');
     }
     if ($this->getRequest()->isGet()) {
         return array('name' => $name);
         // Display confirmation form
     } else {
         if ($this->params()->fromPost('yes')) {
             $this->_softwareManager->setDisplay($name, $display);
         }
         $session = new \Zend\Session\Container('ManageSoftware');
         return $this->redirectToRoute('software', 'index', array('filter' => $session->filter));
     }
 }
 /**
  * Display overview of software licenses
  *
  * @return array windowsProductKeys => number of manually entered keys
  */
 public function indexAction()
 {
     return array('windowsProductKeys' => $this->_softwareManager->getNumManualProductKeys());
 }