This commit is contained in:
Jakub Míšek 2020-11-01 22:18:27 +01:00
Родитель 208a979ad8
Коммит 61076b968d
24 изменённых файлов: 54 добавлений и 152 удалений

Просмотреть файл

@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<PhpUnitVersion Condition="$(PhpUnitVersion) == ''">9.2.3</PhpUnitVersion>
<PhpUnitVersion Condition="$(PhpUnitVersion) == ''">9.2.6</PhpUnitVersion>
<VersionSuffix>preview3</VersionSuffix>
</PropertyGroup>
</Project>

12
NuGet.Config Normal file
Просмотреть файл

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="./packages" />
</config>
<packageSources>
<remove key="peachpie.io(public)" />
<add key="peachpie.io(public)" value="https://feed.peachpie.io/public/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -5,13 +5,13 @@ VisualStudioVersion = 16.0.29911.84
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-phpunit", "src\dotnet-phpunit\dotnet-phpunit.csproj", "{82009126-14D0-4518-A424-70D6109F2FC3}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "Peachpied.PhpUnit", "src\Peachpied.PhpUnit\Peachpied.PhpUnit.msbuildproj", "{EE7AC928-31FD-4ABF-A69B-E5F992B183AF}"
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "phpunit.phpunit.phar", "src\phpunit.phpunit.phar\phpunit.phpunit.phar.msbuildproj", "{EE7AC928-31FD-4ABF-A69B-E5F992B183AF}"
EndProject
Project("{13B669BE-BB05-4DDF-9536-439F39A36129}") = "Lib", "samples\Lib\Lib.msbuildproj", "{1C3E0802-1C80-44E2-9609-1DBCD2A0366A}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{4BAA7A9F-4A8C-4AD5-9842-61DAA740A871}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Peachpied.PhpUnit.TestAdapter", "src\Peachpied.PhpUnit.TestAdapter\Peachpied.PhpUnit.TestAdapter.csproj", "{D60B740C-3C98-4519-90DC-1B91239C5623}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PHPUnit.TestAdapter", "src\PHPUnit.TestAdapter\PHPUnit.TestAdapter.csproj", "{D60B740C-3C98-4519-90DC-1B91239C5623}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{35B254AE-A7D6-42E5-9A3F-98D92CD0B8E6}"
ProjectSection(SolutionItems) = preProject

Просмотреть файл

@ -1,20 +1,14 @@
<Project Sdk="Peachpie.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**/*.php" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../../src/Peachpied.PhpUnit/Peachpied.PhpUnit.msbuildproj" />
<ProjectReference Include="../../src/Peachpied.PhpUnit.TestAdapter/Peachpied.PhpUnit.TestAdapter.csproj" />
<ProjectReference Include="..\..\src\PHPUnit.TestAdapter\PHPUnit.TestAdapter.csproj" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -1,16 +0,0 @@
<Project Sdk="Peachpie.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**/*.php" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="Peachpied.PhpUnit.TestAdapter" Version="$(PhpUnitVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,8 +0,0 @@
<phpunit bootstrap="src/Email.php">
<testsuites>
<!-- Default test suite to run all tests. -->
<testsuite name="tests">
<directory suffix=".php">tests</directory>
</testsuite>
</testsuites>
</phpunit>

Просмотреть файл

@ -1,52 +0,0 @@
<?php
declare(strict_types=1);
final class Email
{
private $email;
private function __construct(string $email)
{
$this->ensureIsValidEmail($email);
$this->email = $email;
}
public static function fromString(string $email): self
{
return new self($email);
}
public function __toString(): string
{
return $this->email;
}
private function ensureIsValidEmail(string $email): void
{
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
throw new InvalidArgumentException(
sprintf(
'"%s" is not a valid email address',
$email
)
);
}
}
/**
* @dataProvider dataProvider
*/
public function testDataProviding($val)
{
$this->assertEquals(42, $val);
}
public function dataProvider()
{
return array(
array(42),
array("42")
);
}
}

Просмотреть файл

@ -1,33 +0,0 @@
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
/**
* @covers Email
*/
final class EmailTest extends TestCase
{
public function testCanBeCreatedFromValidEmailAddress(): void
{
$this->assertInstanceOf(
Email::class,
Email::fromString('user@example.com')
);
}
public function testCannotBeCreatedFromInvalidEmailAddress(): void
{
$this->expectException(InvalidArgumentException::class);
Email::fromString('invalid');
}
public function testCanBeUsedAsString(): void
{
$this->assertEquals(
'user@example.com',
Email::fromString('user@example.com')
);
}
}

Просмотреть файл

@ -2,7 +2,7 @@
<configuration>
<packageSources>
<add key="Generated PHPUnit packages" value="../nupkg" />
<add key="Generated PHPUnit packages" value="../packages" />
</packageSources>
</configuration>

Просмотреть файл

@ -3,9 +3,8 @@
<Import Project="$(MSBuildThisFileDirectory)../Directory.Build.props" />
<PropertyGroup>
<Version>$(PhpUnitVersion)</Version>
<PackageVersion>$(PhpUnitVersion)</PackageVersion>
<PackageOutputPath>$(MSBuildThisFileDirectory)../nupkg</PackageOutputPath>
<VersionPrefix>$(PhpUnitVersion)</VersionPrefix>
<PackageOutputPath>$(MSBuildThisFileDirectory)../artifacts</PackageOutputPath>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>

Просмотреть файл

@ -5,7 +5,7 @@ using System.IO;
using System.Linq;
using System.Text;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Helper to obtain the information about the environment where the tests are being run.

Просмотреть файл

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.0.0" ExcludeAssets="runtime" />
<PackageReference Include="phpunit.phpunit" Version="$(PhpUnitVersion)-preview3" />
<PackageReference Include="phpunit.php-file-iterator" Version="3.0.5-preview3" />
<PackageReference Include="phpunit.php-timer" Version="5.0.3-preview3" />
</ItemGroup>
</Project>

Просмотреть файл

@ -8,7 +8,7 @@ using System.IO;
using System.Reflection;
using System.Text;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Helper for running PHPUnit and translating test names.

Просмотреть файл

@ -9,7 +9,7 @@ using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Implementation of the <see cref="ITestDiscoverer"/> interface used to discover tests prior to running
@ -28,7 +28,7 @@ namespace Peachpied.PhpUnit.TestAdapter
{
ProcessSource(discoverySink, source);
}
catch (Exception e)
catch (System.Exception e)
{
logger.SendMessage(TestMessageLevel.Error, e.Message + "\n" + e.StackTrace);
}

Просмотреть файл

@ -11,7 +11,7 @@ using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Implementation of the <see cref="ITestExecutor"/> interface used to run tests.
@ -77,7 +77,7 @@ namespace Peachpied.PhpUnit.TestAdapter
ctx.SetProperty(testRunCtx);
});
}
catch (Exception e)
catch (System.Exception e)
{
frameworkHandle.SendMessage(TestMessageLevel.Error, e.Message + "\n" + e.StackTrace);
}

Просмотреть файл

@ -6,7 +6,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Custom PHPUnit extension to report the test results.
@ -14,9 +14,9 @@ namespace Peachpied.PhpUnit.TestAdapter
/// </summary>
internal class TestReporterExtension : BeforeTestHook, AfterSuccessfulTestHook, AfterTestErrorHook, AfterTestFailureHook, AfterSkippedTestHook
{
public readonly static string PhpName = typeof(TestReporterExtension).GetPhpTypeInfo().Name;
public static string PhpName => PhpTypeInfoExtension.GetPhpTypeInfo<TestReporterExtension>().Name;
private TestRunContext _testRunContext;
readonly TestRunContext _testRunContext;
public TestReporterExtension(Context ctx)
{

Просмотреть файл

@ -3,7 +3,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// Class to store information about the current test run to be used from <see cref="TestReporterExtension"/>.

Просмотреть файл

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Xml.Linq;
namespace Peachpied.PhpUnit.TestAdapter
namespace PHPUnit.TestAdapter
{
/// <summary>
/// LINQ to XML utility methods.

Просмотреть файл

@ -1,15 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="16.0.0" ExcludeAssets="runtime" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Peachpied.PhpUnit\Peachpied.PhpUnit.msbuildproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -159,7 +159,10 @@ namespace DotnetPhpUnit
// Run the PHAR entry point so that all the classes are included
var pharLoader = Context.TryGetDeclaredScript(PharName);
RunScript(ctx, () => pharLoader.Evaluate(ctx, PhpArray.NewEmpty(), null).ToInt());
if (pharLoader.IsValid)
{
RunScript(ctx, () => pharLoader.Evaluate(ctx, PhpArray.NewEmpty(), null).ToInt());
}
// Run the tests themselves
return RunScript(ctx, () => (int)Command.main(ctx, PhpTypeInfoExtension.GetPhpTypeInfo<Command>()));

Просмотреть файл

@ -13,7 +13,10 @@
<PackageReference Include="Microsoft.Build" Version="16.0.461" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Runtime" Version="16.0.461" ExcludeAssets="runtime;contentfiles" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.6" />
<ProjectReference Include="../Peachpied.PhpUnit/Peachpied.PhpUnit.msbuildproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\phpunit.phpunit.phar\phpunit.phpunit.phar.msbuildproj" />
</ItemGroup>
</Project>

Просмотреть файл

Просмотреть файл