private PhpLanguageDetector CreatePhpLanguageDetector(string[] supportedPhpVersions, IEnvironment environment)
        {
            var optionsSetup = new PhpScriptGeneratorOptionsSetup(environment);
            var options      = new PhpScriptGeneratorOptions();

            optionsSetup.Configure(options);

            return(new PhpLanguageDetector(Options.Create(options), new TestPhpVersionProvider(supportedPhpVersions), NullLogger <PhpLanguageDetector> .Instance));
        }
        public void Configure_SetsPythonVersion_ToLatestVersion_WhenNoEnvironmentVariableSet()
        {
            // Arrange
            var environment  = new TestEnvironment();
            var optionsSetup = new PhpScriptGeneratorOptionsSetup(environment);
            var options      = new PhpScriptGeneratorOptions();

            // Act
            optionsSetup.Configure(options);

            // Assert
            Assert.Equal(PhpConstants.DefaultPhpRuntimeVersion, options.PhpDefaultVersion);
        }
Esempio n. 3
0
        //[Fact]
        //public void GeneratedScript_UsesNpmInstall_IfPackageLockJsonFileIsPresent()
        //{
        //    // Arrange
        //    var scriptGenerator = GetScriptGenerator(defaultNpmVersion: "6.0.0");
        //    var repo = new MemorySourceRepo();
        //    repo.AddFile(ComposerFileWithNoNpmVersion, NodeConstants.ComposerFileFileName);
        //    repo.AddFile("Package lock json file content here", NodeConstants.PackageLockJsonFileName);
        //    var context = CreateBuildScriptGeneratorContext(repo);
        //    context.LanguageVersion = "8.2.1";
        //    var expected = new NodeBashBuildSnippetProperties(
        //        packageInstallCommand: NpmInstallCommand,
        //        runBuildCommand: null,
        //        runBuildAzureCommand: null);

        //    // Act
        //    var snippet = scriptGenerator.GenerateBashBuildScriptSnippet(context);

        //    // Assert
        //    Assert.NotNull(snippet);
        //    Assert.Equal(TemplateHelpers.Render(
        //        TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
        //}

        //[Fact]
        //public void GeneratedScript_UsesNpmRunBuild_IfBuildNodeIsPresentUnderScripts()
        //{
        //    // Arrange
        //    var scriptGenerator = GetScriptGenerator(defaultNpmVersion: "6.0.0");
        //    var repo = new MemorySourceRepo();
        //    repo.AddFile(ComposerFileWithBuildScript, NodeConstants.ComposerFileFileName);
        //    var context = CreateBuildScriptGeneratorContext(repo);
        //    context.LanguageVersion = "8.2.1";
        //    var expected = new NodeBashBuildSnippetProperties(
        //        packageInstallCommand: NpmInstallCommand,
        //        runBuildCommand: "npm run build",
        //        runBuildAzureCommand: "npm run build:azure");

        //    // Act
        //    var snippet = scriptGenerator.GenerateBashBuildScriptSnippet(context);

        //    // Assert
        //    Assert.NotNull(snippet);
        //    Assert.Equal(TemplateHelpers.Render(
        //        TemplateHelpers.TemplateResource.NodeSnippet, expected), snippet.BashBuildScriptSnippet);
        //}

        private IProgrammingPlatform GetScriptGenerator(string defaultVersion = null)
        {
            var environment = new TestEnvironment();

            environment.Variables[PhpConstants.PhpRuntimeVersionEnvVarName] = defaultVersion;

            var phpVersionProvider = new TestPhpVersionProvider(new[] { "7.2.15", Common.PhpVersions.Php73Version });

            var scriptGeneratorOptions = Options.Create(new PhpScriptGeneratorOptions());
            var optionsSetup           = new PhpScriptGeneratorOptionsSetup(environment);

            optionsSetup.Configure(scriptGeneratorOptions.Value);

            return(new PhpPlatform(scriptGeneratorOptions, phpVersionProvider, NullLogger <PhpPlatform> .Instance, null));
        }
        public void Configure_SetsPythonVersion_ToEnvironmentVariableValue()
        {
            // Arrange
            var environment = new TestEnvironment();

            environment.Variables[PhpConstants.PhpRuntimeVersionEnvVarName] = "10.10.10";
            var optionsSetup = new PhpScriptGeneratorOptionsSetup(environment);
            var options      = new PhpScriptGeneratorOptions();

            // Act
            optionsSetup.Configure(options);

            // Assert
            Assert.Equal("10.10.10", options.PhpVersion);
        }