<commit_before><?php
/**
 * Unit Test for the Route Listener Event
 *
 * This file contains the unit test for Route Listener Event
 *
 * PHP version 5.3
 *
 * LICENSE: BSD
 *
 * @category  Reliv
 * @package   Rcm
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 Reliv International
 * @license   License.txt New BSD License
 * @version   GIT: <git_id>
 * @link      http://github.com/reliv
 */

namespace RcmTest\EventListener;

require_once __DIR__ . '/../../../autoload.php';

use Rcm\Entity\Domain;
use Rcm\Entity\Redirect;
use Rcm\Entity\Site;
use Rcm\EventListener\RouteListener;
use Zend\Http\PhpEnvironment\Request;
use Zend\Http\Response;
use Zend\Mvc\MvcEvent;
use Zend\Stdlib\Parameters;

/**
 * Unit Test for Route Listener Event
 *
 * Unit Test for Route Listener Event
 *
 * @category  Reliv
 * @package   Rcm
 * @author    <NAME> <<EMAIL>>
 * @copyright 2012 Reliv International
 * @license   License.txt New BSD License
 * @version   Release: 1.0
 * @link      http://github.com/reliv
 */
class RouteListenerTest extends \PHPUnit_Framework_TestCase
{

    /** @var \Rcm\EventListener\RouteListener */
    protected $routeListener;

    protected $domains;

    protected $redirects;

    protected $redirectRepo;

    /** @var \Rcm\Entity\Site */
    protected $currentSite;

    /**
     * Setup for tests
     *
     * @return void
     */
    public function setup()
    {
        $this->domains = [
            'reliv.com' => [
                'domain' => 'local.reliv.com',
                'primaryDomain' => null,
                'languageId' => 'eng',
                'siteId' => 1,
                'countryId' => 'USA',
            ],
            'www.reliv.com' => [
                'domain' => 'local.reliv.com',
                'primaryDomain' => 'reliv.com',
                'languageId' => 'eng',
                'siteId' => 1,
                'countryId' => 'USA',
            ],
        ];

        $this->redirects = [
            '/requestOne' => [
                'requestUrl' => '/requestOne',
                'redirectUrl' => 'reliv.com/redirectOne',
            ],
            '/requestTwo' => [
                'requestUrl' => '/requestTwo',
                'redirectUrl' => 'reliv.com/redirectTwo',
            ],
        ];

        $config = [];

        $this->currentSite = new Site();
        $this->currentSite->setSiteId(1);
        $this->currentSite->setStatus('A');

        $domain = new Domain();
        $domain->setDomainId(1);
        $domain->setDomainName('reliv.com');

        $this->currentSite->setDomain($domain);

        $this->redirectRepo = $this
            ->getMockBuilder('\Rcm\Repository\Redirect')
            ->disableOriginalConstructor()
            ->getMock();

        $map = [];

        foreach ($this->redirects as $key => $redirect) {
            $redirectEntity = new Redirect();
            $redirectEntity->setRedirectUrl($redirect['requestUrl']);
            $redirectEntity->setRedirectUrl($redirect['redirectUrl']);

            $map[] = [$key, $this->currentSite->getSiteId(), $redirectEntity];
        }

        $this->redirectRepo->expects($this->any())
            ->method('getRedirect')
            ->will($this->returnValueMap($map));

        $this->routeListener = new RouteListener(
            $this->currentSite,
            $this->redirectRepo,
            $config
        );
    }

    /**
     * Test Check Domain
     *
     * @return void
     *
     * @covers \Rcm\EventListener\RouteListener<commit_msg>Fix test<commit_after><?php
/**
 * Unit Test for the Route Listener Event
 *
 * This file contains the unit test for Route Listener Event
 *
 * PHP version 5.3
 *
 * LICENSE: BSD
 *
 * @category  Reliv
 * @package   Rcm
 * @author    <NAME> <<EMAIL>>
 * @copyright 2014 Reliv International
 * @license   License.txt New BSD License
 * @version   GIT: <git_id>
 * @link      http://github.com/reliv
 */

namespace RcmTest\EventListener;

require_once __DIR__ . '/../../../autoload.php';

use Rcm\Entity\Domain;
use Rcm\Entity\Redirect;
use Rcm\Entity\Site;
use Rcm\EventListener\RouteListener;
use Zend\Http\PhpEnvironment\Request;
use Zend\Http\Response;
use Zend\Mvc\MvcEvent;
use Zend\Stdlib\Parameters;

/**
 * Unit Test for Route Listener Event
 *
 * Unit Test for Route Listener Event
 *
 * @category  Reliv
 * @package   Rcm
 * @author    <NAME> <<EMAIL>>
 * @copyright 2012 Reliv International
 * @license   License.txt New BSD License
 * @version   Release: 1.0
 * @link      http://github.com/reliv
 */
class RouteListenerTest extends \PHPUnit_Framework_TestCase
{

    /** @var \Rcm\EventListener\RouteListener */
    protected $routeListener;

    protected $domains;

    protected $redirects;

    protected $redirectRepo;

    /** @var \Rcm\Entity\Site */
    protected $currentSite;

    /**
     * Setup for tests
     *
     * @return void
     */
    public function setup()
    {
        $this->domains = [
            'reliv.com' => [
                'domain' => 'local.reliv.com',
                'primaryDomain' => null,
                'languageId' => 'eng',
                'siteId' => 1,
                'countryId' => 'USA',
            ],
            'www.reliv.com' => [
                'domain' => 'local.reliv.com',
                'primaryDomain' => 'reliv.com',
                'languageId' => 'eng',
                'siteId' => 1,
                'countryId' => 'USA',
            ],
        ];

        $this->redirects = [
            '/requestOne' => [
                'requestUrl' => '/requestOne',
                'redirectUrl' => 'reliv.com/redirectOne',
            ],
            '/requestTwo' => [
                'requestUrl' => '/requestTwo',
                'redirectUrl' => 'reliv.com/redirectTwo',
            ],
        ];

        $config = [];

        $this->currentSite = new Site();
        $this->currentSite->setSiteId(1);
        $this->currentSite->setStatus('A');

        $domain = new Domain();
        $domain->setDomainId(1);
        $domain->setDomainName('reliv.com');

        $this->currentSite->setDomain($domain);

        $this->redirectRepo = $this
            ->getMockBuilder('\Rcm\Repository\Redirect')
            ->disableOriginalConstructor()
            ->getMock();

        $map = [];

        foreach ($this->redirects as $key => $redirect) {
            $redirectEntity = new Redirect();
            $redirectEntity->setRedirectUrl($redirect['requestUrl']);
            $redirectEntity->setRedirectUrl($redirect['redirectUrl']);

            $map[] = [$key, $this->currentSite->getSiteId(), $redirectEntity];
        }

        $this->redirectRepo->expects($this->any())
            ->method('getRedirect')
            ->will($this->returnValueMap($map));

        $this->routeListener = new RouteListener(
            $this->currentSite,
            $this->redirectRepo,
            new \Zend\Validator\Ip(),
            $config
        );
    }

    /**
     * Test Check Domain
     *
     * @return void
     *
     * @covers \Rcm\EventListener\RouteListener
{'fraction_non_alphanumeric': 0.14887282007656316, 'fraction_numerical': 0.004537076421380973, 'mean_word_length': 1.9136720363486164, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7384583', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2010, 'n_words': 414}