PhilippBaschke\ACFProInstaller\Test\PluginTest::testAddVersionOnInstall PHP Метод

testAddVersionOnInstall() публичный Метод

    public function testAddVersionOnInstall()
    {
        // The version that should be required
        $version = '1.2.3';
        // Make key available in the ENVIRONMENT
        putenv(self::KEY_ENV_VARIABLE . '=KEY');
        // Mock a Package
        $package = $this->getMockBuilder('Composer\\Package\\PackageInterface')->setMethods(['getName', 'getPrettyVersion', 'getDistUrl', 'setDistUrl'])->getMockForAbstractClass();
        $package->expects($this->once())->method('getName')->willReturn(self::REPO_NAME);
        $package->expects($this->once())->method('getPrettyVersion')->willReturn($version);
        $package->expects($this->once())->method('getDistUrl')->willReturn(self::REPO_URL);
        $package->expects($this->once())->method('setDistUrl')->with(self::REPO_URL . "&t={$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);
    }