Преглед изворни кода

Issue #110 Fixed internal classes mocks

Some php versions with some phpunit version do not allow cloning
internal classes without the construct method invocation

* ReflectionClass
* ReflectionMethod

Now we mock them with existing class and method

* Edited the mock class existing and added one simple and empty method
mmoreram пре 11 година
родитељ
комит
a87af40c97

+ 1 - 1
Tests/Module/JobClassTest.php

@@ -84,7 +84,7 @@ class JobClassTest extends PHPUnit_Framework_TestCase
     {
         $this->reflectionMethod = $this
             ->getMockBuilder('\ReflectionMethod')
-            ->disableOriginalConstructor()
+            ->setConstructorArgs(array('\Mmoreram\GearmanBundle\Tests\Service\Mocks\SingleCleanFile', 'myMethod'))
             ->setMethods(array(
                 'getName',
             ))

+ 2 - 7
Tests/Module/WorkerClassTest.php

@@ -22,7 +22,6 @@ use Mmoreram\GearmanBundle\Driver\Gearman\Work as WorkAnnotation;
  */
 class WorkerClassTest extends \PHPUnit_Framework_TestCase
 {
-
     /**
      * @var WorkAnnotation
      *
@@ -96,17 +95,16 @@ class WorkerClassTest extends \PHPUnit_Framework_TestCase
      */
     public function setUp()
     {
-
         $this->reflectionClass = $this
             ->getMockBuilder('\ReflectionClass')
-            ->disableOriginalConstructor()
+            ->setConstructorArgs(array('\Mmoreram\GearmanBundle\Tests\Service\Mocks\SingleCleanFile'))
             ->setMethods(array(
                 'getName',
                 'getNamespaceName',
                 'getFileName',
                 'getMethods',
             ))
-                            ->getMock();
+            ->getMock();
 
         $this->workAnnotation = $this
             ->getMockBuilder('\Mmoreram\GearmanBundle\Driver\Gearman\Work')
@@ -131,7 +129,6 @@ class WorkerClassTest extends \PHPUnit_Framework_TestCase
      */
     public function testWorkerAnnotationsDefined()
     {
-
         $this
             ->reflectionClass
             ->expects($this->once())
@@ -204,7 +201,6 @@ class WorkerClassTest extends \PHPUnit_Framework_TestCase
      */
     public function testWorkerAnnotationsEmpty()
     {
-
         $this
             ->reflectionClass
             ->expects($this->once())
@@ -261,7 +257,6 @@ class WorkerClassTest extends \PHPUnit_Framework_TestCase
      */
     public function testCombinationServers()
     {
-
         $this
             ->reflectionClass
             ->expects($this->once())

+ 8 - 0
Tests/Service/Mocks/SingleCleanFile.php

@@ -18,4 +18,12 @@ namespace Mmoreram\GearmanBundle\Tests\Service\Mocks;
  */
 class SingleCleanFile
 {
+    /**
+     * My method
+     *
+     *
+     */
+    public function myMethod() {
+
+    }
 }