<commit_before><?php

class DinklyBaseTest extends PHPUnit_Framework_TestCase
{
	protected function setUp()
	{
		date_default_timezone_set("Europe/Paris");
		
		$this->valid_config = 
			array(
				"settings" => array(
					"dinkly_version" => Dinkly::getConfigValue('dinkly_version', 'global')
				),
				"apps" => array(
					"admin" => array(
						"default_app" => true,
						"default_module" => "home",
						"base_href" => "/",
						"app_name" => "Dinkly Admin Dev",
						"app_description" => "Just a humble little PHP MVC Framework",
						"copyright" => "Dinkly"
					),
					"api" => array(
						"base_href" => "/api", 
						"default_module" => "api",
						"app_name" => "Dinkly API"
					)
				)
			);

		$this->valid_modules = array("home","login","user");
		$context=null;
		$this->valid_context = 
			array('current_app_name' => 'admin', 'module' => 'home', 'view' => 'default', 'parameters'=>array('id'=>1));
	}

	public function testRoute()
	{
		// $this->base= new DinklyBase();
		// $this->base->route("/home/default/id/1");
		// //$example_uri = "/home/default/id/1";
		// //$this->context =$this->base->getContext($example_uri);
		// error_log("hello");
	}

	public function testLoadError()
	{
		$this->base= new DinklyBase();
		//make sure nothing is being returned
		$this->assertEmpty($this->base->loadError("admin","home"));
	}
	public function testGetContext()
	{
		$this->base= new DinklyBase();
		$example_uri = "/home/default/id/1";
		$this->context =$this->base->getContext($example_uri);
		$test_context= $this->valid_context;
		//test to make sure context is formatted correctly against example context
		$this->assertEquals($test_context['current_app_name'],$this->context['current_app_name']);
		$this->assertEquals($test_context['module'],$this->context['module']);
		$this->assertEquals($test_context['view'],$this->context['view']);
		$this->assertEquals($test_context['parameters']['id'],$this->context['parameters']['id']);

	}

	public function testLoadModule()
	{

	}

	public function testCurrentView()
	{

	}

	public function testCurrentModule()
	{

	}

	public function testGetParameters()
	{
		
	}

	public function testGetDefaultApp()
	{
		//Test setting config values and getting default<commit_msg>more dinklybase test functions<commit_after><?php

class DinklyBaseTest extends PHPUnit_Framework_TestCase
{
	protected function setUp()
	{
		date_default_timezone_set("Europe/Paris");
		
		$this->valid_config = 
			array(
				"settings" => array(
					"dinkly_version" => Dinkly::getConfigValue('dinkly_version', 'global')
				),
				"apps" => array(
					"admin" => array(
						"default_app" => true,
						"default_module" => "home",
						"base_href" => "/",
						"app_name" => "Dinkly Admin Dev",
						"app_description" => "Just a humble little PHP MVC Framework",
						"copyright" => "Dinkly"
					),
					"api" => array(
						"base_href" => "/api", 
						"default_module" => "api",
						"app_name" => "Dinkly API"
					)
				)
			);

		$this->valid_modules = array("home","login","user");
		$context=null;
		$this->valid_context = 
			array('current_app_name' => 'admin', 'module' => 'home', 'view' => 'default', 'parameters'=>array('id'=>1));
	}

	public function testRoute()
	{
		// $this->base= new DinklyBase();
		// $this->base->route("/home/default/id/1");
		// //$example_uri = "/home/default/id/1";
		// //$this->context =$this->base->getContext($example_uri);
		// error_log("hello");
	}

	public function testLoadError()
	{
		$this->base= new DinklyBase();
		//make sure nothing is being returned
		$this->assertEmpty($this->base->loadError("admin","home"));
	}
	public function testGetContext()
	{
		$this->base= new DinklyBase();
		$example_uri = "/home/default/id/1";
		$this->context =$this->base->getContext($example_uri);
		$test_context= $this->valid_context;
		//test to make sure context is formatted correctly against example context
		$this->assertEquals($test_context['current_app_name'],$this->context['current_app_name']);
		$this->assertEquals($test_context['module'],$this->context['module']);
		$this->assertEquals($test_context['view'],$this->context['view']);
		$this->assertEquals($test_context['parameters']['id'],$this->context['parameters']['id']);

	}

	public function testLoadModule()
	{

	}

	public function testGetCurrentView()
	{
			$this->base= new DinklyBase();
			$_SERVER['REQUEST_URI']="/home/default/id/1";
			//make sure current view is set correctly based on URI
			$this->assertEquals($this->base->getCurrentView(),'default');
	}

	public function testGetCurrentModule()
	{
			$this->base= new DinklyBase();
			$_SERVER['REQUEST_URI']="/home/default/id/1";
			//make sure current module is set correctly based on URI
			$this->assertEquals($this->base->getCurrentModule(),'home');
	}

	public function testGetParameters()
	{
	  $this->base= new DinklyBase();
		$example_uri = "/home/default/id/200";
		$this->context =$this->base->getContext($example_uri);
		$parameters=$this->base->getParameters();
		//test stored parameters agains sample context that is set
		$this->assertEquals($parameters['id'],200);
		
		
	}

	public function testGetDefaultApp()
	{
		//Test setting config values and getting default
{'fraction_non_alphanumeric': 0.1863270777479893, 'fraction_numerical': 0.003063960168517809, 'mean_word_length': 4.181547619047619, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 108, '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': '665249', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1687, 'n_words': 316}