<commit_before><?php
namespace Codeception\Util;

use \Symfony\Component\DomCrawler\Crawler;

/**
 * Abstract module for PHP frameworks connected via Symfony BrowserKit components
 * Each framework is connected with it's own connector defined in \Codeception\Util\Connector
 * Each module for framework should extend this class.
 *
 */

abstract class Framework extends \Codeception\Module implements FrameworkInterface
{
    /**
     * @var \Symfony\Component\DomCrawler\Crawler
     */
    protected $crawler;

    /**
     * @api
     * @var \Symfony\Component\BrowserKit\Client
     */
    public $client;

    protected $forms = array();

    public function _failed(\Codeception\TestCase $test, $fail)
    {
        if (!$this->client->getResponse()) return;
        file_put_contents(\Codeception\Configuration::logDir() . basename($test->getFileName()) . '.page.debug.html', $this->client->getResponse()->getContent());
    }

    public function _after(\Codeception\TestCase $test)
    {
        $this->client = null;
        $this->crawler = null;
        $this->forms = array();

    }

    public function amHttpAuthenticated($username, $password)
    {
        $this->client->setServerParameter('PHP_AUTH_USER', $username);
        $this->client->setServerParameter('PHP_AUTH_PW', $password);
    }

    public function amOnPage($page)
    {
        $this->crawler = $this->client->request('GET', $page);
        $this->debugResponse();
    }

    public function click($link, $context = null)
    {
        $literal = Crawler::xpathLiteral($link);

        if ($context) {
            $this->crawler = $this->match($context);
        }<commit_msg>Fix where an uninitialized client would throw error on failure.<commit_after><?php
namespace Codeception\Util;

use \Symfony\Component\DomCrawler\Crawler;

/**
 * Abstract module for PHP frameworks connected via Symfony BrowserKit components
 * Each framework is connected with it's own connector defined in \Codeception\Util\Connector
 * Each module for framework should extend this class.
 *
 */

abstract class Framework extends \Codeception\Module implements FrameworkInterface
{
    /**
     * @var \Symfony\Component\DomCrawler\Crawler
     */
    protected $crawler;

    /**
     * @api
     * @var \Symfony\Component\BrowserKit\Client
     */
    public $client;

    protected $forms = array();

    public function _failed(\Codeception\TestCase $test, $fail)
    {
        if (!$this->client || !$this->client->getResponse()) return;
        file_put_contents(\Codeception\Configuration::logDir() . basename($test->getFileName()) . '.page.debug.html', $this->client->getResponse()->getContent());
    }

    public function _after(\Codeception\TestCase $test)
    {
        $this->client = null;
        $this->crawler = null;
        $this->forms = array();

    }

    public function amHttpAuthenticated($username, $password)
    {
        $this->client->setServerParameter('PHP_AUTH_USER', $username);
        $this->client->setServerParameter('PHP_AUTH_PW', $password);
    }

    public function amOnPage($page)
    {
        $this->crawler = $this->client->request('GET', $page);
        $this->debugResponse();
    }

    public function click($link, $context = null)
    {
        $literal = Crawler::xpathLiteral($link);

        if ($context) {
            $this->crawler = $this->match($context);
        }
{'fraction_non_alphanumeric': 0.13775811209439529, 'fraction_numerical': 0.0, 'mean_word_length': 3.008274231678487, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3085173', 'n_tokens_mistral': 981, 'n_tokens_neox': 954, 'n_words': 212}