Commit 3a019ca6 authored by Ghislain Loas's avatar Ghislain Loas
Browse files

phpunit 6 compatibility

parent 92fd58c0
......@@ -5,15 +5,15 @@ require_once 'ZendL/Reflection/Class.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Class
*/
class ZendL_Reflection_ClassTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_ClassTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,64 +22,64 @@ class ZendL_Reflection_ClassTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testMethodReturns()
{
$reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass2');
$methodByName = $reflectionClass->getMethod('getProp1');
$this->assertEquals(get_class($methodByName), 'ZendL_Reflection_Method');
$methodsAll = $reflectionClass->getMethods();
$this->assertEquals(count($methodsAll), 3);
$firstMethod = array_shift($methodsAll);
$this->assertEquals($firstMethod->getName(), 'getProp1');
}
public function testPropertyReturns()
{
$reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass2');
$propertyByName = $reflectionClass->getProperty('_prop1');
$this->assertEquals(get_class($propertyByName), 'ZendL_Reflection_Property');
$propertiesAll = $reflectionClass->getProperties();
$this->assertEquals(count($propertiesAll), 2);
$firstProperty = array_shift($propertiesAll);
$this->assertEquals($firstProperty->getName(), '_prop1');
}
public function testParentReturn()
{
$reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass');
$parent = $reflectionClass->getParentClass();
$this->assertEquals(get_class($parent), 'ZendL_Reflection_Class');
$this->assertEquals($parent->getName(), 'ArrayObject');
}
public function testInterfaceReturn()
{
$reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass4');
$interfaces = $reflectionClass->getInterfaces();
$this->assertEquals(count($interfaces), 1);
$interface = array_shift($interfaces);
$this->assertEquals($interface->getName(), 'ZendL_Reflection_TestSampleClassInterface');
}
public function testStartLine()
{
$reflectionClass = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$this->assertEquals($reflectionClass->getStartLine(), 87);
$this->assertEquals($reflectionClass->getStartLine(true), 76);
}
}
\ No newline at end of file
......@@ -3,18 +3,18 @@
require_once 'ZendL/Reflection/File.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Docblock
* @group ZendL_Reflection_Docblock_Tag
* @group ZendL_Reflection_Docblock_Tag_Param
*/
class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -23,7 +23,7 @@ class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testType()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
......@@ -31,7 +31,7 @@ class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals($paramTag->getType(), 'int');
}
public function testVariableName()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
......@@ -39,6 +39,5 @@ class ZendL_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('param');
$this->assertEquals($paramTag->getVariableName(), '$one');
}
}
\ No newline at end of file
......@@ -3,17 +3,17 @@
require_once 'ZendL/Reflection/File.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Docblock
* @group ZendL_Reflection_Docblock_Tag
* @group ZendL_Reflection_Docblock_Tag_Return
*/
class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,7 +22,7 @@ class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit_Framework_TestCas
self::$_sampleClassFileRequired = true;
}
}
public function testType()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
......@@ -30,6 +30,5 @@ class ZendL_Reflection_Docblock_Tag_ReturnTest extends PHPUnit_Framework_TestCas
$paramTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals($paramTag->getType(), 'mixed');
}
}
\ No newline at end of file
......@@ -3,17 +3,17 @@
require_once 'ZendL/Reflection/File.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Docblock
* @group ZendL_Reflection_Docblock_Tag
*/
class ZendL_Reflection_Docblock_TagTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_Docblock_TagTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,7 +22,7 @@ class ZendL_Reflection_Docblock_TagTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testTagDescription()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
......@@ -30,5 +30,5 @@ class ZendL_Reflection_Docblock_TagTest extends PHPUnit_Framework_TestCase
$authorTag = $classReflection->getDocblock()->getTag('author');
$this->assertEquals($authorTag->getDescription(), 'Ralph Schindler <ralph.schindler@zend.com>');
}
}
......@@ -3,16 +3,16 @@
require_once 'ZendL/Reflection/File.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Docblock
*/
class ZendL_Reflection_DocblockTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_DocblockTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -21,18 +21,18 @@ class ZendL_Reflection_DocblockTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testDocblockShortDescription()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$this->assertEquals($classReflection->getDocblock()->getShortDescription(), 'TestSampleClass5 Docblock Short Desc');
}
public function testDocblockLongDescription()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$expectedOutput =<<<EOS
This is a long description for
This is a long description for
the docblock of this class, it
should be longer than 3 lines.
It indeed is longer than 3 lines
......@@ -42,44 +42,44 @@ EOS;
$this->assertEquals($classReflection->getDocblock()->getLongDescription(), $expectedOutput);
}
public function testDocblockTags()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$this->assertEquals(count($classReflection->getDocblock()->getTags()), 1);
$this->assertEquals(count($classReflection->getDocblock()->getTags('author')), 1);
$this->assertEquals($classReflection->getDocblock()->getTag('version'), false);
$this->assertEquals($classReflection->getMethod('doSomething')->getDocblock()->hasTag('return'), true);
$returnTag = $classReflection->getMethod('doSomething')->getDocblock()->getTag('return');
$this->assertEquals(get_class($returnTag), 'ZendL_Reflection_Docblock_Tag_Return');
$this->assertEquals($returnTag->getType(), 'mixed');
}
public function testDocblockLines()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$classDocblock = $classReflection->getDocblock();
$this->assertEquals($classDocblock->getStartLine(), 76);
$this->assertEquals($classDocblock->getEndLine(), 86);
}
public function testDocblockContents()
{
$classReflection = new ZendL_Reflection_Class('ZendL_Reflection_TestSampleClass5');
$classDocblock = $classReflection->getDocblock();
$expectedContents = <<<EOS
TestSampleClass5 Docblock Short Desc
This is a long description for
This is a long description for
the docblock of this class, it
should be longer than 3 lines.
It indeed is longer than 3 lines
......@@ -88,9 +88,9 @@ now.
@author Ralph Schindler <ralph.schindler@zend.com>
EOS;
$this->assertEquals($classDocblock->getContents(), $expectedContents);
}
}
\ No newline at end of file
......@@ -4,20 +4,20 @@ require_once 'ZendL/Reflection/Extension.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Extension
*/
class ZendL_Reflection_ExtensionTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_ExtensionTest extends PHPUnit\Framework\TestCase
{
public function testClassReturn()
{
$extension = new ZendL_Reflection_Extension('Reflection');
$extensionClasses = $extension->getClasses();
$this->assertEquals(get_class(array_shift($extensionClasses)), 'ZendL_Reflection_Class');
}
public function testFunctionReturn()
{
$extension = new ZendL_Reflection_Extension('Spl');
......@@ -25,4 +25,3 @@ class ZendL_Reflection_ExtensionTest extends PHPUnit_Framework_TestCase
$this->assertEquals(get_class(array_shift($extensionFunctions)), 'ZendL_Reflection_Function');
}
}
......@@ -5,23 +5,23 @@ require_once 'ZendL/Reflection/File.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_File
*/
class ZendL_Reflection_FileTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_FileTest extends PHPUnit\Framework\TestCase
{
public function testConstructor()
{
$reflectionFile = new ZendL_Reflection_File(__FILE__);
$this->assertEquals(get_class($reflectionFile), 'ZendL_Reflection_File');
$this->assertEquals($reflectionFile->getFileName(), __FILE__);
require_once 'Zend/Loader.php';
$reflectionFile = new ZendL_Reflection_File('Zend/Loader.php');
$this->assertEquals(get_class($reflectionFile), 'ZendL_Reflection_File');
try {
$nonExistentFile = 'Non/Existent/File.php';
$reflectionFile = new ZendL_Reflection_File($nonExistentFile);
......@@ -30,17 +30,17 @@ class ZendL_Reflection_FileTest extends PHPUnit_Framework_TestCase
$this->assertEquals($e->getMessage(), 'File ' . $nonExistentFile . ' must be required before it can be reflected.');
}
}
public function testClassReturns()
{
$fileToRequire = dirname(__FILE__) . '/_files/TestSampleClass.php';
require_once $fileToRequire;
$reflectionFile = new ZendL_Reflection_File($fileToRequire);
$this->assertEquals(get_class($reflectionFile), 'ZendL_Reflection_File');
$this->assertEquals(count($reflectionFile->getClasses()), 5);
$this->assertEquals(get_class($reflectionFile->getClass('ZendL_Reflection_TestSampleClass2')), 'ZendL_Reflection_Class');
try {
$nonExistentClass = 'Some_Non_Existent_Class';
$reflectionFile->getClass($nonExistentClass);
......@@ -48,7 +48,7 @@ class ZendL_Reflection_FileTest extends PHPUnit_Framework_TestCase
} catch (ZendL_Reflection_Exception $e) {
$this->assertEquals($e->getMessage(), 'Class by name ' . $nonExistentClass . ' not found.');
}
}
}
\ No newline at end of file
......@@ -5,15 +5,15 @@ require_once 'ZendL/Reflection/Function.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Function
*/
class ZendL_Reflection_FunctionTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_FunctionTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,7 +22,7 @@ class ZendL_Reflection_FunctionTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testParemeterReturn()
{
$function = new ZendL_Reflection_Function('array_splice');
......@@ -30,12 +30,11 @@ class ZendL_Reflection_FunctionTest extends PHPUnit_Framework_TestCase
$this->assertEquals(count($parameters), 4);
$this->assertEquals(get_class(array_shift($parameters)), 'ZendL_Reflection_Parameter');
}
public function testFunctionDocblockReturn()
{
$function = new ZendL_Reflection_Function('zend_reflection_test_sample_function6');
$this->assertEquals(get_class($function->getDocblock()), 'ZendL_Reflection_Docblock');
}
}
}
......@@ -5,15 +5,15 @@ require_once 'ZendL/Reflection/Method.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Method
*/
class ZendL_Reflection_MethodTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_MethodTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,13 +22,13 @@ class ZendL_Reflection_MethodTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testDeclaringClassReturn()
{
$method = new ZendL_Reflection_Method('ZendL_Reflection_TestSampleClass2', 'getProp1');
$this->assertEquals(get_class($method->getDeclaringClass()), 'ZendL_Reflection_Class');
}
public function testParemeterReturn()
{
$method = new ZendL_Reflection_Method('ZendL_Reflection_TestSampleClass2', 'getProp2');
......@@ -36,14 +36,13 @@ class ZendL_Reflection_MethodTest extends PHPUnit_Framework_TestCase
$this->assertEquals(count($parameters), 2);
$this->assertEquals(get_class(array_shift($parameters)), 'ZendL_Reflection_Parameter');
}
public function testStartLine()
{
$reflectionMethod = new ZendL_Reflection_Method('ZendL_Reflection_TestSampleClass5', 'doSomething');
$this->assertEquals($reflectionMethod->getStartLine(), 105);
$this->assertEquals($reflectionMethod->getStartLine(true), 89);
}
}
}
......@@ -5,15 +5,15 @@ require_once 'ZendL/Reflection/Parameter.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Parameter
*/
class ZendL_Reflection_ParameterTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_ParameterTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,24 +22,23 @@ class ZendL_Reflection_ParameterTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testDeclaringClassReturn()
{
$parameter = new ZendL_Reflection_Parameter(array('ZendL_Reflection_TestSampleClass2', 'getProp2'), 0);
$this->assertEquals(get_class($parameter->getDeclaringClass()), 'ZendL_Reflection_Class');
}
public function testClassReturn()
{
$parameter = new ZendL_Reflection_Parameter(array('ZendL_Reflection_TestSampleClass2', 'getProp2'), 'param2');
$this->assertEquals(get_class($parameter->getClass()), 'ZendL_Reflection_Class');
}
public function testTypeReturn()
{
$parameter = new ZendL_Reflection_Parameter(array('ZendL_Reflection_TestSampleClass5', 'doSomething'), 'two');
$this->assertEquals($parameter->getType(), 'int');
}
}
}
......@@ -5,15 +5,15 @@ require_once 'ZendL/Reflection/Property.php';
/**
*
*
* @group ZendL_Reflection
* @group ZendL_Reflection_Property
*/
class ZendL_Reflection_PropertyTest extends PHPUnit_Framework_TestCase
class ZendL_Reflection_PropertyTest extends PHPUnit\Framework\TestCase
{
static protected $_sampleClassFileRequired = false;
public function setup()
{
if (self::$_sampleClassFileRequired === false) {
......@@ -22,13 +22,12 @@ class ZendL_Reflection_PropertyTest extends PHPUnit_Framework_TestCase
self::$_sampleClassFileRequired = true;
}
}
public function testDeclaringClassReturn()
{
$property = new ZendL_Reflection_Property('ZendL_Reflection_TestSampleClass2', '_prop1');
$this->assertEquals(get_class($property->getDeclaringClass()), 'ZendL_Reflection_Class');
}