<commit_before><?php

namespace AssetManagerTest\Service;

use PHPUnit_Framework_TestCase;
use AssetManager\Service\AssetManager;
use Zend\ServiceManager\ServiceManager;
use Zend\Http\PhpEnvironment\Request;
use Zend\Console\Request as ConsoleRequest;

class AssetManagerTest extends PHPUnit_Framework_TestCase
{
    public function testServe()
    {
        $resolver = $this->getMock('AssetManager\Resolver\ResolverInterface');
        $resolver
            ->expects($this->once())
            ->method('resolve')
            ->with('asset-path')
            ->will($this->returnValue(__FILE__));

        $assetManager = new AssetManager($resolver);
        $request = new Request();
        $request->setUri('http://localhost/base-path/asset-path');
        $request->setBasePath('/base-path');
        ob_start();
        $servedSuccess = $assetManager->serveAsset($request);
        $served = ob_get_contents();
        ob_end_clean();<commit_msg>Fixing failure related to headers being already sent (using Stdlib error handler)<commit_after><?php

namespace AssetManagerTest\Service;

use PHPUnit_Framework_TestCase;
use AssetManager\Service\AssetManager;
use Zend\ServiceManager\ServiceManager;
use Zend\Http\PhpEnvironment\Request;
use Zend\Console\Request as ConsoleRequest;
use Zend\Stdlib\ErrorHandler;

class AssetManagerTest extends PHPUnit_Framework_TestCase
{
    public function testServe()
    {
        $resolver = $this->getMock('AssetManager\Resolver\ResolverInterface');
        $resolver
            ->expects($this->once())
            ->method('resolve')
            ->with('asset-path')
            ->will($this->returnValue(__FILE__));

        $assetManager = new AssetManager($resolver);
        $request = new Request();
        $request->setUri('http://localhost/base-path/asset-path');
        $request->setBasePath('/base-path');
        ob_start();
        // need the error handler since headers will otherwise be considered as "already sent"
        ErrorHandler::start();
        $servedSuccess = $assetManager->serveAsset($request);
        ErrorHandler::stop();
        $served = ob_get_contents();
        ob_end_clean();
{'fraction_non_alphanumeric': 0.1253469010175763, 'fraction_numerical': 0.0, 'mean_word_length': 3.3433734939759034, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '2490052', 'n_tokens_mistral': 591, 'n_tokens_neox': 573, 'n_words': 113}