Merge pull request #10 from barryvdh/test-ghactions

Create run-tests.yml
This commit is contained in:
Barry vd. Heuvel
2022-10-31 16:22:38 +01:00
committed by GitHub
22 changed files with 107 additions and 58 deletions
+43
View File
@@ -0,0 +1,43 @@
name: Unit Tests
on:
push:
branches:
- master
pull_request:
branches:
- "*"
schedule:
- cron: '0 0 * * *'
jobs:
php-tests:
runs-on: ubuntu-latest
timeout-minutes: 15
env:
COMPOSER_NO_INTERACTION: 1
strategy:
matrix:
php: [8.1, 8.0, 7.4, 7.3, 7.2]
dependency-version: [prefer-lowest, prefer-stable]
name: P${{ matrix.php }} - ${{ matrix.dependency-version }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
tools: composer:v2
- name: Install dependencies
run: |
composer update --${{ matrix.dependency-version }} --prefer-dist --no-progress
- name: Execute Unit Tests
run: vendor/bin/phpunit
-26
View File
@@ -1,26 +0,0 @@
language: php
matrix:
include:
- php: 5.3
dist: precise
- php: 5.4
dist: trusty
- php: 5.5
dist: trusty
- php: 5.6
dist: xenial
- php: 7.0
dist: xenial
- php: 7.1
dist: bionic
- php: 7.2
dist: bionic
- php: 7.3
dist: bionic
- php: 7.4
dist: bionic
before_script: travis_retry composer install
script: vendor/bin/phpunit
+1 -1
View File
@@ -12,7 +12,7 @@
"psr-0": {"Barryvdh": ["src/"]} "psr-0": {"Barryvdh": ["src/"]}
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~4.0,<4.5" "phpunit/phpunit": "^8.5.14|^9"
}, },
"suggest": { "suggest": {
"dflydev/markdown": "~1.0", "dflydev/markdown": "~1.0",
@@ -210,11 +210,7 @@ class Collection extends \ArrayObject
if ('' !== $namespace) { if ('' !== $namespace) {
$namespace .= self::OPERATOR_NAMESPACE; $namespace .= self::OPERATOR_NAMESPACE;
} }
$with_name_space = self::OPERATOR_NAMESPACE . $namespace . $type; return self::OPERATOR_NAMESPACE . $namespace . $type;
if($this->shouldBeAbsolute($with_name_space)){
return $with_name_space;
}
return $type;
} }
if (strpos($type_parts[0], '::')) { if (strpos($type_parts[0], '::')) {
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock; namespace Barryvdh\Reflection\DocBlock;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Description * Test class for \Barryvdh\Reflection\DocBlock\Description
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class DescriptionTest extends \PHPUnit_Framework_TestCase class DescriptionTest extends TestCase
{ {
public function testConstruct() public function testConstruct()
{ {
@@ -106,7 +108,7 @@ LONGDESC;
$parsedDescription = $parsedContents[1]->getParsedDescription(); $parsedDescription = $parsedContents[1]->getParsedDescription();
$this->assertCount(3, $parsedDescription); $this->assertCount(3, $parsedDescription);
$this->assertSame("inline tag with\n", $parsedDescription[0]); $this->assertSame("inline tag with", trim($parsedDescription[0]));
$this->assertInstanceOf( $this->assertInstanceOf(
__NAMESPACE__ . '\Tag\LinkTag', __NAMESPACE__ . '\Tag\LinkTag',
$parsedDescription[1] $parsedDescription[1]
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\CoversTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\CoversTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class CoversTagTest extends \PHPUnit_Framework_TestCase class CoversTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\CoversTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\CoversTag can create
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\DeprecatedTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class DeprecatedTagTest extends \PHPUnit_Framework_TestCase class DeprecatedTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\ExampleTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\ExampleTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class ExampleTagTest extends \PHPUnit_Framework_TestCase class ExampleTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\LinkTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\LinkTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class LinkTagTest extends \PHPUnit_Framework_TestCase class LinkTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\MethodTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\MethodTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class MethodTagTest extends \PHPUnit_Framework_TestCase class MethodTagTest extends TestCase
{ {
/** /**
* @param string $signature The signature to test. * @param string $signature The signature to test.
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\ParamTag * Test class for \Barryvdh\Reflection\DocBlock\ParamTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class ParamTagTest extends \PHPUnit_Framework_TestCase class ParamTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ParamTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\ParamTag can
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\ReturnTag * Test class for \Barryvdh\Reflection\DocBlock\ReturnTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class ReturnTagTest extends \PHPUnit_Framework_TestCase class ReturnTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ReturnTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\ReturnTag can
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SeeTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\SeeTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class SeeTagTest extends \PHPUnit_Framework_TestCase class SeeTagTest extends TestCase
{ {
/** /**
* Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link * Test that the phpDocumentor_Reflection_DocBlock_Tag_See can create a link
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SinceTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\SinceTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class SinceTagTest extends \PHPUnit_Framework_TestCase class SinceTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\SourceTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\SourceTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class SourceTagTest extends \PHPUnit_Framework_TestCase class SourceTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\SourceTag can
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\ThrowsTag * Test class for \Barryvdh\Reflection\DocBlock\ThrowsTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class ThrowsTagTest extends \PHPUnit_Framework_TestCase class ThrowsTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\ThrowsTag can
@@ -12,6 +12,9 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\UsesTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\UsesTag
* *
@@ -20,7 +23,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class UsesTagTest extends \PHPUnit_Framework_TestCase class UsesTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\UsesTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\UsesTag can create
@@ -12,6 +12,9 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
* *
@@ -20,7 +23,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class VarTagTest extends \PHPUnit_Framework_TestCase class VarTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\VarTag can * Test that the \Barryvdh\Reflection\DocBlock\Tag\VarTag can
@@ -12,6 +12,8 @@
namespace Barryvdh\Reflection\DocBlock\Tag; namespace Barryvdh\Reflection\DocBlock\Tag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VersionTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\VersionTag
* *
@@ -20,7 +22,7 @@ namespace Barryvdh\Reflection\DocBlock\Tag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class VersionTagTest extends \PHPUnit_Framework_TestCase class VersionTagTest extends TestCase
{ {
/** /**
* Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create * Test that the \Barryvdh\Reflection\DocBlock\Tag\LinkTag can create
@@ -14,6 +14,7 @@ namespace Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock; use Barryvdh\Reflection\DocBlock;
use Barryvdh\Reflection\DocBlock\Context; use Barryvdh\Reflection\DocBlock\Context;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag * Test class for \Barryvdh\Reflection\DocBlock\Tag\VarTag
@@ -23,16 +24,16 @@ use Barryvdh\Reflection\DocBlock\Context;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class TagTest extends \PHPUnit_Framework_TestCase class TagTest extends TestCase
{ {
/** /**
* @expectedException \InvalidArgumentException *
*
* @return void * @return void
*/ */
public function testInvalidTagLine() public function testInvalidTagLine()
{ {
$this->expectException(\InvalidArgumentException::class);
Tag::createInstance('Invalid tag line'); Tag::createInstance('Invalid tag line');
} }
@@ -76,7 +77,7 @@ class TagTest extends \PHPUnit_Framework_TestCase
*/ */
public function testTagHandlerCorrectRegistration() public function testTagHandlerCorrectRegistration()
{ {
if (0 == ini_get('allow_url_include')) { if (!ini_get('allow_url_include')) {
$this->markTestSkipped('"data" URIs for includes are required.'); $this->markTestSkipped('"data" URIs for includes are required.');
} }
$currentHandler = __NAMESPACE__ . '\Tag\VarTag'; $currentHandler = __NAMESPACE__ . '\Tag\VarTag';
@@ -13,6 +13,7 @@
namespace Barryvdh\Reflection\DocBlock\Type; namespace Barryvdh\Reflection\DocBlock\Type;
use Barryvdh\Reflection\DocBlock\Context; use Barryvdh\Reflection\DocBlock\Context;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for \Barryvdh\Reflection\DocBlock\Type\Collection * Test class for \Barryvdh\Reflection\DocBlock\Type\Collection
@@ -24,7 +25,7 @@ use Barryvdh\Reflection\DocBlock\Context;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class CollectionTest extends \PHPUnit_Framework_TestCase class CollectionTest extends TestCase
{ {
/** /**
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct * @covers Barryvdh\Reflection\DocBlock\Type\Collection::__construct
@@ -145,12 +146,12 @@ class CollectionTest extends \PHPUnit_Framework_TestCase
/** /**
* @covers Barryvdh\Reflection\DocBlock\Type\Collection::add * @covers Barryvdh\Reflection\DocBlock\Type\Collection::add
* @expectedException InvalidArgumentException
* *
* @return void * @return void
*/ */
public function testAddWithInvalidArgument() public function testAddWithInvalidArgument()
{ {
$this->expectException(\InvalidArgumentException::class);
$collection = new Collection(); $collection = new Collection();
$collection->add(array()); $collection->add(array());
} }
+6 -4
View File
@@ -15,6 +15,7 @@ namespace Barryvdh\Reflection;
use Barryvdh\Reflection\DocBlock\Context; use Barryvdh\Reflection\DocBlock\Context;
use Barryvdh\Reflection\DocBlock\Location; use Barryvdh\Reflection\DocBlock\Location;
use Barryvdh\Reflection\DocBlock\Tag\ReturnTag; use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
use PHPUnit\Framework\TestCase;
/** /**
* Test class for Barryvdh\Reflection\DocBlock * Test class for Barryvdh\Reflection\DocBlock
@@ -24,7 +25,7 @@ use Barryvdh\Reflection\DocBlock\Tag\ReturnTag;
* @license http://www.opensource.org/licenses/mit-license.php MIT * @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org * @link http://phpdoc.org
*/ */
class DocBlockTest extends \PHPUnit_Framework_TestCase class DocBlockTest extends TestCase
{ {
/** /**
* @covers \Barryvdh\Reflection\DocBlock * @covers \Barryvdh\Reflection\DocBlock
@@ -165,12 +166,12 @@ DOCBLOCK;
} }
/** /**
* @expectedException \InvalidArgumentException *
*
* @return void * @return void
*/ */
public function testExceptionOnInvalidObject() public function testExceptionOnInvalidObject()
{ {
$this->expectException(\InvalidArgumentException::class);
new DocBlock($this); new DocBlock($this);
} }
@@ -203,8 +204,9 @@ DOCBLOCK;
*/ */
public function testInvalidTagBlock() public function testInvalidTagBlock()
{ {
if (0 == ini_get('allow_url_include')) { if (!ini_get('allow_url_include')) {
$this->markTestSkipped('"data" URIs for includes are required.'); $this->markTestSkipped('"data" URIs for includes are required.');
return;
} }
include 'data:text/plain;base64,'. base64_encode( include 'data:text/plain;base64,'. base64_encode(