<commit_before><?php

/**
 * This file contains the FrontControllerGetTest class.
 *
 * PHP Version 5.4
 *
 * @category   Libraries
 * @package    Corona
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @copyright  2013, M2Mobi BV, Amsterdam, The Netherlands
 * @license    http://lunr.nl/LICENSE MIT License
 */

namespace Lunr\Corona\Tests;

/**
 * This class contains tests for getting controllers from the FrontController class.
 *
 * @category   Libraries
 * @package    Corona
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @covers     Lunr\Corona\FrontController
 */
class FrontControllerGetTest extends FrontControllerTest
{

    /**
     * Test that get_controller() returns a FQCN.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsFQCNForExistingController()
    {
        $dir    = __DIR__;
        $result = __DIR__ . '/Project/Package/FunctionController.php';
        $fqcn   = 'Project\\Package\\FunctionController';

        $this->request->expects($this->once())
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(array($result)));

        $this->response->expects($this->never())
                       ->method('__set');

        $value = $this->class->get_controller($dir);

        $this->assertEquals($fqcn, $value);
    }

    /**
     * Test that get_controller() returns an emoty string if controller not found.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringForNonExistingController()
    {
        $dir = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('controller/method'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(array()));

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('controller/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);
    }

    /**
     * Test that get_controller() returns an empty string if finding caused error.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringIfFindFailed()
    {
        $dir = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('controller/method'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(FALSE));

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('controller/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);
    }

    /**
     * Test that get_controller() returns an empty string if there is no controller info available.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringIfNoControllerInfoAvailable()
    {
        $dir    = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue(NULL));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('/method'));

        $this->fao->expects($this->never())
                  ->method('find_matches');

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);<commit_msg>Corona: Fix codestyle error.<commit_after><?php

/**
 * This file contains the FrontControllerGetTest class.
 *
 * PHP Version 5.4
 *
 * @category   Libraries
 * @package    Corona
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @copyright  2013, M2Mobi BV, Amsterdam, The Netherlands
 * @license    http://lunr.nl/LICENSE MIT License
 */

namespace Lunr\Corona\Tests;

/**
 * This class contains tests for getting controllers from the FrontController class.
 *
 * @category   Libraries
 * @package    Corona
 * @subpackage Tests
 * @author     <NAME> <<EMAIL>>
 * @covers     Lunr\Corona\FrontController
 */
class FrontControllerGetTest extends FrontControllerTest
{

    /**
     * Test that get_controller() returns a FQCN.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsFQCNForExistingController()
    {
        $dir    = __DIR__;
        $result = __DIR__ . '/Project/Package/FunctionController.php';
        $fqcn   = 'Project\\Package\\FunctionController';

        $this->request->expects($this->once())
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(array($result)));

        $this->response->expects($this->never())
                       ->method('__set');

        $value = $this->class->get_controller($dir);

        $this->assertEquals($fqcn, $value);
    }

    /**
     * Test that get_controller() returns an emoty string if controller not found.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringForNonExistingController()
    {
        $dir = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('controller/method'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(array()));

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('controller/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);
    }

    /**
     * Test that get_controller() returns an empty string if finding caused error.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringIfFindFailed()
    {
        $dir = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue('function'));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('controller/method'));

        $this->fao->expects($this->once())
                  ->method('find_matches')
                  ->with('/^.+functioncontroller.php/i', $dir)
                  ->will($this->returnValue(FALSE));

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('controller/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);
    }

    /**
     * Test that get_controller() returns an empty string if there is no controller info available.
     *
     * @covers Lunr\Corona\FrontController::get_controller
     */
    public function testGetControllerReturnsEmptyStringIfNoControllerInfoAvailable()
    {
        $dir = __DIR__;

        $this->request->expects($this->at(0))
                      ->method('__get')
                      ->with('controller')
                      ->will($this->returnValue(NULL));

        $this->request->expects($this->at(1))
                      ->method('__get')
                      ->with('call')
                      ->will($this->returnValue('/method'));

        $this->fao->expects($this->never())
                  ->method('find_matches');

        $this->response->expects($this->once())
                       ->method('set_error_message')
                       ->with($this->equalTo('/method'), $this->equalTo('Undefined controller'));

        $value = $this->class->get_controller($dir);

        $this->assertEquals('', $value);
{'fraction_non_alphanumeric': 0.15965886552955177, 'fraction_numerical': 0.002578341927806426, 'mean_word_length': 1.9626909518213866, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 237, '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': '5444048', 'n_tokens_mistral': 2758, 'n_tokens_neox': 2595, 'n_words': 424}