<commit_before><?php

namespace Continuous\Features;

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Testwork\Hook\Scope\AfterSuiteScope;
use Behat\Testwork\Hook\Scope\BeforeSuiteScope;
use Continuous\DeployAgent\Application\ApplicationManager;
use Zend\Mvc\Application;

/**
 * Defines application features from the specific context.
 */
class DeployAgentContext implements Context, SnippetAcceptingContext
{
    /**
     * @var Application
     */
    protected static $application;
    
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
    
    /**
     * @BeforeSuite
     */
    public static function setupTests(BeforeSuiteScope $scope)
    {
        copy('config/autoload/db.test.php.dist', 'config/autoload/db.test.php');
        
        if (file_exists('data/db/test.db')) {
            unlink('data/db/test.db');
        }

        $appConfig = include 'config/application.config.php';

        if (file_exists('config/development.config.php')) {
            $appConfig = \Zend\Stdlib\ArrayUtils::merge($appConfig, include 'config/development.config.php');
        }
        
        self::$application = Application::init($appConfig)->bootstrap();
    }
    
    /**
     * @AfterSuite
     */
    public static function removeDB(AfterSuiteScope $scope)
    {
        unlink('config/autoload/db.test.php');
    }
    
    /**
     * @BeforeScenario
     */
    public function provisionDB(BeforeScenarioScope $scope)
    {
        exec('./agent orm:schema-tool:create');
    }

    /**
     * @AfterScenario
     */
    public function cleanDB(AfterScenarioScope $scope)
    {
        unlink('data/db/test.db');
    }

    /**
     * @Then I should have the application
     */<commit_msg>remove application bootstrap from test<commit_after><?php

namespace Continuous\Features;

use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Behat\Hook\Scope\AfterScenarioScope;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Testwork\Hook\Scope\AfterSuiteScope;
use Behat\Testwork\Hook\Scope\BeforeSuiteScope;
use Continuous\DeployAgent\Application\ApplicationManager;
use Zend\Mvc\Application;

/**
 * Defines application features from the specific context.
 */
class DeployAgentContext implements Context, SnippetAcceptingContext
{
    /**
     * @var Application
     */
    protected static $application;
    
    /**
     * Initializes context.
     *
     * Every scenario gets its own context instance.
     * You can also pass arbitrary arguments to the
     * context constructor through behat.yml.
     */
    public function __construct()
    {
    }
    
    /**
     * @BeforeSuite
     */
    public static function setupTests(BeforeSuiteScope $scope)
    {
        copy('config/autoload/db.test.php.dist', 'config/autoload/db.test.php');
        
        if (file_exists('data/db/test.db')) {
            unlink('data/db/test.db');
        }

        $appConfig = require 'config/application.config.php';

        if (file_exists('config/development.config.php')) {
            $appConfig = \Zend\Stdlib\ArrayUtils::merge($appConfig, require 'config/development.config.php');
        }
        
        self::$application = Application::init($appConfig);
    }
    
    /**
     * @AfterSuite
     */
    public static function removeDB(AfterSuiteScope $scope)
    {
        unlink('config/autoload/db.test.php');
    }
    
    /**
     * @BeforeScenario
     */
    public function provisionDB(BeforeScenarioScope $scope)
    {
        exec('./agent orm:schema-tool:create');
    }

    /**
     * @AfterScenario
     */
    public function cleanDB(AfterScenarioScope $scope)
    {
        unlink('data/db/test.db');
    }

    /**
     * @Then I should have the application
     */
{'fraction_non_alphanumeric': 0.11854243542435425, 'fraction_numerical': 0.0, 'mean_word_length': 2.6692047377326564, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '6707356', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1286, 'n_words': 232}