Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Symfony][SF2][SF]problem z testami w symfony
Forum PHP.pl > Forum > PHP > Frameworki
symer
Witam . Instaluje od nowa paczkę symfony 3.3 . Wpisuje w cmd phpunit tests\AppBundle\Controller\DefaultContr
ollerTest.php i pokazuje mi komunikat : No test executed . Co robię źle?
kallosz
musisz najpierw napisać test.
symer
Mam napisany test w tym DefaultControllerTest.php
404
Pokaż tą klasę. Sprawdź też wersję PHPUnita.
symer
To jest klasa testowa co już była wbudowana w Symfony. No ale ok :
  1. namespace Tests\AppBundle\Controller;
  2.  
  3. class DefaultControllerTest
  4. {
  5. public function testIndex()
  6. {
  7. $client = static::createClient();
  8.  
  9. $crawler = $client->request('GET', '/eppend');
  10.  
  11. $this->assertEquals(200, $client->getResponse()->getStatusCode());
  12. $this->assertContains('Welcome to Symfonye', $crawler->filter('#container h1')->text());
  13. }
  14. }


A phpunit.xml
  1. <?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!-- <a href="https://phpunit.de/manual/current/en/appendixes.configuration.html" target="_blank">https://phpunit.de/manual/current/en/append...figuration.html</a> -->
  4. <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
  6. backupGlobals="false"
  7. colors="true"
  8. bootstrap="vendor/autoload.php"
  9. >
  10. <php>
  11. <ini name="error_reporting" value="-1" />
  12. <server name="KERNEL_CLASS" value="AppKernel" />
  13. </php>
  14.  
  15. <testsuites>
  16. <testsuite name="Project Test Suite">
  17. <directory>tests</directory>
  18. </testsuite>
  19. </testsuites>
  20.  
  21. <filter>
  22. <whitelist>
  23. <directory>src</directory>
  24. <exclude>
  25. <directory>src/*Bundle/Resources</directory>
  26. <directory>src/*/*Bundle/Resources</directory>
  27. <directory>src/*/Bundle/*Bundle/Resources</directory>
  28. </exclude>
  29. </whitelist>
  30. </filter>
  31. </phpunit>


Gdy dodam/edytuję klasę z tymi wierszami:
  1. use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
  2.  
  3. class DefaultControllerTest extends WebTestCase


To znów pokaże mi się komunikat :

C:\xampp\htdocs\heroku\mototest3>phpunit tests\AppBundle\Controller\DefaultContr
ollerTest.php
PHP Fatal error: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdoc
s\heroku\mototest3\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Tes
t\KernelTestCase.php on line 25

Fatal error: Class 'PHPUnit\Framework\TestCase' not found in C:\xampp\htdocs\her
oku\mototest3\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Test\Ker
nelTestCase.php on line 25

I za cholerę nie mogę tego naprawić. Może wersja phpunit nie ta. Mam wersje symfony 3.3
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.