public function testComponentsAction()
 {
     $this->composerInformation->expects($this->once())->method('getInstalledMagentoPackages')->willReturn(['magento/sample-module1' => ['name' => 'magento/sample-module1', 'type' => 'magento2-module', 'version' => '1.0.0']]);
     $this->composerInformation->expects($this->once())->method('isPackageInComposerJson')->willReturn(true);
     $this->infoCommand->expects($this->once())->method('run')->willReturn(['versions' => '3.0.0, 2.0.0', 'current_version' => '1.0.0', 'new_versions' => ['3.0.0', '2.0.0']]);
     $jsonModel = $this->controller->componentsAction();
     $this->assertInstanceOf('Zend\\View\\Model\\JsonModel', $jsonModel);
     $variables = $jsonModel->getVariables();
     $this->assertArrayHasKey('responseType', $variables);
     $this->assertEquals(ResponseTypeInterface::RESPONSE_TYPE_SUCCESS, $variables['responseType']);
     $this->assertArrayHasKey('components', $variables);
     $expected = ['0' => ['name' => 'magento/sample-module1', 'type' => 'magento2-module', 'version' => '1.0.0', 'vendor' => 'magento', 'updates' => [['id' => '3.0.0', 'name' => '3.0.0 (latest)'], ['id' => '2.0.0', 'name' => '2.0.0'], ['id' => '1.0.0', 'name' => '1.0.0 (current)']], 'dropdownId' => 'dd_magento/sample-module1', 'checkboxId' => 'cb_magento/sample-module1']];
     $this->assertEquals($expected, $variables['components']);
     $this->assertArrayHasKey('total', $variables);
     $this->assertEquals(1, $variables['total']);
 }
    /**
     * @param string $ceCurrentVersion
     * @param array $expectedResult
     *
     * @dataProvider getAllowedEnterpriseVersionsDataProvider
     */
    public function testGetAllowedEnterpriseVersions($ceCurrentVersion, $expectedResult)
    {
        $this->composerAppFactory->expects($this->once())
            ->method('createInfoCommand')
            ->willReturn($this->infoCommand);
        $this->systemPackage = new SystemPackage($this->composerAppFactory, $this->composerInformation);
        $this->infoCommand->expects($this->once())
            ->method('run')
            ->with('magento/product-enterprise-edition')
            ->willReturn(['available_versions' => ['1.0.0', '1.0.1', '1.0.2']]);
        $require = $this->getMock('\Composer\Package\Link', [], [], '', false);
        $constraintMock = $this->getMock('\Composer\Package\LinkConstraint\VersionConstraint', [], [], '', false);
        $constraintMock->expects($this->any())->method('getPrettyString')
            ->willReturn('1.0.1');
        $require->expects($this->any())
            ->method('getConstraint')
            ->willReturn($constraintMock);

        $this->composerInformation->expects($this->any())
            ->method('getPackageRequirements')
            ->willReturn(['magento/product-community-edition' => $require]);
        $this->assertEquals(
            $expectedResult,
            $this->systemPackage->getAllowedEnterpriseVersions($ceCurrentVersion)
        );
    }
 /**
  * @expectedException \RuntimeException
  * @expectedExceptionMessage
  */
 public function testRunException()
 {
     $this->application->expects($this->at(1))->method('runComposerCommand')->willThrowException(new \RuntimeException($this->errorMessage));
     $this->infoCommand->expects($this->once())->method('run')->willReturn($this->packageInfo);
     $this->requireUpdateDryRunCommand->run(['3rdp/e 1.2.0'], '');
 }