<commit_before><?php

use Anvil\Routing\Inspector;

class InspectorTest extends PHPUnit_Framework_TestCase {

	public function testHomePage()
	{
		$inspector = $this->getInspector('/', null);
		$this->assertTrue($inspector->isHome());

		$inspector = $this->getInspector('/', 'FooController');
		$this->assertTrue($inspector->isHome());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('/', $inspector->detectRoute());

		$inspector = $this->getInspector('test', 'FooController');
		$this->assertFalse($inspector->isHome());
		$this->assertEquals('TestController', $inspector->detectController());
		$this->assertEquals('test', $inspector->detectRoute());

		$inspector = $this->getInspector('foo', 'FooController');
		$this->assertTrue($inspector->isHome());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('foo', $inspector->detectRoute());

		$inspector = $this->getInspector('foo', 'BarController');
		$this->assertFalse($inspector->isHome());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('foo', $inspector->detectRoute());
	}

	public function testHomePageFailsWithExtraUriSegments()
	{
		$inspector = $this->getInspector('foo', 'FooController');
		$this->assertTrue($inspector->isHome());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('foo', $inspector->detectRoute());

		$inspector = $this->getInspector('foo/bar', 'FooController');
		$this->assertFalse($inspector->isHome());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('foo', $inspector->detectRoute());
	}

	public function testAdminRoutes()
	{
		$inspector = $this->getInspector('/', 'FooController');
		$this->assertFalse($inspector->isAdmin());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('/', $inspector->detectRoute());

		$inspector = $this->getInspector('foo/bar', null);
		$this->assertFalse($inspector->isAdmin());
		$this->assertEquals('FooController', $inspector->detectController());
		$this->assertEquals('foo', $inspector->detectRoute());

		$inspector = $this->getInspector('admin', null);
		$this->assertTrue($inspector->isAdmin());
		$this->assertEquals(Inspector::ADMIN_HOME_CONTROLLER, $inspector->detectController());
		$this->assertEquals('admin', $inspector->detectRoute());

		$inspector = $this->getInspector('admin', 'FooController');
		$this->assertTrue($inspector->isAdmin());
		$this->assertEquals(Inspector::ADMIN_HOME_CONTROLLER, $inspector->detectController());
		$this->assertEquals('admin', $inspector->detectRoute());

		$inspector = $this->getInspector('admin/foo', null);
		$this->assertTrue($inspector->isAdmin());
		$this->assertEquals('FooAdminController', $inspector->detectController());
		$this->assertEquals('admin/foo', $inspector->detectRoute());

		$inspector = $this->getInspector('admin/foo', 'FooController');
		$this->assertTrue($inspector->isAdmin());
		$this->assertEquals('FooAdminController', $inspector->detectController());
		$this->assertEquals('admin/foo', $inspector->detectRoute());

		$inspector = $this->getInspector('admin/foo/bar', 'FooController');
		$this->assertTrue($inspector->isAdmin());
		$this->assertEquals('FooAdminController', $inspector->detectController());
		$this->assertEquals('admin/foo', $inspector->detectRoute());
	}

	public function getInspector($uri, $defaultController)
	{
		return new Inspector($uri, $defaultController);
	}
}<commit_msg>Added test for admin inspector.<commit_after><?php

use Illuminate\Http\Request;
use Anvil\Routing\Inspector\AdminInspector;
use Anvil\Routing\Inspector\DefaultInspector;
use Anvil\Routing\Inspector\Route;

class InspectorTest extends PHPUnit_Framework_TestCase {

	public function testAdminInspector()
	{
		$inspector = new AdminInspector;

		$route = new Route(Request::create('/'));
		$this->assertEquals(null, $inspector->inspect($route));

		$route = new Route(Request::create('foo'));
		$this->assertEquals(null, $inspector->inspect($route));

		$route = new Route(Request::create('admin'));
		$route = $inspector->inspect($route);
		$this->assertEquals(true, $route->isAdmin);
		$this->assertEquals('admin', $route->route);
		$this->assertEquals('Anvil\Controllers\AdminController', $route->controller);

		$route = new Route(Request::create('admin/foo'));
		$route = $inspector->inspect($route);
		$this->assertEquals(true, $route->isAdmin);
		$this->assertEquals('admin/foo', $route->route);
		$this->assertEquals('FooAdminController', $route->controller);

		$route = new Route(Request::create('admin/foo/bar'));
		$route = $inspector->inspect($route);
		$this->assertEquals(true, $route->isAdmin);
		$this->assertEquals('admin/foo', $route->route);
		$this->assertEquals('FooAdminController', $route->controller);
	}

	public function testDefaultInspector()
	{

	}
}
{'fraction_non_alphanumeric': 0.20048455481526348, 'fraction_numerical': 0.0, 'mean_word_length': 7.410865874363328, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 122, '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': '2216550', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1459, 'n_words': 201}