+
+
+
+
+
Server Error: 404 (Not Found)
+
+
What does this mean?
+
+
+ We couldn't find the page you requested on our servers. We're really sorry
+ about that. It's our fault, not yours. We'll work hard to get this page
+ back online as soon as possible.
+
+
+
+ Perhaps you would like to go to our ?
+
+
+
+
\ No newline at end of file
diff --git a/tests/application/views/error/500.php b/tests/application/views/error/500.php
new file mode 100644
index 00000000..4dcd92ad
--- /dev/null
+++ b/tests/application/views/error/500.php
@@ -0,0 +1,103 @@
+
+
+
+
+
+
+
+
+
Server Error: 500 (Internal Server Error)
+
+
What does this mean?
+
+
+ Something went wrong on our servers while we were processing your request.
+ We're really sorry about this, and will work hard to get this resolved as
+ soon as possible.
+
+
+
+ Perhaps you would like to go to our ?
+
+
+
+
\ No newline at end of file
diff --git a/tests/application/views/home/index.php b/tests/application/views/home/index.php
new file mode 100644
index 00000000..39497146
--- /dev/null
+++ b/tests/application/views/home/index.php
@@ -0,0 +1,122 @@
+
+
+
+
+
Welcome To Laravel
+
+
A Framework For Web Artisans
+
+
+ You have successfully installed the Laravel framework. Laravel is a simple framework
+ that helps web artisans create beautiful, creative applications using elegant, expressive
+ syntax. You'll love using it.
+
+
+
Learn the terrain.
+
+
+ You've landed yourself on our default home page. The route that
+ is generating this page lives at:
+
+
+
APP_PATH/routes.php
+
+
And the view sitting before you can be found at:
+
+
APP_PATH/views/home/index.php
+
+
Create something beautiful.
+
+
+ Now that you're up and running, it's time to start creating!
+ Here are some links to help you get started:
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/application/views/tests/basic.php b/tests/application/views/tests/basic.php
new file mode 100644
index 00000000..c961dc2f
--- /dev/null
+++ b/tests/application/views/tests/basic.php
@@ -0,0 +1 @@
+ is
\ No newline at end of file
diff --git a/tests/application/views/tests/nested.php b/tests/application/views/tests/nested.php
new file mode 100644
index 00000000..9ce498e5
--- /dev/null
+++ b/tests/application/views/tests/nested.php
@@ -0,0 +1 @@
+Taylor
\ No newline at end of file
diff --git a/tests/bundles/.gitignore b/tests/bundles/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/tests/bundles/dashboard/config/meta.php b/tests/bundles/dashboard/config/meta.php
new file mode 100644
index 00000000..a82d1703
--- /dev/null
+++ b/tests/bundles/dashboard/config/meta.php
@@ -0,0 +1,7 @@
+ 'dashboard',
+
+);
\ No newline at end of file
diff --git a/tests/bundles/dashboard/controllers/panel.php b/tests/bundles/dashboard/controllers/panel.php
new file mode 100644
index 00000000..b532296d
--- /dev/null
+++ b/tests/bundles/dashboard/controllers/panel.php
@@ -0,0 +1,10 @@
+ 'dashboard', function()
+{
+ //
+}));
+
+Route::controller('dashboard::panel');
\ No newline at end of file
diff --git a/tests/bundles/dummy/routes.php b/tests/bundles/dummy/routes.php
new file mode 100644
index 00000000..2117e2e0
--- /dev/null
+++ b/tests/bundles/dummy/routes.php
@@ -0,0 +1,6 @@
+assertTrue($container === Asset::container('foo'));
+ $this->assertInstanceOf('\\Laravel\\Asset_Container', $container);
+ }
+
+ /**
+ * Test the Asset::container method for default container creation.
+ *
+ * @group laravel
+ */
+ public function testDefaultContainerCreatedByDefault()
+ {
+ $this->assertEquals('default', Asset::container()->name);
+ }
+
+ /**
+ * Test the Asset::__callStatic method.
+ *
+ * @group laravel
+ */
+ public function testContainerMethodsCanBeDynamicallyCalled()
+ {
+ Asset::style('common', 'common.css');
+
+ $this->assertEquals('common.css', Asset::container()->assets['style']['common']['source']);
+ }
+
+ /**
+ * Test the Asset_Container constructor.
+ *
+ * @group laravel
+ */
+ public function testNameIsSetOnAssetContainerConstruction()
+ {
+ $container = $this->getContainer();
+
+ $this->assertEquals('foo', $container->name);
+ }
+
+ /**
+ * Test the Asset_Container::add method.
+ *
+ * @group laravel
+ */
+ public function testAddMethodProperlySniffsAssetType()
+ {
+ $container = $this->getContainer();
+
+ $container->add('jquery', 'jquery.js');
+ $container->add('common', 'common.css');
+
+ $this->assertEquals('jquery.js', $container->assets['script']['jquery']['source']);
+ $this->assertEquals('common.css', $container->assets['style']['common']['source']);
+ }
+
+ /**
+ * Test the Asset_Container::style method.
+ *
+ * @group laravel
+ */
+ public function testStyleMethodProperlyRegistersAnAsset()
+ {
+ $container = $this->getContainer();
+
+ $container->style('common', 'common.css');
+
+ $this->assertEquals('common.css', $container->assets['style']['common']['source']);
+ }
+
+ /**
+ * Test the Asset_Container::style method sets media attribute.
+ *
+ * @group laravel
+ */
+ public function testStyleMethodProperlySetsMediaAttributeIfNotSet()
+ {
+ $container = $this->getContainer();
+
+ $container->style('common', 'common.css');
+
+ $this->assertEquals('all', $container->assets['style']['common']['attributes']['media']);
+ }
+
+ /**
+ * Test the Asset_Container::style method sets media attribute.
+ *
+ * @group laravel
+ */
+ public function testStyleMethodProperlyIgnoresMediaAttributeIfSet()
+ {
+ $container = $this->getContainer();
+
+ $container->style('common', 'common.css', array(), array('media' => 'print'));
+
+ $this->assertEquals('print', $container->assets['style']['common']['attributes']['media']);
+ }
+
+ /**
+ * Test the Asset_Container::script method.
+ *
+ * @group laravel
+ */
+ public function testScriptMethodProperlyRegistersAnAsset()
+ {
+ $container = $this->getContainer();
+
+ $container->script('jquery', 'jquery.js');
+
+ $this->assertEquals('jquery.js', $container->assets['script']['jquery']['source']);
+ }
+
+ /**
+ * Test the Asset_Container::add method properly sets dependencies.
+ *
+ * @group laravel
+ */
+ public function testAddMethodProperlySetsDependencies()
+ {
+ $container = $this->getContainer();
+
+ $container->add('common', 'common.css', 'jquery');
+ $container->add('jquery', 'jquery.js', array('jquery-ui'));
+
+ $this->assertEquals(array('jquery'), $container->assets['style']['common']['dependencies']);
+ $this->assertEquals(array('jquery-ui'), $container->assets['script']['jquery']['dependencies']);
+ }
+
+ /**
+ * Test the Asset_Container::add method properly sets attributes.
+ *
+ * @group laravel
+ */
+ public function testAddMethodProperlySetsAttributes()
+ {
+ $container = $this->getContainer();
+
+ $container->add('common', 'common.css', array(), array('media' => 'print'));
+ $container->add('jquery', 'jquery.js', array(), array('defer'));
+
+ $this->assertEquals(array('media' => 'print'), $container->assets['style']['common']['attributes']);
+ $this->assertEquals(array('defer'), $container->assets['script']['jquery']['attributes']);
+ }
+
+ /**
+ * Test the Asset_Container::bundle method.
+ *
+ * @group laravel
+ */
+ public function testBundleMethodCorrectlySetsTheAssetBundle()
+ {
+ $container = $this->getContainer();
+
+ $container->bundle('eloquent');
+
+ $this->assertEquals('eloquent', $container->bundle);
+ }
+
+ /**
+ * Test the Asset_Container::path method.
+ *
+ * @group laravel
+ */
+ public function testPathMethodReturnsCorrectPathForABundleAsset()
+ {
+ Config::set('application.url', 'http://localhost');
+
+ $container = $this->getContainer();
+
+ $container->bundle('eloquent');
+
+ $this->assertEquals('http://localhost/bundles/eloquent/foo.jpg', $container->path('foo.jpg'));
+ }
+
+ /**
+ * Test the Asset_Container::path method.
+ *
+ * @group laravel
+ */
+ public function testPathMethodReturnsCorrectPathForAnApplicationAsset()
+ {
+ Config::set('application.url', 'http://localhost');
+
+ $container = $this->getContainer();
+
+ $this->assertEquals('http://localhost/foo.jpg', $container->path('foo.jpg'));
+ }
+
+ /**
+ * Test the Asset_Container::scripts method.
+ *
+ * @group laravel
+ */
+ public function testScriptsCanBeRetrieved()
+ {
+ $container = $this->getContainer();
+
+ $container->script('dojo', 'dojo.js', array('jquery-ui'));
+ $container->script('jquery', 'jquery.js', array('jquery-ui', 'dojo'));
+ $container->script('jquery-ui', 'jquery-ui.js');
+
+ $scripts = $container->scripts();
+
+ $this->assertTrue(strpos($scripts, 'jquery.js') > 0);
+ $this->assertTrue(strpos($scripts, 'jquery.js') > strpos($scripts, 'jquery-ui.js'));
+ $this->assertTrue(strpos($scripts, 'dojo.js') > strpos($scripts, 'jquery-ui.js'));
+ }
+
+ /**
+ * Test the Asset_Container::styles method.
+ *
+ * @group laravel
+ */
+ public function testStylesCanBeRetrieved()
+ {
+ $container = $this->getContainer();
+
+ $container->style('dojo', 'dojo.css', array('jquery-ui'), array('media' => 'print'));
+ $container->style('jquery', 'jquery.css', array('jquery-ui', 'dojo'));
+ $container->style('jquery-ui', 'jquery-ui.css');
+
+ $styles = $container->styles();
+
+ $this->assertTrue(strpos($styles, 'jquery.css') > 0);
+ $this->assertTrue(strpos($styles, 'media="print"') > 0);
+ $this->assertTrue(strpos($styles, 'jquery.css') > strpos($styles, 'jquery-ui.css'));
+ $this->assertTrue(strpos($styles, 'dojo.css') > strpos($styles, 'jquery-ui.css'));
+ }
+
+ /**
+ * Get an asset container instance.
+ *
+ * @param string $name
+ * @return Asset_Container
+ */
+ private function getContainer($name = 'foo')
+ {
+ return new Laravel\Asset_Container($name);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/auth.test.php b/tests/cases/auth.test.php
new file mode 100644
index 00000000..dd9b6e3e
--- /dev/null
+++ b/tests/cases/auth.test.php
@@ -0,0 +1,259 @@
+assertEquals('Taylor', Auth::user());
+ }
+
+ /**
+ * Test the Auth::check method.
+ *
+ * @group laravel
+ */
+ public function testCheckMethodReturnsTrueWhenUserIsSet()
+ {
+ $this->assertTrue(AuthUserReturnsDummy::check());
+ }
+
+ /**
+ * Test the Auth::check method.
+ *
+ * @group laravel
+ */
+ public function testCheckMethodReturnsFalseWhenNoUserIsSet()
+ {
+ $this->assertFalse(AuthUserReturnsNull::check());
+ }
+
+ /**
+ * Test the Auth::guest method.
+ *
+ * @group laravel
+ */
+ public function testGuestReturnsTrueWhenNoUserIsSet()
+ {
+ $this->assertTrue(AuthUserReturnsNull::guest());
+ }
+
+ /**
+ * Test the Auth::guest method.
+ *
+ * @group laravel
+ */
+ public function testGuestReturnsFalseWhenUserIsSet()
+ {
+ $this->assertFalse(AuthUserReturnsDummy::guest());
+ }
+
+ /**
+ * Test the Auth::user method.
+ *
+ * @group laravel
+ */
+ public function testUserMethodReturnsNullWhenNoUserExistsAndNoRecallerExists()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+
+ $this->assertNull(Auth::user());
+ }
+
+ /**
+ * Test the Auth::user method.
+ *
+ * @group laravel
+ */
+ public function testUserReturnsUserByID()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+ Session::$instance->session['data'][Auth::user_key] = 1;
+
+ $this->assertEquals('Taylor Otwell', Auth::user()->name);
+ }
+
+ /**
+ * Test the Auth::user method.
+ *
+ * @group laravel
+ */
+ public function testNullReturnedWhenUserIDNotValidInteger()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+ Session::$instance->session['data'][Auth::user_key] = 'asdlkasd';
+
+ $this->assertNull(Auth::user());
+ }
+
+ /**
+ * Test the Auth::recall method.
+ *
+ * @group laravel
+ */
+ public function testUserCanBeRecalledViaCookie()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+
+ $cookie = Crypter::encrypt('1|'.Str::random(40));
+ Cookie::forever(Config::get('auth.cookie'), $cookie);
+
+ $this->assertEquals('Taylor Otwell', AuthLoginStub::user()->name);
+ $this->assertTrue(AuthLoginStub::user() === $_SERVER['auth.login.stub']['user']);
+ }
+
+ /**
+ * Test the Auth::attempt method.
+ *
+ * @group laravel
+ */
+ public function testAttemptMethodReturnsFalseWhenCredentialsAreInvalid()
+ {
+ $this->assertFalse(Auth::attempt('foo', 'foo'));
+ $this->assertFalse(Auth::attempt('foo', null));
+ $this->assertFalse(Auth::attempt(null, null));
+ $this->assertFalse(Auth::attempt('taylor', 'password'));
+ $this->assertFalse(Auth::attempt('taylor', 232));
+ }
+
+ /**
+ * Test the Auth::attempt method.
+ *
+ * @group laravel
+ */
+ public function testAttemptReturnsTrueWhenCredentialsAreCorrect()
+ {
+ $this->assertTrue(AuthLoginStub::attempt('taylor', 'password1'));
+ $this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
+ $this->assertFalse($_SERVER['auth.login.stub']['remember']);
+
+ $this->assertTrue(AuthLoginStub::attempt('taylor', 'password1', true));
+ $this->assertEquals('Taylor Otwell', $_SERVER['auth.login.stub']['user']->name);
+ $this->assertTrue($_SERVER['auth.login.stub']['remember']);
+ }
+
+ /**
+ * Test Auth::login method.
+ *
+ * @group laravel
+ */
+ public function testLoginMethodStoresUserKeyInSession()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+
+ $user = new StdClass;
+ $user->id = 10;
+ Auth::login($user);
+ $this->assertEquals(10, Session::$instance->session['data'][Auth::user_key]);
+
+ Auth::login(5);
+ $this->assertEquals(5, Session::$instance->session['data'][Auth::user_key]);
+ }
+
+ /**
+ * Test the Auth::login method.
+ *
+ * @group laravel
+ */
+ public function testLoginStoresRememberCookieWhenNeeded()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+
+ // Set the session vars to make sure remember cookie uses them
+ Config::set('session.path', 'foo');
+ Config::set('session.domain', 'bar');
+ Config::set('session.secure', true);
+
+ Auth::login(10, true);
+ $this->assertTrue(isset(Cookie::$jar[Config::get('auth.cookie')]));
+
+ $cookie = Cookie::$jar[Config::get('auth.cookie')]['value'];
+ $cookie = explode('|', Crypter::decrypt($cookie));
+ $this->assertEquals(10, $cookie[0]);
+ $this->assertEquals('foo', Cookie::$jar[Config::get('auth.cookie')]['path']);
+ $this->assertEquals('bar', Cookie::$jar[Config::get('auth.cookie')]['domain']);
+ $this->assertTrue(Cookie::$jar[Config::get('auth.cookie')]['secure']);
+ }
+
+ /**
+ * Test the Auth::logout method.
+ *
+ * @group laravel
+ */
+ public function testLogoutMethodLogsOutUser()
+ {
+ Session::$instance = new Payload($this->getMock('Laravel\\Session\\Drivers\\Driver'));
+ Session::$instance->session['data'][Auth::user_key] = 10;
+
+ Config::set('auth.logout', function($user) { $_SERVER['auth.logout.stub'] = $user; });
+
+ Auth::$user = 'Taylor';
+ Auth::logout();
+
+ $this->assertEquals('Taylor', $_SERVER['auth.logout.stub']);
+ $this->assertNull(Auth::$user);
+ $this->assertFalse(isset(Session::$instance->session['data'][Auth::user_key]));
+ $this->assertTrue(Cookie::$jar[Config::get('auth.cookie')]['minutes'] < 0);
+ }
+
+}
+
+class AuthUserReturnsNull extends Laravel\Auth {
+
+ public static function user() {}
+
+}
+
+class AuthUserReturnsDummy extends Laravel\Auth {
+
+ public static function user() { return 'Taylor'; }
+
+}
+
+class AuthLoginStub extends Laravel\Auth {
+
+ public static function login($user, $remember = false)
+ {
+ $_SERVER['auth.login.stub'] = compact('user', 'remember');
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/autoloader.test.php b/tests/cases/autoloader.test.php
new file mode 100644
index 00000000..80605447
--- /dev/null
+++ b/tests/cases/autoloader.test.php
@@ -0,0 +1,102 @@
+ path('app').'models/foo.php',
+ ));
+
+ $this->assertEquals(path('app').'models/foo.php', Autoloader::$mappings['Foo']);
+ }
+
+ /**
+ * Test the Autoloader::alias method.
+ *
+ * @group laravel
+ */
+ public function testAliasesCanBeRegistered()
+ {
+ Autoloader::alias('Foo\\Bar', 'Foo');
+
+ $this->assertEquals('Foo\\Bar', Autoloader::$aliases['Foo']);
+ }
+
+ /**
+ * Test the Autoloader::directories method.
+ *
+ * @group laravel
+ */
+ public function testPsrDirectoriesCanBeRegistered()
+ {
+ Autoloader::directories(array(
+ path('app').'foo'.DS.'bar',
+ path('app').'foo'.DS.'baz'.DS.DS,
+ ));
+
+ $this->assertTrue(in_array(path('app').'foo'.DS.'bar'.DS, Autoloader::$directories));
+ $this->assertTrue(in_array(path('app').'foo'.DS.'baz'.DS, Autoloader::$directories));
+ }
+
+ /**
+ * Test the Autoloader::namespaces method.
+ *
+ * @group laravel
+ */
+ public function testNamespacesCanBeRegistered()
+ {
+ Autoloader::namespaces(array(
+ 'Autoloader_1' => path('bundle').'autoload'.DS.'models',
+ 'Autoloader_2' => path('bundle').'autoload'.DS.'libraries'.DS.DS,
+ ));
+
+ $this->assertEquals(path('bundle').'autoload'.DS.'models'.DS, Autoloader::$namespaces['Autoloader_1\\']);
+ $this->assertEquals(path('bundle').'autoload'.DS.'libraries'.DS, Autoloader::$namespaces['Autoloader_2\\']);
+ }
+
+ /**
+ * Test the loading of PSR-0 models and libraries.
+ *
+ * @group laravel
+ */
+ public function testPsrLibrariesAndModelsCanBeLoaded()
+ {
+ $this->assertInstanceOf('User', new User);
+ $this->assertInstanceOf('Repositories\\User', new Repositories\User);
+ }
+
+ /**
+ * Test the loading of hard-coded classes.
+ *
+ * @group laravel
+ */
+ public function testHardcodedClassesCanBeLoaded()
+ {
+ Autoloader::map(array(
+ 'Autoloader_HardCoded' => path('app').'models'.DS.'autoloader.php',
+ ));
+
+ $this->assertInstanceOf('Autoloader_HardCoded', new Autoloader_HardCoded);
+ }
+
+ /**
+ * Test the loading of classes mapped by namespaces.
+ *
+ * @group laravel
+ */
+ public function testClassesMappedByNamespaceCanBeLoaded()
+ {
+ Autoloader::namespaces(array(
+ 'Dashboard' => path('bundle').'dashboard'.DS.'models',
+ ));
+
+ $this->assertInstanceOf('Dashboard\\Repository', new Dashboard\Repository);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/blade.test.php b/tests/cases/blade.test.php
new file mode 100644
index 00000000..70e80b3b
--- /dev/null
+++ b/tests/cases/blade.test.php
@@ -0,0 +1,63 @@
+assertEquals('', Blade::compile_string($blade1));
+ $this->assertEquals('', Blade::compile_string($blade2));
+ }
+
+ /**
+ * Test the compilation of control structures.
+ *
+ * @group laravel
+ */
+ public function testControlStructuresAreCreatedCorrectly()
+ {
+ $blade1 = "@if (true)\nfoo\n@endif";
+ $blade2 = "@if (count(".'$something'.") > 0)\nfoo\n@endif";
+ $blade3 = "@if (true)\nfoo\n@elseif (false)\nbar\n@endif";
+ $blade4 = "@if (true)\nfoo\n@else\nbar\n@endif";
+
+ $this->assertEquals("\nfoo\n", Blade::compile_string($blade1));
+ $this->assertEquals(" 0): ?>\nfoo\n", Blade::compile_string($blade2));
+ $this->assertEquals("\nfoo\n\nbar\n", Blade::compile_string($blade3));
+ $this->assertEquals("\nfoo\n\nbar\n", Blade::compile_string($blade4));
+ }
+
+ /**
+ * Test the compilation of yield statements.
+ *
+ * @group laravel
+ */
+ public function testYieldsAreCompiledCorrectly()
+ {
+ $blade = "@yield('something')";
+
+ $this->assertEquals("", Blade::compile_string($blade));
+ }
+
+ /**
+ * Test the compilation of section statements.
+ *
+ * @group laravel
+ */
+ public function testSectionsAreCompiledCorrectly()
+ {
+ $blade = "@section('something')\nfoo\n@endsection";
+
+ $this->assertEquals("\nfoo\n", Blade::compile_string($blade));
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/bundle.test.php b/tests/cases/bundle.test.php
new file mode 100644
index 00000000..5a107d62
--- /dev/null
+++ b/tests/cases/bundle.test.php
@@ -0,0 +1,253 @@
+ 'foo-baz'));
+ $this->assertEquals('foo-baz', Bundle::$bundles['foo-baz']['handles']);
+ $this->assertFalse(Bundle::$bundles['foo-baz']['auto']);
+
+ Bundle::register('foo-bar', array());
+ $this->assertFalse(Bundle::$bundles['foo-baz']['auto']);
+ $this->assertNull(Bundle::$bundles['foo-bar']['handles']);
+
+ unset(Bundle::$bundles['foo-baz']);
+ unset(Bundle::$bundles['foo-bar']);
+ }
+
+ /**
+ * Test the Bundle::start method.
+ *
+ * @group laravel
+ */
+ public function testStartMethodStartsBundle()
+ {
+ $_SERVER['bundle.dummy.start'] = 0;
+ $_SERVER['bundle.dummy.routes'] = 0;
+
+ $_SERVER['started.dummy'] = false;
+
+ Event::listen('laravel.started: dummy', function()
+ {
+ $_SERVER['started.dummy'] = true;
+ });
+
+ Bundle::register('dummy');
+ Bundle::start('dummy');
+
+ $this->assertTrue($_SERVER['started.dummy']);
+ $this->assertEquals(1, $_SERVER['bundle.dummy.start']);
+ $this->assertEquals(1, $_SERVER['bundle.dummy.routes']);
+
+ Bundle::start('dummy');
+
+ $this->assertEquals(1, $_SERVER['bundle.dummy.start']);
+ $this->assertEquals(1, $_SERVER['bundle.dummy.routes']);
+ }
+
+ /**
+ * Test Bundle::handles method.
+ *
+ * @group laravel
+ */
+ public function testHandlesMethodReturnsBundleThatHandlesURI()
+ {
+ Bundle::register('foo', array('handles' => 'foo-bar'));
+ $this->assertEquals('foo', Bundle::handles('foo-bar/admin'));
+ unset(Bundle::$bundles['foo']);
+ }
+
+ /**
+ * Test the Bundle::exist method.
+ *
+ * @group laravel
+ */
+ public function testExistMethodIndicatesIfBundleExist()
+ {
+ $this->assertTrue(Bundle::exists('dashboard'));
+ $this->assertFalse(Bundle::exists('foo'));
+ }
+
+ /**
+ * Test the Bundle::started method.
+ *
+ * @group laravel
+ */
+ public function testStartedMethodIndicatesIfBundleIsStarted()
+ {
+ Bundle::register('dummy');
+ Bundle::start('dummy');
+ $this->assertTrue(Bundle::started('dummy'));
+ }
+
+ /**
+ * Test the Bundle::prefix method.
+ *
+ * @group laravel
+ */
+ public function testPrefixMethodReturnsCorrectPrefix()
+ {
+ $this->assertEquals('dummy::', Bundle::prefix('dummy'));
+ $this->assertEquals('', Bundle::prefix(DEFAULT_BUNDLE));
+ }
+
+ /**
+ * Test the Bundle::class_prefix method.
+ *
+ * @group laravel
+ */
+ public function testClassPrefixMethodReturnsProperClassPrefixForBundle()
+ {
+ $this->assertEquals('Dummy_', Bundle::class_prefix('dummy'));
+ $this->assertEquals('', Bundle::class_prefix(DEFAULT_BUNDLE));
+ }
+
+ /**
+ * Test the Bundle::path method.
+ *
+ * @group laravel
+ */
+ public function testPathMethodReturnsCorrectPath()
+ {
+ $this->assertEquals(path('app'), Bundle::path(null));
+ $this->assertEquals(path('app'), Bundle::path(DEFAULT_BUNDLE));
+ $this->assertEquals(path('bundle').'dashboard'.DS, Bundle::path('dashboard'));
+ }
+
+ /**
+ * Test the Bundle::asset method.
+ *
+ * @group laravel
+ */
+ public function testAssetPathReturnsPathToBundlesAssets()
+ {
+ Config::set('application.url', 'http://localhost');
+
+ $this->assertEquals('http://localhost/bundles/dashboard/', Bundle::assets('dashboard'));
+ $this->assertEquals('http://localhost/', Bundle::assets(DEFAULT_BUNDLE));
+
+ Config::set('application.url', '');
+ }
+
+ /**
+ * Test the Bundle::name method.
+ *
+ * @group laravel
+ */
+ public function testBundleNameCanBeRetrievedFromIdentifier()
+ {
+ $this->assertEquals(DEFAULT_BUNDLE, Bundle::name('something'));
+ $this->assertEquals(DEFAULT_BUNDLE, Bundle::name('something.else'));
+ $this->assertEquals('bundle', Bundle::name('bundle::something.else'));
+ }
+
+ /**
+ * Test the Bundle::element method.
+ *
+ * @group laravel
+ */
+ public function testElementCanBeRetrievedFromIdentifier()
+ {
+ $this->assertEquals('something', Bundle::element('something'));
+ $this->assertEquals('something.else', Bundle::element('something.else'));
+ $this->assertEquals('something.else', Bundle::element('bundle::something.else'));
+ }
+
+ /**
+ * Test the Bundle::identifier method.
+ *
+ * @group laravel
+ */
+ public function testIdentifierCanBeConstructed()
+ {
+ $this->assertEquals('something.else', Bundle::identifier(DEFAULT_BUNDLE, 'something.else'));
+ $this->assertEquals('dashboard::something', Bundle::identifier('dashboard', 'something'));
+ $this->assertEquals('dashboard::something.else', Bundle::identifier('dashboard', 'something.else'));
+ }
+
+ /**
+ * Test the Bundle::resolve method.
+ *
+ * @group laravel
+ */
+ public function testBundleNamesCanBeResolved()
+ {
+ $this->assertEquals(DEFAULT_BUNDLE, Bundle::resolve('foo'));
+ $this->assertEquals('dashboard', Bundle::resolve('dashboard'));
+ }
+
+ /**
+ * Test the Bundle::parse method.
+ *
+ * @group laravel
+ */
+ public function testParseMethodReturnsElementAndIdentifier()
+ {
+ $this->assertEquals(array('application', 'something'), Bundle::parse('something'));
+ $this->assertEquals(array('application', 'something.else'), Bundle::parse('something.else'));
+ $this->assertEquals(array('dashboard', 'something'), Bundle::parse('dashboard::something'));
+ $this->assertEquals(array('dashboard', 'something.else'), Bundle::parse('dashboard::something.else'));
+ }
+
+ /**
+ * Test the Bundle::get method.
+ *
+ * @group laravel
+ */
+ public function testOptionMethodReturnsBundleOption()
+ {
+ $this->assertFalse(Bundle::option('dashboard', 'auto'));
+ $this->assertEquals('dashboard', Bundle::option('dashboard', 'location'));
+ }
+
+ /**
+ * Test the Bundle::all method.
+ *
+ * @group laravel
+ */
+ public function testAllMethodReturnsBundleArray()
+ {
+ Bundle::register('foo');
+ $this->assertEquals(Bundle::$bundles, Bundle::all());
+ unset(Bundle::$bundles['foo']);
+ }
+
+ /**
+ * Test the Bundle::names method.
+ *
+ * @group laravel
+ */
+ public function testNamesMethodReturnsBundleNames()
+ {
+ Bundle::register('foo');
+ $this->assertEquals(array('dashboard', 'dummy', 'foo'), Bundle::names());
+ unset(Bundle::$bundles['foo']);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/config.test.php b/tests/cases/config.test.php
new file mode 100644
index 00000000..573b8cff
--- /dev/null
+++ b/tests/cases/config.test.php
@@ -0,0 +1,79 @@
+assertEquals('UTF-8', Config::get('application.encoding'));
+ $this->assertEquals('mysql', Config::get('database.connections.mysql.driver'));
+ $this->assertEquals('dashboard', Config::get('dashboard::meta.bundle'));
+ }
+
+ /**
+ * Test the Config::has method.
+ *
+ * @group laravel
+ */
+ public function testHasMethodIndicatesIfConfigItemExists()
+ {
+ $this->assertFalse(Config::has('application.foo'));
+ $this->assertTrue(Config::has('application.encoding'));
+ }
+
+ /**
+ * Test the Config::set method.
+ *
+ * @group laravel
+ */
+ public function testConfigItemsCanBeSet()
+ {
+ Config::set('application.encoding', 'foo');
+ Config::set('dashboard::meta.bundle', 'bar');
+
+ $this->assertEquals('foo', Config::get('application.encoding'));
+ $this->assertEquals('bar', Config::get('dashboard::meta.bundle'));
+ }
+
+ /**
+ * Test that environment configurations are loaded correctly.
+ *
+ * @group laravel
+ */
+ public function testEnvironmentConfigsOverrideNormalConfigurations()
+ {
+ $_SERVER['LARAVEL_ENV'] = 'local';
+
+ $this->assertEquals('sqlite', Config::get('database.default'));
+
+ unset($_SERVER['LARAVEL_ENV']);
+ }
+
+ /**
+ * Test that items can be set after the entire file has already been loaded.
+ *
+ * @group laravel
+ */
+ public function testItemsCanBeSetAfterEntireFileIsLoaded()
+ {
+ Config::get('application');
+ Config::set('application.key', 'taylor');
+ $application = Config::get('application');
+
+ $this->assertEquals('taylor', $application['key']);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/controller.test.php b/tests/cases/controller.test.php
new file mode 100644
index 00000000..1963c129
--- /dev/null
+++ b/tests/cases/controller.test.php
@@ -0,0 +1,264 @@
+assertEquals('action_index', Controller::call('auth@index')->content);
+ $this->assertEquals('Admin_Panel_Index', Controller::call('admin.panel@index')->content);
+ $this->assertEquals('Taylor', Controller::call('auth@profile', array('Taylor'))->content);
+ $this->assertEquals('Dashboard_Panel_Index', Controller::call('dashboard::panel@index')->content);
+ }
+
+ /**
+ * Test basic controller filters are called.
+ *
+ * @group laravel
+ */
+ public function testAssignedBeforeFiltersAreRun()
+ {
+ $_SERVER['test-all-after'] = false;
+ $_SERVER['test-all-before'] = false;
+
+ Controller::call('filter@index');
+
+ $this->assertTrue($_SERVER['test-all-after']);
+ $this->assertTrue($_SERVER['test-all-before']);
+ }
+
+ /**
+ * Test that "only" filters only apply to their assigned methods.
+ *
+ * @group laravel
+ */
+ public function testOnlyFiltersOnlyApplyToTheirAssignedMethods()
+ {
+ $_SERVER['test-profile-before'] = false;
+
+ Controller::call('filter@index');
+
+ $this->assertFalse($_SERVER['test-profile-before']);
+
+ Controller::call('filter@profile');
+
+ $this->assertTrue($_SERVER['test-profile-before']);
+ }
+
+ /**
+ * Test that "except" filters only apply to the excluded methods.
+ *
+ * @group laravel
+ */
+ public function testExceptFiltersOnlyApplyToTheExlucdedMethods()
+ {
+ $_SERVER['test-except'] = false;
+
+ Controller::call('filter@index');
+ Controller::call('filter@profile');
+
+ $this->assertFalse($_SERVER['test-except']);
+
+ Controller::call('filter@show');
+
+ $this->assertTrue($_SERVER['test-except']);
+ }
+
+ /**
+ * Test that filters can be constrained by the request method.
+ *
+ * @group laravel
+ */
+ public function testFiltersCanBeConstrainedByRequestMethod()
+ {
+ $_SERVER['test-on-post'] = false;
+
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ Controller::call('filter@index');
+
+ $this->assertFalse($_SERVER['test-on-post']);
+
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ Controller::call('filter@index');
+
+ $this->assertTrue($_SERVER['test-on-post']);
+
+ $_SERVER['test-on-get-put'] = false;
+
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ Controller::call('filter@index');
+
+ $this->assertFalse($_SERVER['test-on-get-put']);
+
+ $_SERVER['REQUEST_METHOD'] = 'PUT';
+ Controller::call('filter@index');
+
+ $this->assertTrue($_SERVER['test-on-get-put']);
+ }
+
+ public function testGlobalBeforeFilterIsNotCalledByController()
+ {
+ $_SERVER['before'] = false;
+ $_SERVER['after'] = false;
+
+ Controller::call('auth@index');
+
+ $this->assertFalse($_SERVER['before']);
+ $this->assertFalse($_SERVER['after']);
+ }
+
+ /**
+ * Test that before filters can override the controller response.
+ *
+ * @group laravel
+ */
+ public function testBeforeFiltersCanOverrideResponses()
+ {
+ $this->assertEquals('Filtered!', Controller::call('filter@login')->content);
+ }
+
+ /**
+ * Test that after filters do not affect the response.
+ *
+ * @group laravel
+ */
+ public function testAfterFiltersDoNotAffectControllerResponse()
+ {
+ $this->assertEquals('action_logout', Controller::call('filter@logout')->content);
+ }
+
+ /**
+ * Test that filter parameters are passed to the filter.
+ *
+ * @group laravel
+ */
+ public function testFilterParametersArePassedToTheFilter()
+ {
+ $this->assertEquals('12', Controller::call('filter@edit')->content);
+ }
+
+ /**
+ * Test that multiple filters can be assigned to a single method.
+ *
+ * @group laravel
+ */
+ public function testMultipleFiltersCanBeAssignedToAnAction()
+ {
+ $_SERVER['test-multi-1'] = false;
+ $_SERVER['test-multi-2'] = false;
+
+ Controller::call('filter@save');
+
+ $this->assertTrue($_SERVER['test-multi-1']);
+ $this->assertTrue($_SERVER['test-multi-2']);
+ }
+
+ /**
+ * Test Restful controllers respond by request method.
+ *
+ * @group laravel
+ */
+ public function testRestfulControllersRespondWithRestfulMethods()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+
+ $this->assertEquals('get_index', Controller::call('restful@index')->content);
+
+ $_SERVER['REQUEST_METHOD'] = 'PUT';
+
+ $this->assertEquals(404, Controller::call('restful@index')->status);
+
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+
+ $this->assertEquals('post_index', Controller::call('restful@index')->content);
+ }
+
+ /**
+ * Test that the template is returned by template controllers.
+ *
+ * @group laravel
+ */
+ public function testTemplateControllersReturnTheTemplate()
+ {
+ $response = Controller::call('template.basic@index');
+
+ $home = file_get_contents(path('app').'views/home/index.php');
+
+ $this->assertEquals($home, $response->content);
+ }
+
+ /**
+ * Test that controller templates can be named views.
+ *
+ * @group laravel
+ */
+ public function testControllerTemplatesCanBeNamedViews()
+ {
+ View::name('home.index', 'home');
+
+ $response = Controller::call('template.named@index');
+
+ $home = file_get_contents(path('app').'views/home/index.php');
+
+ $this->assertEquals($home, $response->content);
+
+ View::$names = array();
+ }
+
+ /**
+ * Test that the "layout" method is called on the controller.
+ *
+ * @group laravel
+ */
+ public function testTheTemplateCanBeOverriden()
+ {
+ $this->assertEquals('Layout', Controller::call('template.override@index')->content);
+ }
+
+ /**
+ * Test the Controller::resolve method.
+ *
+ * @group laravel
+ */
+ public function testResolveMethodChecksTheIoCContainer()
+ {
+ IoC::controller('home', function()
+ {
+ require_once path('app').'controllers/home.php';
+
+ $controller = new Home_Controller;
+
+ $controller->foo = 'bar';
+
+ return $controller;
+ });
+
+ $controller = Controller::resolve(DEFAULT_BUNDLE, 'home');
+
+ $this->assertEquals('bar', $controller->foo);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/cookie.test.php b/tests/cases/cookie.test.php
new file mode 100644
index 00000000..2c6591cb
--- /dev/null
+++ b/tests/cases/cookie.test.php
@@ -0,0 +1,140 @@
+ 'bar');
+ $this->assertTrue(Cookie::has('foo'));
+ $this->assertFalse(Cookie::has('bar'));
+
+ Cookie::put('baz', 'foo');
+ $this->assertTrue(Cookie::has('baz'));
+ }
+
+ /**
+ * Test the Cookie::get method.
+ *
+ * @group laravel
+ */
+ public function testGetMethodCanReturnValueOfCookies()
+ {
+ Cookie::$jar['foo'] = array('value' => 'bar');
+ $this->assertEquals('bar', Cookie::get('foo'));
+
+ Cookie::put('bar', 'baz');
+ $this->assertEquals('baz', Cookie::get('bar'));
+ }
+
+ /**
+ * Test the Cookie::get method respects signatures.
+ *
+ * @group laravel
+ */
+ public function testTamperedCookiesAreReturnedAsNull()
+ {
+ $_COOKIE['foo'] = Cookie::sign('foo', 'bar');
+ $this->assertEquals('bar', Cookie::get('foo'));
+
+ $_COOKIE['foo'] .= '-baz';
+ $this->assertNull(Cookie::get('foo'));
+
+ $_COOKIE['foo'] = Cookie::sign('foo', 'bar');
+ $_COOKIE['foo'] = 'aslk'.$_COOKIE['foo'];
+ $this->assertNull(Cookie::get('foo'));
+ }
+
+ /**
+ * Test Cookie::forever method.
+ *
+ * @group laravel
+ */
+ public function testForeverShouldUseATonOfMinutes()
+ {
+ Cookie::forever('foo', 'bar');
+ $this->assertEquals('bar', Cookie::$jar['foo']['value']);
+ $this->assertEquals(525600, Cookie::$jar['foo']['minutes']);
+
+ Cookie::forever('bar', 'baz', 'path', 'domain', true);
+ $this->assertEquals('path', Cookie::$jar['bar']['path']);
+ $this->assertEquals('domain', Cookie::$jar['bar']['domain']);
+ $this->assertTrue(Cookie::$jar['bar']['secure']);
+ }
+
+ /**
+ * Test the Cookie::forget method.
+ *
+ * @group laravel
+ */
+ public function testForgetSetsCookieWithExpiration()
+ {
+ Cookie::forget('bar', 'path', 'domain', true);
+ $this->assertEquals(-2000, Cookie::$jar['bar']['minutes']);
+ $this->assertEquals('path', Cookie::$jar['bar']['path']);
+ $this->assertEquals('domain', Cookie::$jar['bar']['domain']);
+ $this->assertTrue(Cookie::$jar['bar']['secure']);
+ }
+
+ /**
+ * Test the Cookie::send method.
+ *
+ * @group laravel
+ */
+ public function testSendMethodSetsProperValuesOnCookie()
+ {
+ $_SERVER['cookie.stub'] = array();
+ $_SERVER['function.headers_sent'] = false;
+
+ Cookie::send();
+ $this->assertTrue(count($_SERVER['cookie.stub']) == 0);
+
+ Cookie::put('foo', 'bar', 20, 'path', 'domain', true);
+ Cookie::send();
+ $this->assertTrue(count($_SERVER['cookie.stub']) == 1);
+ $this->assertEquals('foo', $_SERVER['cookie.stub']['foo']['name']);
+ $this->assertEquals(Cookie::sign('foo', 'bar'), $_SERVER['cookie.stub']['foo']['value']);
+ $this->assertEquals('path', $_SERVER['cookie.stub']['foo']['path']);
+ $this->assertEquals('domain', $_SERVER['cookie.stub']['foo']['domain']);
+ $this->assertEquals((time() + (20 * 60)), $_SERVER['cookie.stub']['foo']['time']);
+ $this->assertTrue($_SERVER['cookie.stub']['foo']['secure']);
+
+ Cookie::put('bar', 'baz', 0);
+ Cookie::send();
+ $this->assertEquals(0, $_SERVER['cookie.stub']['bar']['time']);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/database.test.php b/tests/cases/database.test.php
new file mode 100644
index 00000000..84b1faaf
--- /dev/null
+++ b/tests/cases/database.test.php
@@ -0,0 +1,74 @@
+assertTrue(isset(DB::$connections[Config::get('database.default')]));
+
+ $connection = DatabaseConnectStub::connection('mysql');
+ $this->assertTrue(isset(DB::$connections['mysql']));
+ $this->assertEquals(DB::$connections['mysql']->pdo->laravel_config, Config::get('database.connections.mysql'));
+ }
+
+ /**
+ * Test the DB::profile method.
+ *
+ * @group laravel
+ */
+ public function testProfileMethodReturnsQueries()
+ {
+ Laravel\Database\Connection::$queries = array('Taylor');
+ $this->assertEquals(array('Taylor'), DB::profile());
+ Laravel\Database\Connection::$queries = array();
+ }
+
+ /**
+ * Test the __callStatic method.
+ *
+ * @group laravel
+ */
+ public function testConnectionMethodsCanBeCalledStaticly()
+ {
+ $this->assertEquals('sqlite', DB::driver());
+ }
+
+}
+
+class DatabaseConnectStub extends Laravel\Database {
+
+ protected static function connect($config) { return new PDOStub($config); }
+
+}
+
+class PDOStub extends PDO {
+
+ public $laravel_config;
+
+ public function __construct($config) { $this->laravel_config = $config; }
+
+ public function foo() { return 'foo'; }
+
+}
\ No newline at end of file
diff --git a/tests/cases/event.test.php b/tests/cases/event.test.php
new file mode 100644
index 00000000..52063833
--- /dev/null
+++ b/tests/cases/event.test.php
@@ -0,0 +1,43 @@
+assertEquals(1, $responses[0]);
+ $this->assertEquals(2, $responses[1]);
+ }
+
+ /**
+ * Test parameters can be passed to event listeners.
+ *
+ * @group laravel
+ */
+ public function testParametersCanBePassedToEvents()
+ {
+ Event::listen('test.event', function($var) { return $var; });
+
+ $responses = Event::fire('test.event', array('Taylor'));
+
+ $this->assertEquals('Taylor', $responses[0]);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/fluent.test.php b/tests/cases/fluent.test.php
new file mode 100644
index 00000000..94618dc9
--- /dev/null
+++ b/tests/cases/fluent.test.php
@@ -0,0 +1,50 @@
+ 'Taylor', 'age' => 25);
+
+ $fluent = new FLuent($array);
+
+ $this->assertEquals($array, $fluent->attributes);
+ }
+
+ /**
+ * Test the Fluent::get method.
+ *
+ * @group laravel
+ */
+ public function testGetMethodReturnsAttribute()
+ {
+ $fluent = new Fluent(array('name' => 'Taylor'));
+
+ $this->assertEquals('Taylor', $fluent->get('name'));
+ $this->assertEquals('Default', $fluent->get('foo', 'Default'));
+ $this->assertEquals('Taylor', $fluent->name);
+ $this->assertNull($fluent->foo);
+ }
+
+ public function testMagicMethodsCanBeUsedToSetAttributes()
+ {
+ $fluent = new FLuent;
+
+ $fluent->name = 'Taylor';
+ $fluent->developer();
+ $fluent->age(25);
+
+ $this->assertEquals('Taylor', $fluent->name);
+ $this->assertTrue($fluent->developer);
+ $this->assertEquals(25, $fluent->age);
+ $this->assertInstanceOf('Laravel\\Fluent', $fluent->programmer());
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/hash.test.php b/tests/cases/hash.test.php
new file mode 100644
index 00000000..4dca2713
--- /dev/null
+++ b/tests/cases/hash.test.php
@@ -0,0 +1,37 @@
+assertTrue(strlen(Hash::make('taylor')) == 60);
+ }
+
+ /**
+ * Test the Hash::check method.
+ *
+ * @group laravel
+ */
+ public function testHashCheckFailsWhenNotMatching()
+ {
+ $hash = Hash::make('taylor');
+
+ $this->assertFalse(Hash::check('foo', $hash));
+ }
+
+ /**
+ * Test the Hash::check method.
+ *
+ * @group laravel
+ */
+ public function testHashCheckPassesWhenMatches()
+ {
+ $this->assertTrue(Hash::check('taylor', Hash::make('taylor')));
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/input.test.php b/tests/cases/input.test.php
new file mode 100644
index 00000000..354669ab
--- /dev/null
+++ b/tests/cases/input.test.php
@@ -0,0 +1,172 @@
+ 'Taylor');
+
+ $_FILES = array('age' => 25);
+
+ $this->assertEquals(Input::all(), array('name' => 'Taylor', 'age' => 25));
+ }
+
+ /**
+ * Test the Input::has method.
+ *
+ * @group laravel
+ */
+ public function testHasMethodIndicatesTheExistenceOfInput()
+ {
+ $this->assertFalse(Input::has('foo'));
+
+ Input::$input = array('name' => 'Taylor');
+
+ $this->assertTrue(Input::has('name'));
+ }
+
+ /**
+ * Test the Input::get method.
+ *
+ * @group laravel
+ */
+ public function testGetMethodReturnsInputValue()
+ {
+ Input::$input = array('name' => 'Taylor');
+
+ $this->assertEquals('Taylor', Input::get('name'));
+ $this->assertEquals('Default', Input::get('foo', 'Default'));
+ }
+
+ /**
+ * Test the Input::only method.
+ *
+ * @group laravel
+ */
+ public function testOnlyMethodReturnsSubsetOfInput()
+ {
+ Input::$input = array('name' => 'Taylor', 'age' => 25);
+
+ $this->assertEquals(array('name' => 'Taylor'), Input::only(array('name')));
+ }
+
+ /**
+ * Test the Input::except method.
+ *
+ * @group laravel
+ */
+ public function testExceptMethodReturnsSubsetOfInput()
+ {
+ Input::$input = array('name' => 'Taylor', 'age' => 25);
+
+ $this->assertEquals(array('age' => 25), Input::except(array('name')));
+ }
+
+ /**
+ * Test the Input::old method.
+ *
+ * @group laravel
+ */
+ public function testOldInputCanBeRetrievedFromSession()
+ {
+ $this->setSession();
+
+ Session::$instance->session['data']['laravel_old_input'] = array('name' => 'Taylor');
+
+ $this->assertNull(Input::old('foo'));
+ $this->assertTrue(Input::had('name'));
+ $this->assertFalse(Input::had('foo'));
+ $this->assertEquals('Taylor', Input::old('name'));
+ }
+
+ /**
+ * Test the Input::file method.
+ *
+ * @group laravel
+ */
+ public function testFileMethodReturnsFromFileArray()
+ {
+ $_FILES['foo'] = array('name' => 'Taylor', 'size' => 100);
+
+ $this->assertEquals('Taylor', Input::file('foo.name'));
+ $this->assertEquals(array('name' => 'Taylor', 'size' => 100), Input::file('foo'));
+ }
+
+ /**
+ * Test the Input::flash method.
+ *
+ * @group laravel
+ */
+ public function testFlashMethodFlashesInputToSession()
+ {
+ $this->setSession();
+
+ Input::$input = $input = array('name' => 'Taylor', 'age' => 25);
+
+ Input::flash();
+
+ $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']);
+
+ Input::flash('only', array('name'));
+
+ $this->assertEquals(array('name' => 'Taylor'), Session::$instance->session['data'][':new:']['laravel_old_input']);
+
+ Input::flash('except', array('name'));
+
+ $this->assertEquals(array('age' => 25), Session::$instance->session['data'][':new:']['laravel_old_input']);
+ }
+
+ /**
+ * Test the Input::flush method.
+ *
+ * @group laravel
+ */
+ public function testFlushMethodClearsFlashedInput()
+ {
+ $this->setSession();
+
+ Input::$input = $input = array('name' => 'Taylor');
+
+ Input::flash();
+
+ $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']);
+
+ Input::flush();
+
+ $this->assertEquals(array(), Session::$instance->session['data'][':new:']['laravel_old_input']);
+ }
+
+ /**
+ * Set the session payload instance.
+ */
+ protected function setSession()
+ {
+ $driver = $this->getMock('Laravel\\Session\\Drivers\\Driver');
+
+ Session::$instance = new Laravel\Session\Payload($driver);
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/ioc.test.php b/tests/cases/ioc.test.php
new file mode 100644
index 00000000..964455d0
--- /dev/null
+++ b/tests/cases/ioc.test.php
@@ -0,0 +1,86 @@
+assertEquals('Taylor', IoC::resolve('foo'));
+ }
+
+ /**
+ * Test that singletons are created once.
+ *
+ * @group laravel
+ */
+ public function testSingletonsAreCreatedOnce()
+ {
+ IoC::singleton('foo', function()
+ {
+ return new StdClass;
+ });
+
+ $object = IoC::resolve('foo');
+
+ $this->assertTrue($object === IoC::resolve('foo'));
+ }
+
+ /**
+ * Test the IoC::instance method.
+ *
+ * @group laravel
+ */
+ public function testInstancesAreReturnedBySingleton()
+ {
+ $object = new StdClass;
+
+ IoC::instance('bar', $object);
+
+ $this->assertTrue($object === IoC::resolve('bar'));
+ }
+
+ /**
+ * Test the IoC::registered method.
+ */
+ public function testRegisteredMethodIndicatesIfRegistered()
+ {
+ IoC::register('foo', function() {});
+
+ $this->assertTrue(IoC::registered('foo'));
+ $this->assertFalse(IoC::registered('baz'));
+ }
+
+ /**
+ * Test the IoC::controller method.
+ *
+ * @group laravel
+ */
+ public function testControllerMethodRegistersAController()
+ {
+ IoC::controller('ioc.test', function() {});
+
+ $this->assertTrue(IoC::registered('controller: ioc.test'));
+ }
+
+ /**
+ * Test the IoC::core method.
+ *
+ * @group laravel
+ */
+ public function testCoreMethodReturnsFromLaravel()
+ {
+ IoC::register('laravel.ioc.test', function() { return 'Taylor'; });
+
+ $this->assertEquals('Taylor', IoC::core('ioc.test'));
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/lang.test.php b/tests/cases/lang.test.php
new file mode 100644
index 00000000..74640ccd
--- /dev/null
+++ b/tests/cases/lang.test.php
@@ -0,0 +1,68 @@
+assertEquals($validation['required'], Lang::line('validation.required')->get());
+ $this->assertEquals('Taylor', Lang::line('validation.foo')->get(null, 'Taylor'));
+ }
+
+ /**
+ * Test the Lang::line method.
+ *
+ * @group laravel
+ */
+ public function testGetMethodCanGetLinesForAGivenLanguage()
+ {
+ $validation = require path('app').'language/sp/validation.php';
+
+ $this->assertEquals($validation['required'], Lang::line('validation.required')->get('sp'));
+ }
+
+ /**
+ * Test the __toString method.
+ *
+ * @group laravel
+ */
+ public function testLineCanBeCastAsString()
+ {
+ $validation = require path('app').'language/en/validation.php';
+
+ $this->assertEquals($validation['required'], (string) Lang::line('validation.required'));
+ }
+
+ /**
+ * Test that string replacements are made on lines.
+ *
+ * @group laravel
+ */
+ public function testReplacementsAreMadeOnLines()
+ {
+ $validation = require path('app').'language/en/validation.php';
+
+ $line = str_replace(':attribute', 'e-mail', $validation['required']);
+
+ $this->assertEquals($line, Lang::line('validation.required', array('attribute' => 'e-mail'))->get());
+ }
+
+ /**
+ * Test the Lang::has method.
+ *
+ * @group laravel
+ */
+ public function testHasMethodIndicatesIfLangaugeLineExists()
+ {
+ $this->assertTrue(Lang::has('validation'));
+ $this->assertTrue(Lang::has('validation.required'));
+ $this->assertFalse(Lang::has('validation.foo'));
+ }
+
+}
\ No newline at end of file
diff --git a/tests/cases/messages.test.php b/tests/cases/messages.test.php
new file mode 100644
index 00000000..f007ecb7
--- /dev/null
+++ b/tests/cases/messages.test.php
@@ -0,0 +1,115 @@
+messages = new Laravel\Messages;
+ }
+
+ /**
+ * Test the Messages::add method.
+ *
+ * @group laravel
+ */
+ public function testAddingMessagesDoesNotCreateDuplicateMessages()
+ {
+ $this->messages->add('email', 'test');
+ $this->messages->add('email', 'test');
+ $this->assertCount(1, $this->messages->messages);
+ }
+
+ /**
+ * Test the Messages::add method.
+ *
+ * @group laravel
+ */
+ public function testAddMethodPutsMessageInMessagesArray()
+ {
+ $this->messages->add('email', 'test');
+ $this->assertArrayHasKey('email', $this->messages->messages);
+ $this->assertEquals('test', $this->messages->messages['email'][0]);
+ }
+
+ /**
+ * Test the Messages::has method.
+ *
+ * @group laravel
+ */
+ public function testHasMethodReturnsTrue()
+ {
+ $this->messages->add('email', 'test');
+ $this->assertTrue($this->messages->has('email'));
+ }
+
+ /**
+ * Test the Messages::has method.
+ *
+ * @group laravel
+ */
+ public function testHasMethodReturnsFalse()
+ {
+ $this->assertFalse($this->messages->has('something'));
+ }
+
+ /**
+ * Test the Messages::first method.
+ *
+ * @group laravel
+ */
+ public function testFirstMethodReturnsSingleString()
+ {
+ $this->messages->add('email', 'test');
+ $this->assertEquals('test', $this->messages->first('email'));
+ $this->assertEquals('', $this->messages->first('something'));
+ }
+
+ /**
+ * Test the Messages::get method.
+ *
+ * @group laravel
+ */
+ public function testGetMethodReturnsAllMessagesForAttribute()
+ {
+ $messages = array('email' => array('something', 'else'));
+ $this->messages->messages = $messages;
+ $this->assertEquals(array('something', 'else'), $this->messages->get('email'));
+ }
+
+ /**
+ * Test the Messages::all method.
+ *
+ * @group laravel
+ */
+ public function testAllMethodReturnsAllErrorMessages()
+ {
+ $messages = array('email' => array('something', 'else'), 'name' => array('foo'));
+ $this->messages->messages = $messages;
+ $this->assertEquals(array('something', 'else', 'foo'), $this->messages->all());
+ }
+
+ /**
+ * Test the Messages::get method.
+ *
+ * @group laravel
+ */
+ public function testMessagesRespectFormat()
+ {
+ $this->messages->add('email', 'test');
+ $this->assertEquals('