<commit_before><?php

use Artax\Injection\ReflectionPool,
    Artax\Injection\Provider,
    Artax\Events\Notifier,
    Artax\Framework\Routing\ObservableResourceFactory,
    Artax\Framework\Routing\ClassResourceMapper,
    Artax\Framework\Routing\BadResourceClassException,
    Artax\Framework\Routing\BadResourceMethodException;

class ClassResourceMapperTest extends PHPUnit_Framework_TestCase {

    /**
     * @covers Artax\Framework\Routing\ClassResourceMapper::__construct
     */
    public function testBeginsEmpty() {
        $reflCacher = new ReflectionPool;
        $injector = new Provider($reflCacher);
        $mediator = new Notifier($injector);
        $resFactory = new ObservableResourceFactory($mediator);
        $resMapper = new ClassResourceMapper($injector, $reflCacher, $resFactory);
        
        return $resMapper;
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @covers Artax\Framework\Routing\ClassResourceMapper::provisionResource
     * @expectedException Artax\Framework\Routing\BadResourceClassException
     */
    public function testMakeThrowsExceptionOnResourceClassLoadFailure($resMapper) {
        $resMapper->make('NonexistentResourceClass', 'get', array());
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @expectedException Artax\Framework\Routing\BadResourceMethodException
     */
    public function testMakeThrowsExceptionOnBadResourceMethodVerb($resMapper) {
        $resMapper->make('WidgetController', 'post', array());
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @covers Artax\Framework\Routing\ClassResourceMapper::provisionResource
     * @covers Artax\Framework\Routing\ClassResourceMapper::mergeMethodArgs
     */
    public function testMakeReturnsNewResourceInstance($resMapper) {
        $resource = $resMapper->make('WidgetController2', 'get', array('arg1'=>1));
        $this->assertInstanceOf('Artax\\Framework\\Routing\\ObservableResource', $resource);
    }
}

class WidgetController {
    public function get(){}
}
class WidgetController2 {
    public function get($arg1, TypehintDep $arg2, $arg3, $arg4 = 42){}
}
class TypehintDep {}<commit_msg>Updated test stub to achieve 100% coverage<commit_after><?php

use Artax\Injection\ReflectionPool,
    Artax\Injection\Provider,
    Artax\Events\Notifier,
    Artax\Framework\Routing\ObservableResourceFactory,
    Artax\Framework\Routing\ClassResourceMapper,
    Artax\Framework\Routing\BadResourceClassException,
    Artax\Framework\Routing\BadResourceMethodException;

class ClassResourceMapperTest extends PHPUnit_Framework_TestCase {

    /**
     * @covers Artax\Framework\Routing\ClassResourceMapper::__construct
     */
    public function testBeginsEmpty() {
        $reflCacher = new ReflectionPool;
        $injector = new Provider($reflCacher);
        $mediator = new Notifier($injector);
        $resFactory = new ObservableResourceFactory($mediator);
        $resMapper = new ClassResourceMapper($injector, $reflCacher, $resFactory);
        
        return $resMapper;
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @covers Artax\Framework\Routing\ClassResourceMapper::provisionResource
     * @expectedException Artax\Framework\Routing\BadResourceClassException
     */
    public function testMakeThrowsExceptionOnResourceClassLoadFailure($resMapper) {
        $resMapper->make('NonexistentResourceClass', 'get', array());
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @expectedException Artax\Framework\Routing\BadResourceMethodException
     */
    public function testMakeThrowsExceptionOnBadResourceMethodVerb($resMapper) {
        $resMapper->make('WidgetController', 'post', array());
    }
    
    /**
     * @depends testBeginsEmpty
     * @covers Artax\Framework\Routing\ClassResourceMapper::make
     * @covers Artax\Framework\Routing\ClassResourceMapper::provisionResource
     * @covers Artax\Framework\Routing\ClassResourceMapper::mergeMethodArgs
     */
    public function testMakeReturnsNewResourceInstance($resMapper) {
        $resource = $resMapper->make('WidgetController2', 'get', array('arg1'=>1));
        $this->assertInstanceOf('Artax\\Framework\\Routing\\ObservableResource', $resource);
    }
}

class WidgetController {
    public function __construct(){}
    public function get(){}
}
class WidgetController2 {
    public function get($arg1, TypehintDep $arg2, $arg3, $arg4 = 42){}
}
class TypehintDep {}
{'fraction_non_alphanumeric': 0.10853530031612224, 'fraction_numerical': 0.004847207586933615, 'mean_word_length': 3.985294117647059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, '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': '2271942', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1341, 'n_words': 203}