<commit_before><?php

/*
 * <NAME> (http://muriloamaral.com)
 * Édipo Rebouças (http://edipo.com.br).
 *
 * @link https://github.com/muriloacs/Middleware
 *
 * @copyright Copyright (c) 2015 <NAME>
 * @license The MIT License (MIT)
 *
 * @since File available since Release 1.0
 */

namespace MiddlewareTest\Service\Factory;

use Middleware\Service\Factory\MiddlewareRunnerServiceFactory;
use Zend\ServiceManager\ServiceManager;

class MiddlewareRunnerServiceFactoryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var MiddlewareRunnerServiceFactory
     */
    private $factory;

    protected function setUp()
    {
        parent::setUp();
        $this->factory = new MiddlewareRunnerServiceFactory();
    }

    public function testFactoryShouldCreateMiddlewareService()
    {
        $serviceManager = $this->createServiceManagerMock();
        $actual = $this->factory->createService($serviceManager);
        $this->assertInstanceOf('Middleware\Service\MiddlewareRunnerService', $actual);
    }

    /**
     * @return ServiceManager|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createServiceManagerMock()
    {
        $serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager', array('get'));
        $serviceManager->expects($this->at(0))
            ->method('get')
            ->willReturn($this->createRequestStub());

        $serviceManager->expects($this->at(1))
            ->method('get')
            ->willReturn($this->createResponseStub());

        return $serviceManager;
    }

    /**
     * @return \Zend\Http\PhpEnvironment\Request|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createRequestStub()
    {
        $request = $this->getMock('Zend\Http\PhpEnvironment\Request');

        return $request;
    }

    /**
     * @return \Zend\Http\PhpEnvironment\Response|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createResponseStub()
    {
        $request = $this->getMock('Zend\Http\PhpEnvironment\Response');

        return $request;
    }


    public function testMiddlewareFactory()
    {
        $serviceManager = $this->createServiceManagerMock();
        $runner = $this->factory->createService($serviceManager);
        $serviceManager->expects($this->at(0))->method('get')->with('test1')->willReturn(function(){});
        $runner->run(array('test1'));
    }


}<commit_msg>reformated, add @covers<commit_after><?php

/*
 * <NAME> (http://muriloamaral.com)
 * Édipo Rebouças (http://edipo.com.br).
 *
 * @link https://github.com/muriloacs/Middleware
 *
 * @copyright Copyright (c) 2015 <NAME>
 * @license The MIT License (MIT)
 *
 * @since File available since Release 1.0
 */

namespace MiddlewareTest\Service\Factory;

use Middleware\Service\Factory\MiddlewareRunnerServiceFactory;

class MiddlewareRunnerServiceFactoryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var MiddlewareRunnerServiceFactory
     */
    private $factory;

    protected function setUp()
    {
        parent::setUp();
        $this->factory = new MiddlewareRunnerServiceFactory();
    }

    public function testFactoryShouldCreateMiddlewareService()
    {
        $serviceManager = $this->createServiceManagerMock();
        $actual = $this->factory->createService($serviceManager);
        $this->assertInstanceOf('Middleware\Service\MiddlewareRunnerService', $actual);
    }

    /**
     * @return \Zend\ServiceManager\ServiceManager|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createServiceManagerMock()
    {
        $serviceManager = $this->getMock('Zend\ServiceManager\ServiceManager', array('get'));
        $serviceManager->expects($this->at(0))
            ->method('get')
            ->willReturn($this->createRequestStub());

        $serviceManager->expects($this->at(1))
            ->method('get')
            ->willReturn($this->createResponseStub());

        return $serviceManager;
    }

    /**
     * @return \Zend\Http\PhpEnvironment\Request|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createRequestStub()
    {
        $request = $this->getMock('Zend\Http\PhpEnvironment\Request');

        return $request;
    }

    /**
     * @return \Zend\Http\PhpEnvironment\Response|\PHPUnit_Framework_MockObject_MockObject|
     */
    private function createResponseStub()
    {
        $request = $this->getMock('Zend\Http\PhpEnvironment\Response');

        return $request;
    }


    /**
     * @covers MiddlewareRunnerServiceFactory::createMiddlewareFactory
     */
    public function testMiddlewareFactory()
    {
        $serviceManager = $this->createServiceManagerMock();
        $runner = $this->factory->createService($serviceManager);

        $serviceManager->expects($this->at(0))
            ->method('get')
            ->with('test1')
            ->willReturn(function(){});

        $runner->run(array('test1'));
    }


}
{'fraction_non_alphanumeric': 0.13955843629734657, 'fraction_numerical': 0.004456147457970428, 'mean_word_length': 3.1426174496644297, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 61, 'https://': 2, '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': '3875128', 'n_tokens_mistral': 1403, 'n_tokens_neox': 1381, 'n_words': 199}