<commit_before><?php

Bundle::start('orchestra');

class RoutingInstallerTest extends Orchestra\Testable\TestCase {
	
	/**
	 * Setup the test environment.
	 */
	public function setUp()
	{
		parent::setUp();

		$this->removeApplication();

		Session::load();

		$base_path =  Bundle::path('orchestra').'tests'.DS.'fixtures'.DS;
		set_path('app', $base_path.'application'.DS);
	}

	/**
	 * Teardown the test environment.
	 */
	public function tearDown()
	{
		set_path('app', path('base').'application'.DS);
		parent::tearDown();
	}

	/**
	 * Test Request GET (orchestra)/installer/index failed
	 *
	 * @test
	 */
	public function testGetInstallerPageFailed()
	{
		$driver    = Config::get('database.default', 'mysql');
		$database  = Config::get("database.connections.{$driver}", array());
		$auth      = Config::get('auth');
		$dummyauth = array_merge($auth, array('model' => 'DummyRoutingInstallerAuthStub'));

		Config::set('database.default', 'dummy-mysql');
		Config::set("database.connections.dummy-mysql", array(
			'driver'   => 'mysql',
			'host'     => '127.0.0.1',
			'database' => Str::random(10),
			'username' => Str::random(10),
			'password' => Str::random(10),
			'charset'  => 'utf8',
			'prefix'   => '',
		));
		Config::set('auth', $dummyauth);

		$response = $this->call('orchestra::installer@index', array());

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.index', $response->content->view);

		$this->assertFalse(Orchestra\Installer::check_database());

		Config::set('database.default', $driver);
		Config::set("database.connections.{$driver}", $database);
		Config::set('auth', $auth);
	}

	/**
	 * Test Request GET (orchestra)/installer/index successful
	 *
	 * @test
	 */
	public function testGetInstallerPageSuccessful()
	{
		$response = $this->call('orchestra::installer@index', array());

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.index', $response->content->view);

		$response = $this->call('orchestra::installer@steps', array(1));

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.step1', $response->content->view);

		$response = $this->call('orchestra::installer@steps', array(2), 'POST', array(
			'site_name' => 'Orchestra Test Suite',
			'email'     => '<EMAIL>',
			'password'  => '<PASSWORD>',
			'fullname'  => 'Test Administrator',
		));

		$this->assertInstanceOf('Laravel\Redirect', $response);
		$this->assertEquals(302, $response->foundation->getStatusCode());
		$this->assertEquals(handles('orchestra::installer/steps/1'), 
			$response->foundation->headers->get('location'));

		$response = $this->call('orchestra::installer@steps', array(2), 'POST', array(
			'site_name' => 'Orchestra Test Suite',
			'email'     => '<EMAIL>',
			'password'  => '<PASSWORD>',
			'fullname'  => 'Test Administrator',
		));

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.step2', $response->content->view);
	}
}

class DummyRoutingInstallerAuthStub extends Eloquent {}<commit_msg>Flush Auth and DB connection.<commit_after><?php

Bundle::start('orchestra');

class RoutingInstallerTest extends Orchestra\Testable\TestCase {
	
	/**
	 * Setup the test environment.
	 */
	public function setUp()
	{
		parent::setUp();

		$this->removeApplication();

		Session::load();

		$base_path =  Bundle::path('orchestra').'tests'.DS.'fixtures'.DS;
		set_path('app', $base_path.'application'.DS);
	}

	/**
	 * Teardown the test environment.
	 */
	public function tearDown()
	{
		set_path('app', path('base').'application'.DS);
		parent::tearDown();
	}

	/**
	 * Test Request GET (orchestra)/installer/index failed
	 *
	 * @test
	 */
	public function testGetInstallerPageFailed()
	{
		$driver    = Config::get('database.default', 'mysql');
		$database  = Config::get("database.connections.{$driver}", array());
		$auth      = Config::get('auth');
		$dummyauth = array_merge($auth, array('model' => 'DummyRoutingInstallerAuthStub'));

		Auth::$drivers   = null;
		DB::$connections = array();

		Config::set('database.default', 'dummy-mysql');
		Config::set("database.connections.dummy-mysql", array(
			'driver'   => 'mysql',
			'host'     => '127.0.0.1',
			'database' => Str::random(10),
			'username' => Str::random(10),
			'password' => Str::<PASSWORD>(10),
			'charset'  => 'utf8',
			'prefix'   => '',
		));
		Config::set('auth', $dummyauth);

		$response = $this->call('orchestra::installer@index', array());

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.index', $response->content->view);

		$this->assertFalse(Orchestra\Installer::check_database());

		Auth::$drivers   = null;
		DB::$connections = array();

		Config::set('database.default', $driver);
		Config::set("database.connections.{$driver}", $database);
		Config::set('auth', $auth);
	}

	/**
	 * Test Request GET (orchestra)/installer/index successful
	 *
	 * @test
	 */
	public function testGetInstallerPageSuccessful()
	{
		$response = $this->call('orchestra::installer@index', array());

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.index', $response->content->view);

		$response = $this->call('orchestra::installer@steps', array(1));

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.step1', $response->content->view);

		$response = $this->call('orchestra::installer@steps', array(2), 'POST', array(
			'site_name' => 'Orchestra Test Suite',
			'email'     => '<EMAIL>',
			'password'  => '<PASSWORD>',
			'fullname'  => 'Test Administrator',
		));

		$this->assertInstanceOf('Laravel\Redirect', $response);
		$this->assertEquals(302, $response->foundation->getStatusCode());
		$this->assertEquals(handles('orchestra::installer/steps/1'), 
			$response->foundation->headers->get('location'));

		$response = $this->call('orchestra::installer@steps', array(2), 'POST', array(
			'site_name' => 'Orchestra Test Suite',
			'email'     => '<EMAIL>',
			'password'  => '<PASSWORD>',
			'fullname'  => 'Test Administrator',
		));

		$this->assertInstanceOf('Laravel\Response', $response);
		$this->assertEquals(200, $response->foundation->getStatusCode());
		$this->assertEquals('orchestra::installer.step2', $response->content->view);
	}
}

class DummyRoutingInstallerAuthStub extends Eloquent {}
{'fraction_non_alphanumeric': 0.20601785200115175, 'fraction_numerical': 0.009789807083213361, 'mean_word_length': 5.30399274047187, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 130, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1664819', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2217, 'n_words': 334}