panther
panther copied to clipboard
Call to undefined method App\Tests\E2eTest::assertPageTitleContains()
Hi, I am developing a website without any framework and I want to integrate some test using panther.
Infos
My folder structure :
myproject/
├── src/
│ ├── myprojectrootfile-1.php
│ ├── ...
├── Test/
│ ├── E2eTest.php
├── vendor/
├── composer.json
├── composer.lock
├── phpunit.xml.dist
My composer.json
{
"require-dev": {
"phpunit/phpunit": "9",
"symfony/panther": "^0.7.1"
}
}
My phpunit.xml.dist :
<phpunit>
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
</extensions>
<php>
<server name="KERNEL_DIR" value="./Tests/App" />
<server name="PANTHER_WEB_SERVER_DIR" value="./src/" />
</php>
</phpunit>
My E2eTest.php :
<?php
namespace App\Tests;
use Symfony\Component\Panther\PantherTestCase;
class E2eTest extends PantherTestCase
{
public function testMyApp(): void
{
$client = static::createPantherClient(); // Your app is automatically started using the built-in web server
$client->request('GET', '/view/main.php');
// Use any PHPUnit assertion, including the ones provided by Symfony
$this->assertPageTitleContains('My Title');
$this->assertSelectorTextContains('#main', 'My body');
}
}
Problem
When I run .\vendor\bin\phpunit .\Tests\E2eTest.php I have an error :
- App\Tests\E2eTest::testMyApp Error: Call to undefined method App\Tests\E2eTest::assertPageTitleContains()
I don't understand why.
Thanks for your help