Forráskód Böngészése

merged branch dbu/doc-webtestcase (PR #2565)

Commits
-------

957690c fixing WebTastCase when kernel is not found and improving exception message

Discussion
----------

fixing WebTastCase when kernel is not found and improving exception message

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -

this time against 2.0 and with the link to the symfony book. replaces #2418

(i hope you merge 2.0 into master as well?)

---------------------------------------------------------------------------

by meonkeys at 2011/11/04 10:37:43 -0700

Why is this closed? (I was expecting to see it merged to 2.0)

---------------------------------------------------------------------------

by dbu at 2011/11/04 10:45:05 -0700

this request is not closed, only the referenced  #2418
github could work a bit on the layout though, looks confusing...

---------------------------------------------------------------------------

by meonkeys at 2011/11/04 10:46:56 -0700

Whoops, yep. And I should have read that more closely.
Fabien Potencier 13 éve
szülő
commit
cd7fa4277d

+ 4 - 3
src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php

@@ -116,11 +116,12 @@ abstract class WebTestCase extends \PHPUnit_Framework_TestCase
 
         $finder = new Finder();
         $finder->name('*Kernel.php')->depth(0)->in($dir);
-        if (!count($finder)) {
-            throw new \RuntimeException('You must override the WebTestCase::createKernel() method.');
+        $results = iterator_to_array($finder);
+        if (!count($results)) {
+            throw new \RuntimeException('Either set KERNEL_DIR in your phpunit.xml according to http://symfony.com/doc/current/book/testing.html#your-first-functional-test or override the WebTestCase::createKernel() method.');
         }
 
-        $file = current(iterator_to_array($finder));
+        $file = current($results);
         $class = $file->getBasename('.php');
 
         require_once $file;