<commit_before><?php

/**
 * AspectPHP_ExampleTest
 *
 * @category PHP
 * @package AspectPHP_Example
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/AspectPHP
 * @since 05.04.2012
 */

/**
 * Initializes the test environment.
 */
require_once(dirname(__FILE__) . '/bootstrap.php');

/**
 * Tests the example script.
 *
 * @category PHP
 * @package AspectPHP_Example
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/AspectPHP
 * @since 05.04.2012
 */
class AspectPHP_ExampleTest extends PHPUnit_Framework_TestCase
{
    
    /**
     * Ensures that the example outputs the line that is echoed
     * by the Demo class.
     */
    public function testExampleOutputsLineFromDemoClass()
    {
        $output = $this->callExampleScript();
        $this->assertContains('Hello Matthias!', $output);
    }
    
    /**
     * Calls the example script and returns its output.
     *
     * @return string
     */
    protected function callExampleScript()
    {
        $outputLines = array();
        $return      = null;
        $path        = dirname(__FILE__) . '/../../example/Example.php';
        $path        = realpath($path);
        
        exec('php ' . escapeshellarg($path), $outputLines, $return);
        
        $output  = implode(PHP_EOL, $outputLines);
        $message = 'Script did not terminate successfully: ' . PHP_EOL . $output;
        $this->assertEquals(0, $return, $message);
        return $output;
    }
    
}<commit_msg>added tests for example script<commit_after><?php

/**
 * AspectPHP_ExampleTest
 *
 * @category PHP
 * @package AspectPHP_Example
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/AspectPHP
 * @since 05.04.2012
 */

/**
 * Initializes the test environment.
 */
require_once(dirname(__FILE__) . '/bootstrap.php');

/**
 * Tests the example script.
 *
 * @category PHP
 * @package AspectPHP_Example
 * @subpackage Tests
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/AspectPHP
 * @since 05.04.2012
 */
class AspectPHP_ExampleTest extends PHPUnit_Framework_TestCase
{
    
    /**
     * Ensures that the example script outputs the line that is echoed
     * by the Demo class.
     */
    public function testExampleOutputsLineFromDemoClass()
    {
        $output = $this->callExampleScript();
        $this->assertContains('Hello Matthias!', $output);
    }
    
    /**
     * Checks if the example script outputs the line that is echoed
     * by the before advice.
     */
    public function testExampleOutputsLineFromBeforeAdvice()
    {
        $output = $this->callExampleScript();
        $this->assertContains('before sayHello', $output);
    }
    
    /**
     * Checks if the example script outputs the line that is echoed
     * by the after advice.
     */
    public function testExampleOutputsLineFromAfterAdvice()
    {
        $output = $this->callExampleScript();
        $this->assertContains('after sayHello', $output);
    }
    
    /**
     * Calls the example script and returns its output.
     *
     * @return string
     */
    protected function callExampleScript()
    {
        $outputLines = array();
        $return      = null;
        $path        = dirname(__FILE__) . '/../../example/Example.php';
        $path        = realpath($path);
        
        exec('php ' . escapeshellarg($path), $outputLines, $return);
        
        $output  = implode(PHP_EOL, $outputLines);
        $message = 'Script did not terminate successfully: ' . PHP_EOL . $output;
        $this->assertEquals(0, $return, $message);
        return $output;
    }
    
}
{'fraction_non_alphanumeric': 0.1313403577554521, 'fraction_numerical': 0.013232050967900024, 'mean_word_length': 2.599647266313933, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 29, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '2204374', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1206, 'n_words': 291}