Skip to content

Commit

Permalink
update unit tests (after update composer packages). Update selenium s…
Browse files Browse the repository at this point in the history
…erver and added selenium server standalone (older version)
  • Loading branch information
yaleksandr89 committed Jul 16, 2024
1 parent 5599077 commit 4f7338f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
###> Custom Rules ###
log-execute-phpunit.txt
.phpunit.cache/
uploads/
uploads
Expand Down
6 changes: 2 additions & 4 deletions bin/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,5 @@ php bin/console doctrine:schema:update --complete --force

php bin/console hautelook:fixtures:load -n

php ./vendor/bin/phpunit --testdox --group functional-panther
# --log-events-verbose-text results.txt
# --group unit --group integration --group functional
# --group functional-selenium
php ./vendor/bin/phpunit --testdox --group unit --group integration --group functional --group functional-selenium --group functional-panther
# --log-events-verbose-text log-execute-phpunit.txt #если нужно посмотреть логи выполнения тестов (сохраняется в корень проекта)
Binary file not shown.
Binary file added bin/selenium-server-standalone-3.141.59.jar
Binary file not shown.
46 changes: 20 additions & 26 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,28 @@
bootstrap="tests/bootstrap.php"
cacheDirectory=".phpunit.cache"
>
<php>
<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="11.2.7"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<ini name="display_errors" value="1"/>
<ini name="error_reporting" value="-1"/>
<server name="APP_ENV" value="test" force="true"/>
<server name="SHELL_VERBOSITY" value="-1"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value=""/>
<server name="SYMFONY_PHPUNIT_VERSION" value="11.2.7"/>
</php>
<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<extensions>
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
</extensions>

<!-- Run `composer require symfony/panther` before enabling this extension -->
<!--
<extensions>
<extension class="Symfony\Component\Panther\ServerExtension" />
<bootstrap class="DAMA\DoctrineTestBundle\PHPUnit\PHPUnitExtension"/>
<bootstrap class="Symfony\Component\Panther\ServerExtension"/>
</extensions>
-->

<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ class AuthLoginControllerTest extends BasePantherTestCase
public function testLogin(): void
{
$client = static::createClient();

$client->request('GET', '/ru/login');
$client->submitForm('Авторизоваться', [
'email' => $this->email,
'password' => $this->password,
]);

self::assertResponseRedirects('/ru/profile', Response::HTTP_FOUND);

$client->followRedirect();
self::assertResponseIsSuccessful();
}
Expand All @@ -33,7 +31,6 @@ public function testLoginWithPantherClient(): void
{
$client = static::createPantherClient(['browser' => self::CHROME]);
$client->request('GET', '/ru/login');

$client->submitForm('Авторизоваться', [
'email' => $this->email,
'password' => $this->password,
Expand All @@ -55,7 +52,7 @@ public function testLoginWithSeleniumClient(): void
'password' => $this->password,
]);

// sleep(3);
// sleep(10); // раскомментировать, если нужно увидеть, что отображается на экране
$this->takeScreenshot($client, ' App\Tests\Functional\Controller\Front ');

self::assertSame(
Expand Down
8 changes: 5 additions & 3 deletions tests/SymfonyPanther/BasePantherTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ protected function initSeleniumClient(): Client
static::createPantherClient();
static::startWebServer();

$capabilities = $this->getChromeCapabilities();

return Client::createSeleniumClient('http://127.0.0.1:4444/wd/hub', $capabilities, 'http://127.0.0.1:9080');
return Client::createSeleniumClient(
'http://127.0.0.1:4444/wd/hub',
$this->getChromeCapabilities(),
'http://127.0.0.1:9080'
);
}

private function getChromeCapabilities(): DesiredCapabilities
Expand Down

0 comments on commit 4f7338f

Please sign in to comment.