PhilippBaschke\ACFProInstaller\Test\PluginTest::versionFailsValidationHelper PHP Method

versionFailsValidationHelper() protected method

protected versionFailsValidationHelper ( $version )
    protected function versionFailsValidationHelper($version)
    {
        // Expect an Exception
        $this->setExpectedException('UnexpectedValueException', 'The version constraint of ' . self::REPO_NAME . ' should be exact (with 3 or 4 digits). ' . 'Invalid version string "' . $version . '"');
        // Mock a Package
        $package = $this->getMockBuilder('Composer\\Package\\PackageInterface')->setMethods(['getName', 'getPrettyVersion'])->getMockForAbstractClass();
        $package->expects($this->once())->method('getName')->willReturn(self::REPO_NAME);
        $package->expects($this->once())->method('getPrettyVersion')->willReturn($version);
        // Mock an Operation
        $operationClass = 'Composer\\DependencyResolver\\Operation\\InstallOperation';
        $operation = $this->getMockBuilder($operationClass)->disableOriginalConstructor()->setMethods(['getJobType', 'getPackage'])->getMock();
        $operation->expects($this->once())->method('getJobType')->willReturn('install');
        $operation->expects($this->once())->method('getPackage')->willReturn($package);
        // Mock a PackageEvent
        $packageEvent = $this->getMockBuilder('Composer\\Installer\\PackageEvent')->disableOriginalConstructor()->setMethods(['getOperation'])->getMock();
        $packageEvent->expects($this->once())->method('getOperation')->willReturn($operation);
        // Call addVersion
        $plugin = new Plugin();
        $plugin->addVersion($packageEvent);
    }