mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
* phpunit: use dedicate `Tests` namespace for tests * tests: replace phpunit with orchestra/testbench * phpunit: ignore result cache file * phpunit: adapt test for newer version * tests: add base testcase class with a helper to run/assert commands * tests: add test for ide-helper:eloquent * travis: add global default variables * travis: disable xdebug, speeds up running tests * travis: convert php versions to build matrix for environment vars * travis: only run phpcs/phpunit when the env vars signal it However phpcs only runs with one test combination from the matrix, not necessary to execute it every time.
64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Barryvdh\LaravelIdeHelper\Tests;
|
|
|
|
use Barryvdh\LaravelIdeHelper\Method;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ExampleTest extends TestCase
|
|
{
|
|
/**
|
|
* Test that we can actually instantiate the class
|
|
*/
|
|
public function testCanInstantiate()
|
|
{
|
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
|
$reflectionMethod = $reflectionClass->getMethod('setName');
|
|
|
|
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
|
|
|
$this->assertInstanceOf(Method::class, $method);
|
|
}
|
|
|
|
/**
|
|
* Test the output of a class
|
|
*/
|
|
public function testOutput()
|
|
{
|
|
$reflectionClass = new \ReflectionClass(ExampleClass::class);
|
|
$reflectionMethod = $reflectionClass->getMethod('setName');
|
|
|
|
$method = new Method($reflectionMethod, 'Example', $reflectionClass);
|
|
|
|
$output = '/**
|
|
*
|
|
*
|
|
* @param string $last
|
|
* @param string $first
|
|
* @param string $middle
|
|
* @static
|
|
*/';
|
|
$this->assertEquals($output, $method->getDocComment(''));
|
|
$this->assertEquals('setName', $method->getName());
|
|
$this->assertEquals('\\'.ExampleClass::class, $method->getDeclaringClass());
|
|
$this->assertEquals('$last, $first, ...$middle', $method->getParams(true));
|
|
$this->assertEquals(['$last', '$first', '...$middle'], $method->getParams(false));
|
|
$this->assertEquals('$last, $first = \'Barry\', ...$middle', $method->getParamsWithDefault(true));
|
|
$this->assertEquals(['$last', '$first = \'Barry\'', '...$middle'], $method->getParamsWithDefault(false));
|
|
$this->assertEquals(true, $method->shouldReturn());
|
|
}
|
|
}
|
|
|
|
class ExampleClass
|
|
{
|
|
/**
|
|
* @param string $last
|
|
* @param string $first
|
|
* @param string $middle
|
|
*/
|
|
public function setName($last, $first = 'Barry', ...$middle)
|
|
{
|
|
return;
|
|
}
|
|
}
|