A bug of using class autoloader for selenium browser test #631

Closed
TriAnMan opened this Issue Sep 2, 2012 · 0 comments

Comments

Projects
None yet
2 participants
Contributor

TriAnMan commented Sep 2, 2012

I've found that PHPUnit 3.6.12 throws an php warning while executing a selenium test suite with multiple configured browsers (in xml or in test class). You can see a lot of people facing this issue: http://www.yiiframework.com/forum/index.php/topic/30511-firefoxphp-faild-to-include-in-yiibase/
To replicate a bug you have to install Yii framework 1.1.12, create a webapp with yiic, configure (change TEST_BASE_URL in WebTestCase.php) and launch tests in protected/tests folder.

I've made a patch fixing this problem, so could you apply it in the next release of PHPUnit.

From 6967a195ce5407504d9c592bbdd4c9419daf4050 Mon Sep 17 00:00:00 2001
From: Anton Andersen
Date: Mon, 3 Sep 2012 01:46:44 +0400
Subject: [PATCH] fixed autoloading of classes

---
 PHPUnit/Framework/TestSuite.php | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PHPUnit/Framework/TestSuite.php b/PHPUnit/Framework/TestSuite.php
index 7477af5..af6b195 100644
--- a/PHPUnit/Framework/TestSuite.php
+++ b/PHPUnit/Framework/TestSuite.php
@@ -651,6 +651,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE
                 $this->setUp();

                 if ($this->testCase &&
+                    class_exists($this->name, false) &&
                     method_exists($this->name, 'setUpBeforeClass')) {
                     call_user_func(array($this->name, 'setUpBeforeClass'));
                 }
@@ -749,6 +750,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE

         if ($doSetup) {
             if ($this->testCase &&
+                class_exists($this->name, false) &&
                 method_exists($this->name, 'tearDownAfterClass')) {
                 call_user_func(array($this->name, 'tearDownAfterClass'));
             }
-- 
1.7.11.msysgit.0

@TriAnMan TriAnMan added a commit to TriAnMan/phpunit that referenced this issue Sep 4, 2012

@TriAnMan TriAnMan Prevent initiation of user's class autoloader on selenium tests 1084280

edorian closed this Sep 7, 2012

@greglamb greglamb pushed a commit to greglamb/phpunit that referenced this issue Apr 19, 2013

@TriAnMan TriAnMan Prevent initiation of user's class autoloader on selenium tests ca655ca

@greglamb greglamb pushed a commit to greglamb/phpunit that referenced this issue Apr 19, 2013

@edorian edorian Explainatory comment for the fix for #631 and ChangeLog entry. 3bc7600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment