<commit_before><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Tests\Controller;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public static function setUpBeforeClass(): void
    {
        $kernel = static::bootKernel();
        /** @var EntityManager $doctrine */
        $em = $kernel->getContainer()->get('doctrine.orm.entity_manager');
        /** @var Connection $connection */
        $connection = $em->getConnection();
        try {
            $connection->exec('SELECT 1 FROM flash');
        } catch (\Exception $e) {
            system('php ' . __DIR__ . '/../../app/console doctrine:database:create -q -n');
        }
        system('php ' . __DIR__ . '/../../app/console doctrine:schema:update --force -q -n');
    }

    public function testAvailabilityHomepage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Veranstaltung', $crawler->filter('#page-body h1')->text()
        );
    }

    public function testAvailabilityLegalPage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/legal');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Datenschutzerklärung', $crawler->filter('#page-body h1')
                                            ->text()
        );
    }

    public function testAvailabilityimprintPage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/imprint');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Impressum', $crawler->filter('#page-body h1')->text()
        );
    }
    
    public function testSitemapPage(): void
    {
        $client = static::createClient();
        $client->request('GET', '/sitemap.xml');
        
        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );<commit_msg>Ensuring kernel is shutdown before each test, using crawler with arguments<commit_after><?php
/**
 * This file is part of the Juvem package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Tests\Controller;

use Doctrine\DBAL\Driver\Connection;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class DefaultControllerTest extends WebTestCase
{
    public static function setUpBeforeClass(): void
    {
        static::bootKernel();
        /** @var EntityManager $doctrine */
        $em = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
        /** @var Connection $connection */
        $connection = $em->getConnection();
        try {
            $connection->exec('SELECT 1 FROM flash');
        } catch (\Exception $e) {
            system('php ' . __DIR__ . '/../../app/console doctrine:database:create -q -n');
        } finally {
            static::ensureKernelShutdown();
        }
        system('php ' . __DIR__ . '/../../app/console doctrine:schema:update --force -q -n');
    }
    
    public function tearDown(): void
    {
        static::ensureKernelShutdown();
    }
    
    public function testAvailabilityHomepage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Veranstaltung', $crawler->filter('#page-body h1')->text(null, true)
        );
    }

    public function testAvailabilityLegalPage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/legal');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Datenschutzerklärung', $crawler->filter('#page-body h1')
                                            ->text(null, true)
        );
    }

    public function testAvailabilityimprintPage()
    {
        $client = static::createClient();

        $crawler = $client->request('GET', '/imprint');

        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
        $this->assertStringContainsString(
            'Impressum', $crawler->filter('#page-body h1')->text(null, true)
        );
    }
    
    public function testSitemapPage(): void
    {
        $client = static::createClient();
        $client->request('GET', '/sitemap.xml');
        
        $this->assertEquals(
            200, $client->getResponse()->getStatusCode()
        );
{'fraction_non_alphanumeric': 0.14957020057306591, 'fraction_numerical': 0.006112702960840497, 'mean_word_length': 2.2930817610062895, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1875894', 'n_tokens_mistral': 1432, 'n_tokens_neox': 1400, 'n_words': 293}