// src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
namespace Acme\DemoBundle\Tests\Controller;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class DemoControllerTest extends WebTestCase
{
public function testIndex()
{
$client = static::createClient();
$crawler = $client->request('GET', '/demo/hello/Fabien');
$this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count());
}
}
यह मेरे परीक्षणों में ठीक काम करता है, लेकिन मैं इस क्रॉलर को नियंत्रक में भी उपयोग करना चाहता हूं। मैं यह कैसे कर सकता हूं?नियंत्रक में क्रॉलर का उपयोग करें
मैं मार्ग बनाने के लिए, और नियंत्रक से जोड़ें:
<?php
// src/Ens/JobeetBundle/Controller/CategoryController
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Acme\DemoBundle\Entity\Category;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class CategoryController extends Controller
{
public function testAction()
{
$client = WebTestCase::createClient();
$crawler = $client->request('GET', '/category/index');
}
}
लेकिन यह मुझे त्रुटि:
Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /acme/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php on line 24
धन्यवाद, लेकिन इसके लिए दस्तावेज़ीकरण कहां है? उदाहरण के लिए मैं कक्षा के साथ DIV या अवधि कैसे प्राप्त कर सकता हूं? –
मैंने अधिक जानकारी के साथ अपना उत्तर अपडेट किया –
बहुत, बहुत धन्यवाद :) –