2016-03-31 28 views
1

In Here benim benim phpunit.xml dosyasıPHPUnit ve Symfony2'nin

<?xml version="1.0" encoding="UTF-8"?> 

<!-- http://phpunit.de/manual/4.1/en/appendixes.configuration.html --> 
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd" 
     backupGlobals="false" 
     backupStaticAttributes="false" 
     processIsolation="false" 
     colors="true" 
     stopOnFailure="false" 
     syntaxCheck="false" 
     bootstrap="bootstrap.php.cache" 
     convertErrorsToExceptions="true" 
     convertNoticesToExceptions="true" 
     convertWarningsToExceptions="true" 
> 
    <testsuites> 
     <testsuite name="Project Test Suite"> 
      <directory>../src/*/*Bundle/Tests</directory> 
      <directory>../src/*/Bundle/*Bundle/Tests</directory> 
      <directory>../src/*Bundle/Tests</directory> 
     </testsuite> 
    </testsuites> 

    <php> 
     <server name="KERNEL_DIR" value="./" /> 
     <var name="DB_DSN" value="mysql:dbname=test_xxx;host=localhost" /> 
     <var name="DB_USER" value="root" /> 
     <var name="DB_PASSWD" value="" /> 
     <var name="DB_DBNAME" value="test_xxx" /> 
    </php> 


    <logging> 
     <log type="coverage-html" target="build/coverage" title="App Code Coverage" charset="UTF-8" yui="true" highlight="true" 
     lowUpperBound="35" highLowerBound="70"/> 
     <log type="coverage-clover" target="build/logs/clover.xml"/> 
     <log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/> 
    </logging> 

    <filter> 
     <whitelist> 
      <directory>../src</directory> 
      <exclude> 
       <directory>../src/*Bundle/Resources</directory> 
       <directory>../src/*Bundle/Tests</directory> 
       <directory>../src/*/*Bundle/Resources</directory> 
       <directory>../src/*/*Bundle/Tests</directory> 
       <directory>../src/*/Bundle/*Bundle/Resources</directory> 
       <directory>../src/*/Bundle/*Bundle/Tests</directory> 
      </exclude> 
     </whitelist> 
    </filter> 
</phpunit> 

küresel değişkenleri erişilemiyor:

  • src
    • AppBundle
      • Testler
        • AbstractDatabaseTestCase.php

AbstractDatabaseTestCase.php:

Sana belgeleri takip gerçeği göz önüne alındığında, yorumlardan görebileceğiniz gibi
abstract class AbstractDatabaseTestCase extends \PHPUnit_Extensions_Database_TestCase{ 

    /** 
    * 
    *@var PDO 
    * 
    */ 
    static $pdo; 

    /** 
    * 
    *@var \Doctrine\DBAL\Connection description 
    * 
    */ 
    static $dbal; 

    private $conn; 

    final public function getConnection() 
    { 
     var_dump($GLOBALS); 
// here my GLOBALS['DB_DSN'], GLOBALS['DB_USER'], GLOBALS['DB_PASSWD'] are not seen. 

     if ($this->conn === null) { 
      if (self::$pdo == null) { 
       self::$pdo = new \PDO($GLOBALS['DB_DSN'], $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWD']); 
      } 
      $this->conn = $this->createDefaultDBConnection(self::$pdo, $GLOBALS['DB_DBNAME']); 
     } 

     return $this->conn; 
    } 

, benim sınıf phpunit.xml dosyasında tanımlanan globals'ı görmüyor.

Herhangi bir fikrin var mı? Bir şey mi özledim?

Teşekkür ederiz!

+0

$ _SERVER'i kontrol ettiniz mi? –

+0

@RenatoMendesFigueiredo Bütün cevaplar için aynısını yaptı, şimdi bana aşağıdaki cevaba yol açtı, teşekkürler! – Gabriel

cevap

0

Symfony2'de, varsayılan phpunit.xml, app/phpunit.xml dosyasındaki değil, uygulamanın kök dizinidir. Tüm değerleri buraya koy ve her şey iyi çalıştı.