Skip to content

Commit

Permalink
Styling (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dor authored Jul 5, 2019
1 parent cac402a commit 4474209
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions tests/BuildScriptGenerator.Tests/Php/PhpLanguageDetectorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.Extensions.Options;
using Microsoft.Oryx.BuildScriptGenerator.Exceptions;
using Microsoft.Oryx.BuildScriptGenerator.Php;
using Microsoft.Oryx.Common;
using Microsoft.Oryx.Tests.Common;
using Xunit;

Expand All @@ -26,7 +27,7 @@ public PhpLanguageDetectorTest(TestTempDirTestFixture testFixture)
public void Detect_ReturnsNull_WhenSourceDirectoryIsEmpty()
{
// Arrange
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { Common.PhpVersions.Php73Version });
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { PhpVersions.Php73Version });
var repo = new MemorySourceRepo(); // No files in source repo

// Act
Expand All @@ -40,7 +41,7 @@ public void Detect_ReturnsNull_WhenSourceDirectoryIsEmpty()
public void Detect_ReutrnsNull_WhenComposerFileDoesNotExist()
{
// Arrange
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { Common.PhpVersions.Php73Version });
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { PhpVersions.Php73Version });
var repo = new MemorySourceRepo();
repo.AddFile("foo.php content", "foo.php");

Expand All @@ -55,14 +56,15 @@ public void Detect_ReutrnsNull_WhenComposerFileDoesNotExist()
public void Detect_Throws_WhenUnsupportedPhpVersion_FoundInComposerFile()
{
// Arrange
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { Common.PhpVersions.Php73Version });
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { PhpVersions.Php73Version });
var repo = new MemorySourceRepo();
repo.AddFile("{\"require\":{\"php\":\"0\"}}", PhpConstants.ComposerFileName);
var version = "0";
repo.AddFile("{\"require\":{\"php\":\"" + version + "\"}}", PhpConstants.ComposerFileName);

// Act & Assert
var exception = Assert.Throws<UnsupportedVersionException>(() => detector.Detect(repo));
Assert.Equal(
$"Platform 'php' version '0' is unsupported. Supported versions: {Common.PhpVersions.Php73Version}",
$"Platform 'php' version '{version}' is unsupported. Supported versions: {PhpVersions.Php73Version}",
exception.Message);
}

Expand All @@ -72,7 +74,7 @@ public void Detect_Throws_WhenUnsupportedPhpVersion_FoundInComposerFile()
public void Detect_ReturnsResult_WithPhpDefaultRuntimeVersion_WithComposerFile(string composerFileContent)
{
// Arrange
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { Common.PhpVersions.Php73Version });
var detector = CreatePhpLanguageDetector(supportedPhpVersions: new[] { PhpVersions.Php73Version });
var repo = new MemorySourceRepo();
repo.AddFile(composerFileContent, PhpConstants.ComposerFileName);
repo.AddFile("<?php echo true; ?>", "foo.php");
Expand All @@ -83,7 +85,7 @@ public void Detect_ReturnsResult_WithPhpDefaultRuntimeVersion_WithComposerFile(s
// Assert
Assert.NotNull(result);
Assert.Equal(PhpConstants.PhpName, result.Language);
Assert.Equal(Common.PhpVersions.Php73Version, result.LanguageVersion);
Assert.Equal(PhpVersions.Php73Version, result.LanguageVersion);
}

private PhpLanguageDetector CreatePhpLanguageDetector(string[] supportedPhpVersions)
Expand Down

0 comments on commit 4474209

Please sign in to comment.