moving core tests into bundle.
This commit is contained in:
0
tests/cases/application/.gitignore
vendored
0
tests/cases/application/.gitignore
vendored
0
tests/cases/bundles/.gitignore
vendored
0
tests/cases/bundles/.gitignore
vendored
@@ -1,262 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AssetTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Initialize the test environment.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
Config::$items = array();
|
||||
Config::$cache = array();
|
||||
Asset::$containers = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Asset::container method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testContainersCanBeCreated()
|
||||
{
|
||||
$container = Asset::container('foo');
|
||||
|
||||
$this->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::$cache['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::$cache['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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AuthTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Test the Auth::user method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testUserMethodReturnsCurrentUser()
|
||||
{
|
||||
Auth::$user = 'Taylor';
|
||||
|
||||
$this->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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class AuthUserReturnsNull extends Laravel\Auth {
|
||||
|
||||
public static function user() {}
|
||||
|
||||
}
|
||||
|
||||
class AuthUserReturnsDummy extends Laravel\Auth {
|
||||
|
||||
public static function user() { return 'Taylor'; }
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
|
||||
class AutoloaderTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Test the Autoloader::map method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testMapsCanBeRegistered()
|
||||
{
|
||||
Autoloader::map(array(
|
||||
'Foo' => APP_PATH.'models/foo.php',
|
||||
));
|
||||
|
||||
$this->assertEquals(APP_PATH.'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::psr method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testPsrDirectoriesCanBeRegistered()
|
||||
{
|
||||
Autoloader::psr(array(
|
||||
APP_PATH.'foo'.DS.'bar',
|
||||
APP_PATH.'foo'.DS.'baz'.DS.DS,
|
||||
));
|
||||
|
||||
$this->assertTrue(in_array(APP_PATH.'foo'.DS.'bar'.DS, Autoloader::$psr));
|
||||
$this->assertTrue(in_array(APP_PATH.'foo'.DS.'baz'.DS, Autoloader::$psr));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Autoloader::namespaces method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testNamespacesCanBeRegistered()
|
||||
{
|
||||
Autoloader::namespaces(array(
|
||||
'Autoloader_1' => BUNDLE_PATH.'autoload'.DS.'models',
|
||||
'Autoloader_2' => BUNDLE_PATH.'autoload'.DS.'libraries'.DS.DS,
|
||||
));
|
||||
|
||||
$this->assertEquals(BUNDLE_PATH.'autoload'.DS.'models'.DS, Autoloader::$namespaces['Autoloader_1']);
|
||||
$this->assertEquals(BUNDLE_PATH.'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' => APP_PATH.'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' => BUNDLE_PATH.'dashboard'.DS.'models',
|
||||
));
|
||||
|
||||
$this->assertInstanceOf('Dashboard\\Repository', new Dashboard\Repository);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ConfigTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Tear down the testing environment.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
Config::$items = array();
|
||||
Config::$cache = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Config::get method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testItemsCanBeRetrievedFromConfigFiles()
|
||||
{
|
||||
$this->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']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
|
||||
class EventTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Tear down the testing environment.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
Event::$events = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic event firing.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testListenersAreFiredForEvents()
|
||||
{
|
||||
Event::listen('test.event', function()
|
||||
{
|
||||
return 1;
|
||||
});
|
||||
|
||||
Event::listen('test.event', function()
|
||||
{
|
||||
return 2;
|
||||
});
|
||||
|
||||
$responses = Event::fire('test.event');
|
||||
|
||||
$this->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]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Routing\Route;
|
||||
|
||||
class RouteTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Destroy the testing environment.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
Request::$route = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Route::handles method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testHandlesIndicatesIfTheRouteHandlesAGivenURI()
|
||||
{
|
||||
$route = new Route('GET /', array('handles' => array('GET /foo/bar')));
|
||||
|
||||
$this->assertTrue($route->handles('foo/*'));
|
||||
$this->assertTrue($route->handles('foo/bar'));
|
||||
$this->assertFalse($route->handles('/'));
|
||||
$this->assertFalse($route->handles('baz'));
|
||||
$this->assertFalse($route->handles('/foo'));
|
||||
$this->assertFalse($route->handles('foo'));
|
||||
|
||||
$route = new Route('GET /', array('handles' => array('GET /', 'GET /home')));
|
||||
|
||||
$this->assertTrue($route->handles('/'));
|
||||
$this->assertTrue($route->handles('home'));
|
||||
$this->assertFalse($route->handles('foo'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Route::is method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testIsMethodIndicatesIfTheRouteHasAGivenName()
|
||||
{
|
||||
$route = new Route('GET /', array('name' => 'profile'));
|
||||
|
||||
$this->assertTrue($route->is('profile'));
|
||||
$this->assertFalse($route->is('something'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Laravel\Routing\Router;
|
||||
|
||||
class RoutingTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Destroy the testing environment.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
Router::$names = array();
|
||||
Router::$routes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the basic routing mechanism.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testBasicRouteCanBeRouted()
|
||||
{
|
||||
Router::register('GET /', function() {});
|
||||
Router::register(array('GET /home', 'GET /main'), function() {});
|
||||
|
||||
$this->assertEquals('GET /', Router::route('GET', '/')->key);
|
||||
$this->assertEquals('GET /home', Router::route('GET', '/home')->key);
|
||||
$this->assertEquals('GET /main', Router::route('GET', '/main')->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the router can handle basic wildcards.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testWildcardRoutesCanBeRouted()
|
||||
{
|
||||
Router::register('GET /user/(:num)', function() {});
|
||||
Router::register('GET /profile/(:any)/(:num)', function() {});
|
||||
|
||||
$this->assertNull(Router::route('GET', 'user/1.5'));
|
||||
$this->assertNull(Router::route('GET', 'user/taylor'));
|
||||
$this->assertEquals('GET /user/(:num)', Router::route('GET', 'user/1')->key);
|
||||
|
||||
$this->assertNull(Router::route('GET', 'profile/1/otwell'));
|
||||
$this->assertNull(Router::route('POST', 'profile/taylor/1'));
|
||||
$this->assertNull(Router::route('GET', 'profile/taylor/otwell'));
|
||||
$this->assertNull(Router::route('GET', 'profile/taylor/1/otwell'));
|
||||
$this->assertEquals('GET /profile/(:any)/(:num)', Router::route('GET', 'profile/taylor/1')->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that optional wildcards can be routed.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testOptionalWildcardsCanBeRouted()
|
||||
{
|
||||
Router::register('GET /user/(:num?)', function() {});
|
||||
Router::register('GET /profile/(:any)/(:any?)', function() {});
|
||||
|
||||
$this->assertNull(Router::route('GET', 'user/taylor'));
|
||||
$this->assertEquals('GET /user/(:num?)', Router::route('GET', 'user')->key);
|
||||
$this->assertEquals('GET /user/(:num?)', Router::route('GET', 'user/1')->key);
|
||||
|
||||
$this->assertNull(Router::route('GET', 'profile/taylor/otwell/test'));
|
||||
$this->assertEquals('GET /profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor')->key);
|
||||
$this->assertEquals('GET /profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor/25')->key);
|
||||
$this->assertEquals('GET /profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor/otwell')->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that basic controller routing is working.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testBasicRouteToControllerIsRouted()
|
||||
{
|
||||
$this->assertEquals('home@index', Router::route('GET', '/')->action['uses']);
|
||||
$this->assertEquals('auth@index', Router::route('GET', 'auth')->action['uses']);
|
||||
$this->assertEquals('home@index', Router::route('GET', 'home')->action['uses']);
|
||||
$this->assertEquals('home@index', Router::route('GET', 'home/index')->action['uses']);
|
||||
$this->assertEquals('home@profile', Router::route('GET', 'home/profile')->action['uses']);
|
||||
$this->assertEquals('admin.panel@index', Router::route('GET', 'admin/panel')->action['uses']);
|
||||
$this->assertEquals('admin.panel@show', Router::route('GET', 'admin/panel/show')->action['uses']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test basic bundle route resolution.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testRoutesToBundlesCanBeResolved()
|
||||
{
|
||||
$this->assertNull(Router::route('GET', 'dashboard/foo'));
|
||||
$this->assertEquals('GET /dashboard', Router::route('GET', 'dashboard')->key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test bundle controller route resolution.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testBundleControllersCanBeResolved()
|
||||
{
|
||||
$this->assertEquals('dashboard::panel@index', Router::route('GET', 'dashboard/panel')->action['uses']);
|
||||
$this->assertEquals('dashboard::panel@show', Router::route('GET', 'dashboard/panel/show')->action['uses']);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
|
||||
class StrTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Test the Str::encoding method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testEncodingShouldReturnApplicationEncoding()
|
||||
{
|
||||
$this->assertEquals('UTF-8', Config::get('application.encoding'));
|
||||
Config::set('application.encoding', 'foo');
|
||||
$this->assertEquals('foo', Config::get('application.encoding'));
|
||||
Config::set('application.encoding', 'UTF-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::length method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringLengthIsCorrect()
|
||||
{
|
||||
$this->assertEquals(6, Str::length('Taylor'));
|
||||
$this->assertEquals(5, Str::length('ラドクリフ'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::lower method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringCanBeConvertedToLowercase()
|
||||
{
|
||||
$this->assertEquals('taylor', Str::lower('TAYLOR'));
|
||||
$this->assertEquals('άχιστη', Str::lower('ΆΧΙΣΤΗ'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::upper method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringCanBeConvertedToUppercase()
|
||||
{
|
||||
$this->assertEquals('TAYLOR', Str::upper('taylor'));
|
||||
$this->assertEquals('ΆΧΙΣΤΗ', Str::upper('άχιστη'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::title method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringCanBeConvertedToTitleCase()
|
||||
{
|
||||
$this->assertEquals('Taylor', Str::title('taylor'));
|
||||
$this->assertEquals('Άχιστη', Str::title('άχιστη'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::limit method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringCanBeLimitedByCharacters()
|
||||
{
|
||||
$this->assertEquals('Tay...', Str::limit('Taylor', 3));
|
||||
$this->assertEquals('Taylor', Str::limit('Taylor', 6));
|
||||
$this->assertEquals('Tay___', Str::limit('Taylor', 3, '___'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::words method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringCanBeLimitedByWords()
|
||||
{
|
||||
$this->assertEquals('Taylor...', Str::words('Taylor Otwell', 1));
|
||||
$this->assertEquals('Taylor___', Str::words('Taylor Otwell', 1, '___'));
|
||||
$this->assertEquals('Taylor Otwell', Str::words('Taylor Otwell', 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::plural and Str::singular methods.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringsCanBeSingularOrPlural()
|
||||
{
|
||||
$this->assertEquals('user', Str::singular('users'));
|
||||
$this->assertEquals('user', Str::singular('USERS'));
|
||||
$this->assertEquals('users', Str::plural('user'));
|
||||
$this->assertEquals('users', Str::plural('USER'));
|
||||
$this->assertEquals('user', Str::plural('user', 1));
|
||||
$this->assertEquals('users', Str::plural('user', 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::slug method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringsCanBeSlugged()
|
||||
{
|
||||
$this->assertEquals('my-new-post', Str::slug('My nEw post!!!'));
|
||||
$this->assertEquals('my_new_post', Str::slug('My nEw post!!!', '_'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::classify method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testStringsCanBeClassified()
|
||||
{
|
||||
$this->assertEquals('Something_Else', Str::classify('something.else'));
|
||||
$this->assertEquals('Something_Else', Str::classify('something_else'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the Str::random method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testRandomStringsCanBeGenerated()
|
||||
{
|
||||
$this->assertEquals(40, strlen(Str::random(40)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ViewTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
/**
|
||||
* Tear down the testing environment.
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
View::$shared = array();
|
||||
Event::$events = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View::make method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testMakeMethodReturnsAViewInstance()
|
||||
{
|
||||
$this->assertInstanceOf('Laravel\\View', View::make('home.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View class constructor.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testViewNameIsSetByConstrutor()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$this->assertEquals('home.index', $view->view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View class constructor.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testViewIsCreatedWithCorrectPath()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$this->assertEquals(APP_PATH.'views/home/index.php', $view->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View class constructor.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataIsSetOnViewByConstructor()
|
||||
{
|
||||
$view = new View('home.index', array('name' => 'Taylor'));
|
||||
|
||||
$this->assertEquals('Taylor', $view->data['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View::name method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testNameMethodRegistersAViewName()
|
||||
{
|
||||
View::name('home.index', 'home');
|
||||
|
||||
$this->assertEquals('home.index', View::$names['home']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View::shared method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testSharedMethodAddsDataToSharedArray()
|
||||
{
|
||||
View::share('comment', 'Taylor');
|
||||
|
||||
$this->assertEquals('Taylor', View::$shared['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View::with method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testViewDataCanBeSetUsingWithMethod()
|
||||
{
|
||||
$view = View::make('home.index')->with('comment', 'Taylor');
|
||||
|
||||
$this->assertEquals('Taylor', $view->data['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View class constructor.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testEmptyMessageContainerSetOnViewWhenNoErrorsInSession()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$this->assertInstanceOf('Laravel\\Messages', $view->data['errors']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View __set method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataCanBeSetOnViewsThroughMagicMethods()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$view->comment = 'Taylor';
|
||||
|
||||
$this->assertEquals('Taylor', $view->data['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View __get method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataCanBeRetrievedFromViewsThroughMagicMethods()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$view->comment = 'Taylor';
|
||||
|
||||
$this->assertEquals('Taylor', $view->comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View's ArrayAccess implementation.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataCanBeSetOnTheViewThroughArrayAccess()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$view['comment'] = 'Taylor';
|
||||
|
||||
$this->assertEquals('Taylor', $view->data['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View's ArrayAccess implementation.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataCanBeRetrievedThroughArrayAccess()
|
||||
{
|
||||
$view = new View('home.index');
|
||||
|
||||
$view['comment'] = 'Taylor';
|
||||
|
||||
$this->assertEquals('Taylor', $view['comment']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View::nest method.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testNestMethodSetsViewInstanceInData()
|
||||
{
|
||||
$view = View::make('home.index')->nest('partial', 'tests.basic');
|
||||
|
||||
$this->assertEquals('tests.basic', $view->data['partial']->view);
|
||||
|
||||
$this->assertInstanceOf('Laravel\\View', $view->data['partial']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the registered data is passed to the view correctly.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testDataIsPassedToViewCorrectly()
|
||||
{
|
||||
View::share('name', 'Taylor');
|
||||
|
||||
$view = View::make('tests.basic')->with('age', 25)->render();
|
||||
|
||||
$this->assertEquals('Taylor is 25', $view);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the View class renders nested views.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testNestedViewsAreRendered()
|
||||
{
|
||||
$view = View::make('tests.basic')
|
||||
->with('age', 25)
|
||||
->nest('name', 'tests.nested');
|
||||
|
||||
$this->assertEquals('Taylor is 25', $view->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the View class renders nested responses.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testNestedResponsesAreRendered()
|
||||
{
|
||||
$view = View::make('tests.basic')
|
||||
->with('age', 25)
|
||||
->with('name', Response::view('tests.nested'));
|
||||
|
||||
$this->assertEquals('Taylor is 25', $view->render());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the View class raises a composer event.
|
||||
*
|
||||
* @group laravel
|
||||
*/
|
||||
public function testComposerEventIsCalledWhenViewIsRendering()
|
||||
{
|
||||
View::composer('tests.basic', function($view)
|
||||
{
|
||||
$view->data = array('name' => 'Taylor', 'age' => 25);
|
||||
});
|
||||
|
||||
$view = View::make('tests.basic')->render();
|
||||
|
||||
$this->assertEquals('Taylor is 25', $view);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user