diff --git a/phpunit.php b/phpunit.php deleted file mode 100644 index 110b52e6..00000000 --- a/phpunit.php +++ /dev/null @@ -1,32 +0,0 @@ - - - - tests/cases - - - \ No newline at end of file diff --git a/release b/release deleted file mode 100644 index 9bebb88d..00000000 --- a/release +++ /dev/null @@ -1,97 +0,0 @@ -register(); - -$loader->registerNamespace('Symfony', __DIR__.'/vendor'); - -use Laravel\File; -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; - -$console = new Application; - -class TestingReleaser extends Command { - - /** - * Configure the console command. - * - * @return void - */ - protected function configure() - { - $this->setName('testing:release')->setDescription('Release to testing'); - } - - /** - * Merge the develop branch into testing. - * - * return void - */ - public function execute(InputInterface $input, OutputInterface $output) - { - passthru('git checkout testing'); - passthru('git merge develop'); - File::rmdir(__DIR__.'/tests'); - @unlink(__DIR__.'/phpunit.php'); - @unlink(__DIR__.'/phpunit.xml'); - passthru('git commit -am " removed unit tests from repository."'); - } - -} - -class DevelopHotfixer extends Command { - - /** - * Configure the console command. - * - * @return void - */ - public function configure() - { - $this->setName('develop:hotfix')->setDescription('Bring hotfixes into develop'); - } - - /** - * Merge the testing and master branch hotfixes into the develop branch. - * - * @return void - */ - public function execute(InputInterface $input, OutputInterface $output) - { - passthru('git checkout develop'); - File::cpdir(__DIR__.'/tests', __DIR__.'/tests_bkp'); - File::copy(__DIR__.'/phpunit.php', __DIR__.'/phpunit_bkp.php'); - File::copy(__DIR__.'/phpunit.xml', __DIR__.'/phpunit_bkp.xml'); - passthru('git merge testing'); - File::rmdir(__DIR__.'/tests'); - @unlink(__DIR__.'/phpunit.php'); - @unlink(__DIR__.'/phpunit.xml'); - File::cpdir(__DIR__.'/tests_bkp', __DIR__.'/tests'); - File::copy(__DIR__.'/phpunit_bkp.php', __DIR__.'/phpunit.php'); - File::copy(__DIR__.'/phpunit_bkp.xml', __DIR__.'/phpunit.xml'); - File::rmdir(__DIR__.'/tests_bkp'); - @unlink(__DIR__.'/phpunit_bkp.php'); - @unlink(__DIR__.'/phpunit_bkp.xml'); - passthru('git add .'); - passthru('git commit -am " merging hotfixes. re-added tests into repository."'); - } - -} - -$console->add(new TestingReleaser); -$console->add(new DevelopHotfixer); - -$console->run(); \ No newline at end of file diff --git a/tests/application/bundles.php b/tests/application/bundles.php deleted file mode 100644 index 1013f0cf..00000000 --- a/tests/application/bundles.php +++ /dev/null @@ -1,36 +0,0 @@ - array( -| 'location' => 'admin', -| 'handles' => 'admin', -| ), -| -| Note that the "location" is relative to the "bundles" directory. -| Now the bundle will be recognized by Laravel and will be able -| to respond to requests beginning with "admin"! -| -| Have a bundle that lives in the root of the bundle directory -| and doesn't respond to any requests? Just add the bundle -| name to the array and we'll take care of the rest. -| -*/ - -return array('dashboard' => array('handles' => 'dashboard'), 'dummy'); \ No newline at end of file diff --git a/tests/application/config/application.php b/tests/application/config/application.php deleted file mode 100644 index 596baa24..00000000 --- a/tests/application/config/application.php +++ /dev/null @@ -1,158 +0,0 @@ - '', - - /* - |-------------------------------------------------------------------------- - | Application Index - |-------------------------------------------------------------------------- - | - | If you are including the "index.php" in your URLs, you can ignore this. - | - | However, if you are using mod_rewrite to get cleaner URLs, just set - | this option to an empty string and we'll take care of the rest. - | - */ - - 'index' => 'index.php', - - /* - |-------------------------------------------------------------------------- - | Application Key - |-------------------------------------------------------------------------- - | - | This key is used by the encryption and cookie classes to generate secure - | encrypted strings and hashes. It is extremely important that this key - | remain secret and should not be shared with anyone. Make it about 32 - | characters of random gibberish. - | - */ - - 'key' => '', - - /* - |-------------------------------------------------------------------------- - | Application Character Encoding - |-------------------------------------------------------------------------- - | - | The default character encoding used by your application. This encoding - | will be used by the Str, Text, Form, and any other classes that need - | to know what type of encoding to use for your awesome application. - | - */ - - 'encoding' => 'UTF-8', - - /* - |-------------------------------------------------------------------------- - | Application Language - |-------------------------------------------------------------------------- - | - | The default language of your application. This language will be used by - | Lang library as the default language when doing string localization. - | - */ - - 'language' => 'en', - - /* - |-------------------------------------------------------------------------- - | SSL Link Generation - |-------------------------------------------------------------------------- - | - | Many sites use SSL to protect their users data. However, you may not - | always be able to use SSL on your development machine, meaning all HTTPS - | will be broken during development. - | - | For this reason, you may wish to disable the generation of HTTPS links - | throughout your application. This option does just that. All attempts to - | generate HTTPS links will generate regular HTTP links instead. - | - */ - - 'ssl' => true, - - /* - |-------------------------------------------------------------------------- - | Application Timezone - |-------------------------------------------------------------------------- - | - | The default timezone of your application. This timezone will be used when - | Laravel needs a date, such as when writing to a log file or travelling - | to a distant star at warp speed. - | - */ - - 'timezone' => 'UTC', - - /* - |-------------------------------------------------------------------------- - | Class Aliases - |-------------------------------------------------------------------------- - | - | Here, you can specify any class aliases that you would like registered - | when Laravel loads. Aliases are lazy-loaded, so add as many as you want. - | - | Aliases make it more convenient to use namespaced classes. Instead of - | referring to the class using its full namespace, you may simply use - | the alias defined here. - | - | We have already aliased common Laravel classes to make your life easier. - | - */ - - 'aliases' => array( - 'Auth' => 'Laravel\\Auth', - 'Asset' => 'Laravel\\Asset', - 'Autoloader' => 'Laravel\\Autoloader', - 'Blade' => 'Laravel\\Blade', - 'Bundle' => 'Laravel\\Bundle', - 'Cache' => 'Laravel\\Cache', - 'Config' => 'Laravel\\Config', - 'Controller' => 'Laravel\\Routing\\Controller', - 'Cookie' => 'Laravel\\Cookie', - 'Crypter' => 'Laravel\\Crypter', - 'DB' => 'Laravel\\Database', - 'Event' => 'Laravel\\Event', - 'File' => 'Laravel\\File', - 'Filter' => 'Laravel\\Routing\\Filter', - 'Form' => 'Laravel\\Form', - 'Hash' => 'Laravel\\Hash', - 'HTML' => 'Laravel\\HTML', - 'Input' => 'Laravel\\Input', - 'IoC' => 'Laravel\\IoC', - 'Lang' => 'Laravel\\Lang', - 'Log' => 'Laravel\\Log', - 'Memcached' => 'Laravel\\Memcached', - 'Paginator' => 'Laravel\\Paginator', - 'URL' => 'Laravel\\URL', - 'Redirect' => 'Laravel\\Redirect', - 'Redis' => 'Laravel\\Redis', - 'Request' => 'Laravel\\Request', - 'Response' => 'Laravel\\Response', - 'Route' => 'Laravel\\Routing\\Route', - 'Router' => 'Laravel\\Routing\\Router', - 'Schema' => 'Laravel\\Database\\Schema', - 'Section' => 'Laravel\\Section', - 'Session' => 'Laravel\\Session', - 'Str' => 'Laravel\\Str', - 'Task' => 'Laravel\\CLI\\Tasks\\Task', - 'URI' => 'Laravel\\URI', - 'Validator' => 'Laravel\\Validator', - 'View' => 'Laravel\\View', - ), - -); diff --git a/tests/application/config/auth.php b/tests/application/config/auth.php deleted file mode 100644 index d0137583..00000000 --- a/tests/application/config/auth.php +++ /dev/null @@ -1,81 +0,0 @@ - function($id) - { - if (filter_var($id, FILTER_VALIDATE_INT) !== false) - { - return DB::table('users')->find($id); - } - }, - - /* - |-------------------------------------------------------------------------- - | Authenticate User Credentials - |-------------------------------------------------------------------------- - | - | This closure is called by the Auth::attempt() method when attempting to - | authenticate a user that is logging into your application. It's like a - | super buff bouncer to your application. - | - | If the provided credentials are correct, simply return an object that - | represents the user being authenticated. As long as it has a property - | for the "id", any object will work. If the credentials are not valid, - | you don't meed to return anything. - | - */ - - 'attempt' => function($username, $password) - { - $user = DB::table('users')->where_username($username)->first(); - - if ( ! is_null($user) and Hash::check($password, $user->password)) - { - return $user; - } - }, - - /* - |-------------------------------------------------------------------------- - | Logout The Current User - |-------------------------------------------------------------------------- - | - | Here you may do anything that needs to be done when a user logs out of - | your application, such as call the logout method on a third-party API - | you are using for authentication or anything else you desire. - | - */ - - 'logout' => function($user) {}, - - /* - |-------------------------------------------------------------------------- - | "Remember Me" Cookie Name - |-------------------------------------------------------------------------- - | - | Here you may specify the cookie name that will be used for the cookie - | that serves as the "remember me" token. Of course, a sensible default - | has been set for you, so you probably don't need to change it. - | - */ - - 'cookie' => 'laravel_remember', - -); \ No newline at end of file diff --git a/tests/application/config/cache.php b/tests/application/config/cache.php deleted file mode 100644 index 73fd4c9c..00000000 --- a/tests/application/config/cache.php +++ /dev/null @@ -1,71 +0,0 @@ - 'file', - - /* - |-------------------------------------------------------------------------- - | Cache Key - |-------------------------------------------------------------------------- - | - | This key will be prepended to item keys stored using Memcached and APC - | to prevent collisions with other applications on the server. Since the - | memory based stores could be shared by other applications, we need to - | be polite and use a prefix to uniquely identifier our items. - | - */ - - 'key' => 'laravel', - - /* - |-------------------------------------------------------------------------- - | Cache Database - |-------------------------------------------------------------------------- - | - | When using the database cache driver, this database table will be used - | to store the cached item. You may also add a "connection" option to - | the array to specify which database connection should be used. - | - */ - - 'database' => array('table' => 'laravel_cache'), - - /* - |-------------------------------------------------------------------------- - | Memcached Servers - |-------------------------------------------------------------------------- - | - | The Memcached servers used by your application. Memcached is a free and - | open source, high-performance, distributed memory caching system. It is - | generic in nature but intended for use in speeding up web applications - | by alleviating database load. - | - | For more information, check out: http://memcached.org - | - */ - - 'memcached' => array( - - array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100), - - ), - -); \ No newline at end of file diff --git a/tests/application/config/database.php b/tests/application/config/database.php deleted file mode 100644 index b7b9fd96..00000000 --- a/tests/application/config/database.php +++ /dev/null @@ -1,108 +0,0 @@ - 'sqlite', - - /* - |-------------------------------------------------------------------------- - | PDO Fetch Style - |-------------------------------------------------------------------------- - | - | By default, database results will be returned as instances of the PHP - | stdClass object; however, you may wish to retrieve records as arrays - | instead of objects. Here you can control the PDO fetch style of the - | database queries run by your application. - | - */ - - 'fetch' => PDO::FETCH_CLASS, - - /* - |-------------------------------------------------------------------------- - | Database Connections - |-------------------------------------------------------------------------- - | - | All of the database connections used by your application. Many of your - | applications will no doubt only use one connection; however, you have - | the freedom to specify as many connections as you can handle. - | - | All database work in Laravel is done through the PHP's PDO facilities, - | so make sure you have the PDO drivers for your particlar database of - | choice installed on your machine. - | - | Drivers: 'mysql', 'pgsql', 'sqlsrv', 'sqlite'. - | - */ - - 'connections' => array( - - 'sqlite' => array( - 'driver' => 'sqlite', - 'database' => 'application', - 'prefix' => '', - ), - - 'mysql' => array( - 'driver' => 'mysql', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => 'password', - 'charset' => 'utf8', - 'prefix' => '', - ), - - 'pgsql' => array( - 'driver' => 'pgsql', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => 'password', - 'charset' => 'utf8', - 'prefix' => '', - ), - - 'sqlsrv' => array( - 'driver' => 'sqlsrv', - 'host' => 'localhost', - 'database' => 'database', - 'username' => 'root', - 'password' => 'password', - 'prefix' => '', - ), - - ), - - /* - |-------------------------------------------------------------------------- - | Redis Databases - |-------------------------------------------------------------------------- - | - | Redis is an open source, fast, and advanced key-value store. However, it - | provides a richer set of commands than a typical key-value store such as - | APC or memcached. All the cool kids are using it. - | - | To get the scoop on Redis, check out: http://redis.io - | - */ - - 'redis' => array( - - 'default' => array('host' => '127.0.0.1', 'port' => 6379), - - ), - -); \ No newline at end of file diff --git a/tests/application/config/error.php b/tests/application/config/error.php deleted file mode 100644 index 87db9665..00000000 --- a/tests/application/config/error.php +++ /dev/null @@ -1,69 +0,0 @@ - array(E_NOTICE, E_USER_NOTICE, E_DEPRECATED, E_USER_DEPRECATED), - - /* - |-------------------------------------------------------------------------- - | Error Detail - |-------------------------------------------------------------------------- - | - | Detailed error messages contain information about the file in which an - | error occurs, as well as a PHP stack trace containing the call stack. - | You'll want them when you're trying to debug your application. - | - | If your application is in production, you'll want to turn off the error - | details for enhanced security and user experience since the exception - | stack trace could contain sensitive information. - | - */ - - 'detail' => true, - - /* - |-------------------------------------------------------------------------- - | Error Logging - |-------------------------------------------------------------------------- - | - | When error logging is enabled, the "logger" Closure defined below will - | be called for every error in your application. You are free to log the - | errors however you want. Enjoy the flexibility. - | - */ - - 'log' => false, - - /* - |-------------------------------------------------------------------------- - | Error Logger - |-------------------------------------------------------------------------- - | - | Because of the various ways of managing error logging, you get complete - | flexibility to manage error logging as you see fit. This function will - | be called anytime an error occurs within your application and error - | logging is enabled. - | - | You may log the error message however you like; however, a simple log - | solution has been setup for you which will log all error messages to - | text files within the application storage directory. - | - */ - - 'logger' => function($exception) - { - Log::exception($exception); - }, - -); \ No newline at end of file diff --git a/tests/application/config/local/database.php b/tests/application/config/local/database.php deleted file mode 100644 index bd94d7ba..00000000 --- a/tests/application/config/local/database.php +++ /dev/null @@ -1,7 +0,0 @@ - 'sqlite', - -); \ No newline at end of file diff --git a/tests/application/config/mimes.php b/tests/application/config/mimes.php deleted file mode 100644 index e2bd4fbb..00000000 --- a/tests/application/config/mimes.php +++ /dev/null @@ -1,97 +0,0 @@ - 'application/mac-binhex40', - 'cpt' => 'application/mac-compactpro', - 'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream'), - 'bin' => 'application/macbinary', - 'dms' => 'application/octet-stream', - 'lha' => 'application/octet-stream', - 'lzh' => 'application/octet-stream', - 'exe' => array('application/octet-stream', 'application/x-msdownload'), - 'class' => 'application/octet-stream', - 'psd' => 'application/x-photoshop', - 'so' => 'application/octet-stream', - 'sea' => 'application/octet-stream', - 'dll' => 'application/octet-stream', - 'oda' => 'application/oda', - 'pdf' => array('application/pdf', 'application/x-download'), - 'ai' => 'application/postscript', - 'eps' => 'application/postscript', - 'ps' => 'application/postscript', - 'smi' => 'application/smil', - 'smil' => 'application/smil', - 'mif' => 'application/vnd.mif', - 'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'), - 'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'), - 'wbxml' => 'application/wbxml', - 'wmlc' => 'application/wmlc', - 'dcr' => 'application/x-director', - 'dir' => 'application/x-director', - 'dxr' => 'application/x-director', - 'dvi' => 'application/x-dvi', - 'gtar' => 'application/x-gtar', - 'gz' => 'application/x-gzip', - 'php' => array('application/x-httpd-php', 'text/x-php'), - 'php4' => 'application/x-httpd-php', - 'php3' => 'application/x-httpd-php', - 'phtml' => 'application/x-httpd-php', - 'phps' => 'application/x-httpd-php-source', - 'js' => 'application/x-javascript', - 'swf' => 'application/x-shockwave-flash', - 'sit' => 'application/x-stuffit', - 'tar' => 'application/x-tar', - 'tgz' => array('application/x-tar', 'application/x-gzip-compressed'), - 'xhtml' => 'application/xhtml+xml', - 'xht' => 'application/xhtml+xml', - 'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'), - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mpga' => 'audio/mpeg', - 'mp2' => 'audio/mpeg', - 'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'), - 'aif' => 'audio/x-aiff', - 'aiff' => 'audio/x-aiff', - 'aifc' => 'audio/x-aiff', - 'ram' => 'audio/x-pn-realaudio', - 'rm' => 'audio/x-pn-realaudio', - 'rpm' => 'audio/x-pn-realaudio-plugin', - 'ra' => 'audio/x-realaudio', - 'rv' => 'video/vnd.rn-realvideo', - 'wav' => 'audio/x-wav', - 'bmp' => 'image/bmp', - 'gif' => 'image/gif', - 'jpeg' => array('image/jpeg', 'image/pjpeg'), - 'jpg' => array('image/jpeg', 'image/pjpeg'), - 'jpe' => array('image/jpeg', 'image/pjpeg'), - 'png' => 'image/png', - 'tiff' => 'image/tiff', - 'tif' => 'image/tiff', - 'css' => 'text/css', - 'html' => 'text/html', - 'htm' => 'text/html', - 'shtml' => 'text/html', - 'txt' => 'text/plain', - 'text' => 'text/plain', - 'log' => array('text/plain', 'text/x-log'), - 'rtx' => 'text/richtext', - 'rtf' => 'text/rtf', - 'xml' => 'text/xml', - 'xsl' => 'text/xml', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpe' => 'video/mpeg', - 'qt' => 'video/quicktime', - 'mov' => 'video/quicktime', - 'avi' => 'video/x-msvideo', - 'movie' => 'video/x-sgi-movie', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'word' => array('application/msword', 'application/octet-stream'), - 'xl' => 'application/excel', - 'eml' => 'message/rfc822', - 'json' => array('application/json', 'text/json'), - -); \ No newline at end of file diff --git a/tests/application/config/session.php b/tests/application/config/session.php deleted file mode 100644 index 3b6e6a69..00000000 --- a/tests/application/config/session.php +++ /dev/null @@ -1,117 +0,0 @@ - '', - - /* - |-------------------------------------------------------------------------- - | Session Database - |-------------------------------------------------------------------------- - | - | The database table on which the session should be stored. It probably - | goes without saying that this option only matters if you are using - | the super slick database session driver. - | - */ - - 'table' => 'sessions', - - /* - |-------------------------------------------------------------------------- - | Session Garbage Collection Probability - |-------------------------------------------------------------------------- - | - | Some session drivers require the manual clean-up of expired sessions. - | This option specifies the probability of session garbage collection - | occuring for any given request. - | - | For example, the default value states that garbage collection has a - | 2% chance of occuring for any given request to the application. - | Feel free to tune this to your application's size and speed. - | - */ - - 'sweepage' => array(2, 100), - - /* - |-------------------------------------------------------------------------- - | Session Lifetime - |-------------------------------------------------------------------------- - | - | The number of minutes a session can be idle before expiring. - | - */ - - 'lifetime' => 60, - - /* - |-------------------------------------------------------------------------- - | Session Expiration On Close - |-------------------------------------------------------------------------- - | - | Determines if the session should expire when the user's web browser closes. - | - */ - - 'expire_on_close' => false, - - /* - |-------------------------------------------------------------------------- - | Session Cookie Name - |-------------------------------------------------------------------------- - | - | The name that should be given to the session cookie. - | - */ - - 'cookie' => 'laravel_session', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Path - |-------------------------------------------------------------------------- - | - | The path for which the session cookie is available. - | - */ - - 'path' => '/', - - /* - |-------------------------------------------------------------------------- - | Session Cookie Domain - |-------------------------------------------------------------------------- - | - | The domain for which the session cookie is available. - | - */ - - 'domain' => null, - - /* - |-------------------------------------------------------------------------- - | HTTPS Only Session Cookie - |-------------------------------------------------------------------------- - | - | Determines if the cookie should only be sent over HTTPS. - | - */ - - 'secure' => false, - -); \ No newline at end of file diff --git a/tests/application/config/strings.php b/tests/application/config/strings.php deleted file mode 100644 index 730f973e..00000000 --- a/tests/application/config/strings.php +++ /dev/null @@ -1,187 +0,0 @@ - array( - '/(quiz)$/i' => "$1zes", - '/^(ox)$/i' => "$1en", - '/([m|l])ouse$/i' => "$1ice", - '/(matr|vert|ind)ix|ex$/i' => "$1ices", - '/(x|ch|ss|sh)$/i' => "$1es", - '/([^aeiouy]|qu)y$/i' => "$1ies", - '/(hive)$/i' => "$1s", - '/(?:([^f])fe|([lr])f)$/i' => "$1$2ves", - '/(shea|lea|loa|thie)f$/i' => "$1ves", - '/sis$/i' => "ses", - '/([ti])um$/i' => "$1a", - '/(tomat|potat|ech|her|vet)o$/i' => "$1oes", - '/(bu)s$/i' => "$1ses", - '/(alias)$/i' => "$1es", - '/(octop)us$/i' => "$1i", - '/(ax|test)is$/i' => "$1es", - '/(us)$/i' => "$1es", - '/s$/i' => "s", - '/$/' => "s" - ), - - 'singular' => array( - '/(quiz)zes$/i' => "$1", - '/(matr)ices$/i' => "$1ix", - '/(vert|ind)ices$/i' => "$1ex", - '/^(ox)en$/i' => "$1", - '/(alias)es$/i' => "$1", - '/(octop|vir)i$/i' => "$1us", - '/(cris|ax|test)es$/i' => "$1is", - '/(shoe)s$/i' => "$1", - '/(o)es$/i' => "$1", - '/(bus)es$/i' => "$1", - '/([m|l])ice$/i' => "$1ouse", - '/(x|ch|ss|sh)es$/i' => "$1", - '/(m)ovies$/i' => "$1ovie", - '/(s)eries$/i' => "$1eries", - '/([^aeiouy]|qu)ies$/i' => "$1y", - '/([lr])ves$/i' => "$1f", - '/(tive)s$/i' => "$1", - '/(hive)s$/i' => "$1", - '/(li|wi|kni)ves$/i' => "$1fe", - '/(shea|loa|lea|thie)ves$/i' => "$1f", - '/(^analy)ses$/i' => "$1sis", - '/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis", - '/([ti])a$/i' => "$1um", - '/(n)ews$/i' => "$1ews", - '/(h|bl)ouses$/i' => "$1ouse", - '/(corpse)s$/i' => "$1", - '/(us)es$/i' => "$1", - '/(us|ss)$/i' => "$1", - '/s$/i' => "", - ), - - 'irregular' => array( - 'child' => 'children', - 'foot' => 'feet', - 'goose' => 'geese', - 'man' => 'men', - 'move' => 'moves', - 'person' => 'people', - 'sex' => 'sexes', - 'tooth' => 'teeth', - ), - - 'uncountable' => array( - 'audio', - 'equipment', - 'deer', - 'fish', - 'gold', - 'information', - 'money', - 'rice', - 'police', - 'series', - 'sheep', - 'species', - ), - - /* - |-------------------------------------------------------------------------- - | ASCII Characters - |-------------------------------------------------------------------------- - | - | This array contains foreign characters and their 7-bit ASCII equivalents. - | The array is used by the "ascii" method on the Str class to get strings - | ready for inclusion in a URL slug. - | - | Of course, the "ascii" method may also be used by you for whatever your - | application requires. Feel free to add any characters we missed, and be - | sure to let us know about them! - | - */ - - 'ascii' => array( - - '/æ|ǽ/' => 'ae', - '/œ/' => 'oe', - '/À|Á|Â|Ã|Ä|Å|Ǻ|Ā|Ă|Ą|Ǎ|А/' => 'A', - '/à|á|â|ã|ä|å|ǻ|ā|ă|ą|ǎ|ª|а/' => 'a', - '/Б/' => 'B', - '/б/' => 'b', - '/Ç|Ć|Ĉ|Ċ|Č|Ц/' => 'C', - '/ç|ć|ĉ|ċ|č|ц/' => 'c', - '/Ð|Ď|Đ|Д/' => 'Dj', - '/ð|ď|đ|д/' => 'dj', - '/È|É|Ê|Ë|Ē|Ĕ|Ė|Ę|Ě|Е|Ё|Э/' => 'E', - '/è|é|ê|ë|ē|ĕ|ė|ę|ě|е|ё|э/' => 'e', - '/Ф/' => 'F', - '/ƒ|ф/' => 'f', - '/Ĝ|Ğ|Ġ|Ģ|Г/' => 'G', - '/ĝ|ğ|ġ|ģ|г/' => 'g', - '/Ĥ|Ħ|Х/' => 'H', - '/ĥ|ħ|х/' => 'h', - '/Ì|Í|Î|Ï|Ĩ|Ī|Ĭ|Ǐ|Į|İ|И/' => 'I', - '/ì|í|î|ï|ĩ|ī|ĭ|ǐ|į|ı|и/' => 'i', - '/Ĵ|Й/' => 'J', - '/ĵ|й/' => 'j', - '/Ķ|К/' => 'K', - '/ķ|к/' => 'k', - '/Ĺ|Ļ|Ľ|Ŀ|Ł|Л/' => 'L', - '/ĺ|ļ|ľ|ŀ|ł|л/' => 'l', - '/М/' => 'M', - '/м/' => 'm', - '/Ñ|Ń|Ņ|Ň|Н/' => 'N', - '/ñ|ń|ņ|ň|ʼn|н/' => 'n', - '/Ö|Ò|Ó|Ô|Õ|Ō|Ŏ|Ǒ|Ő|Ơ|Ø|Ǿ|О/' => 'O', - '/ö|ò|ó|ô|õ|ō|ŏ|ǒ|ő|ơ|ø|ǿ|º|о/' => 'o', - '/П/' => 'P', - '/п/' => 'p', - '/Ŕ|Ŗ|Ř|Р/' => 'R', - '/ŕ|ŗ|ř|р/' => 'r', - '/Ś|Ŝ|Ş|Ș|Š|С/' => 'S', - '/ś|ŝ|ş|ș|š|ſ|с/' => 's', - '/Ţ|Ț|Ť|Ŧ|Т/' => 'T', - '/ţ|ț|ť|ŧ|т/' => 't', - '/Ù|Ú|Û|Ũ|Ū|Ŭ|Ů|Ü|Ű|Ų|Ư|Ǔ|Ǖ|Ǘ|Ǚ|Ǜ|У/' => 'U', - '/ù|ú|û|ũ|ū|ŭ|ů|ü|ű|ų|ư|ǔ|ǖ|ǘ|ǚ|ǜ|у/' => 'u', - '/В/' => 'V', - '/в/' => 'v', - '/Ý|Ÿ|Ŷ|Ы/' => 'Y', - '/ý|ÿ|ŷ|ы/' => 'y', - '/Ŵ/' => 'W', - '/ŵ/' => 'w', - '/Ź|Ż|Ž|З/' => 'Z', - '/ź|ż|ž|з/' => 'z', - '/Æ|Ǽ/' => 'AE', - '/ß/'=> 'ss', - '/IJ/' => 'IJ', - '/ij/' => 'ij', - '/Œ/' => 'OE', - '/Ч/' => 'Ch', - '/ч/' => 'ch', - '/Ю/' => 'Ju', - '/ю/' => 'ju', - '/Я/' => 'Ja', - '/я/' => 'ja', - '/Ш/' => 'Sh', - '/ш/' => 'sh', - '/Щ/' => 'Shch', - '/щ/' => 'shch', - '/Ж/' => 'Zh', - '/ж/' => 'zh', - - ), - -); \ No newline at end of file diff --git a/tests/application/controllers/admin/panel.php b/tests/application/controllers/admin/panel.php deleted file mode 100644 index da3b49d7..00000000 --- a/tests/application/controllers/admin/panel.php +++ /dev/null @@ -1,10 +0,0 @@ -filter('before', 'test-all-before'); - $this->filter('after', 'test-all-after'); - $this->filter('before', 'test-profile-before')->only(array('profile')); - $this->filter('before', 'test-except')->except(array('index', 'profile')); - $this->filter('before', 'test-on-post')->on(array('post')); - $this->filter('before', 'test-on-get-put')->on(array('get', 'put')); - $this->filter('before', 'test-before-filter')->only('login'); - $this->filter('after', 'test-before-filter')->only('logout'); - $this->filter('before', 'test-param:1,2')->only('edit'); - $this->filter('before', 'test-multi-1|test-multi-2')->only('save'); - } - - public function action_index() - { - return __FUNCTION__; - } - - public function action_profile() - { - return __FUNCTION__; - } - - public function action_show() - { - return __FUNCTION__; - } - - public function action_edit() - { - return __FUNCTION__; - } - - public function action_save() - { - return __FUNCTION__; - } - - public function action_login() - { - return __FUNCTION__; - } - - public function action_logout() - { - return __FUNCTION__; - } - -} \ No newline at end of file diff --git a/tests/application/controllers/home.php b/tests/application/controllers/home.php deleted file mode 100644 index 3f442005..00000000 --- a/tests/application/controllers/home.php +++ /dev/null @@ -1,42 +0,0 @@ - '« Previous', - 'next' => 'Next »', - -); \ No newline at end of file diff --git a/tests/application/language/en/validation.php b/tests/application/language/en/validation.php deleted file mode 100644 index 5c6354dd..00000000 --- a/tests/application/language/en/validation.php +++ /dev/null @@ -1,96 +0,0 @@ - "The :attribute must be accepted.", - "active_url" => "The :attribute is not a valid URL.", - "alpha" => "The :attribute may only contain letters.", - "alpha_dash" => "The :attribute may only contain letters, numbers, and dashes.", - "alpha_num" => "The :attribute may only contain letters and numbers.", - "between" => array( - "numeric" => "The :attribute must be between :min - :max.", - "file" => "The :attribute must be between :min - :max kilobytes.", - "string" => "The :attribute must be between :min - :max characters.", - ), - "confirmed" => "The :attribute confirmation does not match.", - "different" => "The :attribute and :other must be different.", - "email" => "The :attribute format is invalid.", - "exists" => "The selected :attribute is invalid.", - "image" => "The :attribute must be an image.", - "in" => "The selected :attribute is invalid.", - "integer" => "The :attribute must be an integer.", - "ip" => "The :attribute must be a valid IP address.", - "max" => array( - "numeric" => "The :attribute must be less than :max.", - "file" => "The :attribute must be less than :max kilobytes.", - "string" => "The :attribute must be less than :max characters.", - ), - "mimes" => "The :attribute must be a file of type: :values.", - "min" => array( - "numeric" => "The :attribute must be at least :min.", - "file" => "The :attribute must be at least :min kilobytes.", - "string" => "The :attribute must be at least :min characters.", - ), - "not_in" => "The selected :attribute is invalid.", - "numeric" => "The :attribute must be a number.", - "required" => "The :attribute field is required.", - "same" => "The :attribute and :other must match.", - "size" => array( - "numeric" => "The :attribute must be :size.", - "file" => "The :attribute must be :size kilobyte.", - "string" => "The :attribute must be :size characters.", - ), - "unique" => "The :attribute has already been taken.", - "url" => "The :attribute format is invalid.", - - /* - |-------------------------------------------------------------------------- - | Custom Validation Language Lines - |-------------------------------------------------------------------------- - | - | Here you may specify custom validation messages for attributes using the - | convention "attribute_rule" to name the lines. This helps keep your - | custom validation clean and tidy. - | - | So, say you want to use a custom validation message when validating that - | the "email" attribute is unique. Just add "email_unique" to this array - | with your custom message. The Validator will handle the rest! - | - */ - - 'custom' => array('custom_required' => 'This field is required!'), - - /* - |-------------------------------------------------------------------------- - | Validation Attributes - |-------------------------------------------------------------------------- - | - | The following language lines are used to swap attribute place-holders - | with something more reader friendly such as "E-Mail Address" instead - | of "email". Your users will thank you. - | - | The Validator class will automatically search this array of lines it - | is attempting to replace the :attribute place-holder in messages. - | It's pretty slick. We think you'll like it. - | - */ - - 'attributes' => array('test_attribute' => 'attribute'), - -); \ No newline at end of file diff --git a/tests/application/language/sp/validation.php b/tests/application/language/sp/validation.php deleted file mode 100644 index b9bcbe74..00000000 --- a/tests/application/language/sp/validation.php +++ /dev/null @@ -1,7 +0,0 @@ - 'El campo de atributo es necesario.', - -); \ No newline at end of file diff --git a/tests/application/libraries/.gitignore b/tests/application/libraries/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/application/migrations/.gitignore b/tests/application/migrations/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/application/models/.gitignore b/tests/application/models/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/application/models/autoloader.php b/tests/application/models/autoloader.php deleted file mode 100644 index 0e9027dc..00000000 --- a/tests/application/models/autoloader.php +++ /dev/null @@ -1,3 +0,0 @@ - 'home', function() -{ - return View::make('home.index'); -})); - -Route::controller(array( - 'auth', 'filter', 'home', 'restful', - 'template.basic', 'template.name', 'template.override', - 'admin.panel', -)); - -/* -|-------------------------------------------------------------------------- -| Route Filters -|-------------------------------------------------------------------------- -| -| Filters provide a convenient method for attaching functionality to your -| routes. The built-in "before" and "after" filters are called before and -| after every request to your application, and you may even create other -| filters that can be attached to individual routes. -| -| Let's walk through an example... -| -| First, define a filter: -| -| Filter::register('filter', function() -| { -| return 'Filtered!'; -| }); -| -| Next, attach the filter to a route: -| -| Router::register('GET /', array('before' => 'filter', function() -| { -| return 'Hello World!'; -| })); -| -*/ - -Filter::register('before', function() -{ - $_SERVER['before'] = true; -}); - -Filter::register('after', function() -{ - $_SERVER['after'] = true; -}); - -Filter::register('csrf', function() -{ - if (Request::forged()) return Response::error('500'); -}); - -Filter::register('auth', function() -{ - if (Auth::guest()) return Redirect::to('login'); -}); \ No newline at end of file diff --git a/tests/application/start.php b/tests/application/start.php deleted file mode 100644 index 085dd090..00000000 --- a/tests/application/start.php +++ /dev/null @@ -1,157 +0,0 @@ - path('app').'controllers/base.php', -)); - -/* -|-------------------------------------------------------------------------- -| Auto-Loader Directories -|-------------------------------------------------------------------------- -| -| The Laravel auto-loader can search directories for files using the PSR-0 -| naming convention. This convention basically organizes classes by using -| the class namespace to indicate the directory structure. -| -*/ - -Autoloader::directories(array( - path('app').'models', - path('app').'libraries', -)); - -/* -|-------------------------------------------------------------------------- -| Laravel View Loader -|-------------------------------------------------------------------------- -| -| The Laravel view loader is responsible for returning the full file path -| for the given bundle and view. Of course, a default implementation is -| provided to load views according to typical Laravel conventions but -| you may change this to customize how your views are organized. -| -*/ - -Event::listen(View::loader, function($bundle, $view) -{ - return View::file($bundle, $view, Bundle::path($bundle).'views'); -}); - -/* -|-------------------------------------------------------------------------- -| Laravel Language Loader -|-------------------------------------------------------------------------- -| -| The Laravel language loader is responsible for returning the array of -| language lines for a given bundle, language, and "file". A default -| implementation has been provided which uses the default language -| directories included with Laravel. -| -*/ - -Event::listen(Lang::loader, function($bundle, $language, $file) -{ - return Lang::file($bundle, $language, $file); -}); - -/* -|-------------------------------------------------------------------------- -| Enable The Blade View Engine -|-------------------------------------------------------------------------- -| -| The Blade view engine provides a clean, beautiful templating language -| for your application, including syntax for echoing data and all of -| the typical PHP control structures. We'll simply enable it here. -| -*/ - -Blade::sharpen(); - -/* -|-------------------------------------------------------------------------- -| Set The Default Timezone -|-------------------------------------------------------------------------- -| -| We need to set the default timezone for the application. This controls -| the timezone that will be used by any of the date methods and classes -| utilized by Laravel or your application. The timezone may be set in -| your application configuration file. -| -*/ - -date_default_timezone_set(Config::get('application.timezone')); - -/* -|-------------------------------------------------------------------------- -| Start / Load The User Session -|-------------------------------------------------------------------------- -| -| Sessions allow the web, which is stateless, to simulate state. In other -| words, sessions allow you to store information about the current user -| and state of your application. Here we'll just fire up the session -| if a session driver has been configured. -| -*/ - -if ( ! Request::cli() and Config::get('session.driver') !== '') -{ - Session::load(); -} \ No newline at end of file diff --git a/tests/application/tasks/.gitignore b/tests/application/tasks/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/application/views/error/404.php b/tests/application/views/error/404.php deleted file mode 100644 index 9b9bf55b..00000000 --- a/tests/application/views/error/404.php +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - Error 404 - Not Found - - - - -
- - -

- -

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 deleted file mode 100644 index 4dcd92ad..00000000 --- a/tests/application/views/error/500.php +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - Error 500 - Internal Server Error - - - - -
- - -

- -

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 deleted file mode 100644 index 39497146..00000000 --- a/tests/application/views/home/index.php +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - Laravel - A Framework For Web Artisans - - - - -
-

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 deleted file mode 100644 index c961dc2f..00000000 --- a/tests/application/views/tests/basic.php +++ /dev/null @@ -1 +0,0 @@ - is \ No newline at end of file diff --git a/tests/application/views/tests/nested.php b/tests/application/views/tests/nested.php deleted file mode 100644 index 9ce498e5..00000000 --- a/tests/application/views/tests/nested.php +++ /dev/null @@ -1 +0,0 @@ -Taylor \ No newline at end of file diff --git a/tests/bundles/.gitignore b/tests/bundles/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/bundles/dashboard/config/meta.php b/tests/bundles/dashboard/config/meta.php deleted file mode 100644 index a82d1703..00000000 --- a/tests/bundles/dashboard/config/meta.php +++ /dev/null @@ -1,7 +0,0 @@ - 'dashboard', - -); \ No newline at end of file diff --git a/tests/bundles/dashboard/controllers/panel.php b/tests/bundles/dashboard/controllers/panel.php deleted file mode 100644 index b532296d..00000000 --- a/tests/bundles/dashboard/controllers/panel.php +++ /dev/null @@ -1,10 +0,0 @@ - '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 deleted file mode 100644 index 2117e2e0..00000000 --- a/tests/bundles/dummy/routes.php +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index dd9b6e3e..00000000 --- a/tests/cases/auth.test.php +++ /dev/null @@ -1,259 +0,0 @@ -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 deleted file mode 100644 index 80605447..00000000 --- a/tests/cases/autoloader.test.php +++ /dev/null @@ -1,102 +0,0 @@ - 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 deleted file mode 100644 index 70e80b3b..00000000 --- a/tests/cases/blade.test.php +++ /dev/null @@ -1,63 +0,0 @@ -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 deleted file mode 100644 index 5a107d62..00000000 --- a/tests/cases/bundle.test.php +++ /dev/null @@ -1,253 +0,0 @@ - '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 deleted file mode 100644 index 573b8cff..00000000 --- a/tests/cases/config.test.php +++ /dev/null @@ -1,79 +0,0 @@ -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 deleted file mode 100644 index 1963c129..00000000 --- a/tests/cases/controller.test.php +++ /dev/null @@ -1,264 +0,0 @@ -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 deleted file mode 100644 index 2c6591cb..00000000 --- a/tests/cases/cookie.test.php +++ /dev/null @@ -1,140 +0,0 @@ - '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 deleted file mode 100644 index 84b1faaf..00000000 --- a/tests/cases/database.test.php +++ /dev/null @@ -1,74 +0,0 @@ -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 deleted file mode 100644 index 52063833..00000000 --- a/tests/cases/event.test.php +++ /dev/null @@ -1,43 +0,0 @@ -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 deleted file mode 100644 index 94618dc9..00000000 --- a/tests/cases/fluent.test.php +++ /dev/null @@ -1,50 +0,0 @@ - '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 deleted file mode 100644 index 4dca2713..00000000 --- a/tests/cases/hash.test.php +++ /dev/null @@ -1,37 +0,0 @@ -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 deleted file mode 100644 index 354669ab..00000000 --- a/tests/cases/input.test.php +++ /dev/null @@ -1,172 +0,0 @@ - '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 deleted file mode 100644 index 964455d0..00000000 --- a/tests/cases/ioc.test.php +++ /dev/null @@ -1,86 +0,0 @@ -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 deleted file mode 100644 index 74640ccd..00000000 --- a/tests/cases/lang.test.php +++ /dev/null @@ -1,68 +0,0 @@ -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 deleted file mode 100644 index f007ecb7..00000000 --- a/tests/cases/messages.test.php +++ /dev/null @@ -1,115 +0,0 @@ -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('

test

', $this->messages->first('email', '

:message

')); - $this->assertEquals(array('

test

'), $this->messages->get('email', '

:message

')); - $this->assertEquals(array('

test

'), $this->messages->all('

:message

')); - } - - -} \ No newline at end of file diff --git a/tests/cases/query.test.php b/tests/cases/query.test.php deleted file mode 100644 index 17279150..00000000 --- a/tests/cases/query.test.php +++ /dev/null @@ -1,48 +0,0 @@ -assertEquals('taylor@example.com', $this->query()->find(1)->email); - } - - /** - * Test the select method. - * - * @group laravel - */ - public function testSelectMethodLimitsColumns() - { - $result = $this->query()->select(array('email'))->first(); - - $this->assertTrue(isset($result->email)); - $this->assertFalse(isset($result->name)); - } - - /** - * Test the raw_where method. - * - * @group laravel - */ - public function testRawWhereCanBeUsed() - { - - } - - /** - * Get the query instance for the test case. - * - * @return Query - */ - protected function query() - { - return DB::table('query_test'); - } - -} \ No newline at end of file diff --git a/tests/cases/redirect.test.php b/tests/cases/redirect.test.php deleted file mode 100644 index f9f36aec..00000000 --- a/tests/cases/redirect.test.php +++ /dev/null @@ -1,142 +0,0 @@ -assertEquals(302, $redirect->status); - $this->assertEquals('http://localhost/user/profile', $redirect->headers['location']); - - $redirect = Redirect::to('user/profile', 301, true); - - $this->assertEquals(301, $redirect->status); - $this->assertEquals('https://localhost/user/profile', $redirect->headers['location']); - - $redirect = Redirect::to_secure('user/profile', 301); - - $this->assertEquals(301, $redirect->status); - $this->assertEquals('https://localhost/user/profile', $redirect->headers['location']); - } - - /** - * Test the Redirect::to_route method. - * - * @group laravel - */ - public function testRedirectsCanBeGeneratedForNamedRoutes() - { - Route::get('redirect', array('as' => 'redirect')); - Route::get('redirect/(:any)/(:any)', array('as' => 'redirect-2')); - Route::get('secure/redirect', array('https' => true, 'as' => 'redirect-3')); - - $this->assertEquals(301, Redirect::to_route('redirect', array(), 301, true)->status); - $this->assertEquals('http://localhost/redirect', Redirect::to_route('redirect')->headers['location']); - $this->assertEquals('https://localhost/secure/redirect', Redirect::to_route('redirect-3', array(), 302)->headers['location']); - $this->assertEquals('http://localhost/redirect/1/2', Redirect::to_route('redirect-2', array('1', '2'))->headers['location']); - } - - /** - * Test the Redirect::with method. - * - * @group laravel - */ - public function testWithMethodFlashesItemToSession() - { - $this->setSession(); - - $redirect = Redirect::to('')->with('name', 'Taylor'); - - $this->assertEquals('Taylor', Session::$instance->session['data'][':new:']['name']); - } - - /** - * Test the Redirect::with_input function. - * - * @group laravel - */ - public function testWithInputMethodFlashesInputToTheSession() - { - $this->setSession(); - - Input::$input = $input = array('name' => 'Taylor', 'age' => 25); - - $redirect = Redirect::to('')->with_input(); - - $this->assertEquals($input, Session::$instance->session['data'][':new:']['laravel_old_input']); - - $redirect = Redirect::to('')->with_input('only', array('name')); - - $this->assertEquals(array('name' => 'Taylor'), Session::$instance->session['data'][':new:']['laravel_old_input']); - - $redirect = Redirect::to('')->with_input('except', array('name')); - - $this->assertEquals(array('age' => 25), Session::$instance->session['data'][':new:']['laravel_old_input']); - } - - /** - * Test the Redirect::with_errors method. - * - * @group laravel - */ - public function testWithErrorsFlashesErrorsToTheSession() - { - $this->setSession(); - - Redirect::to('')->with_errors(array('name' => 'Taylor')); - - $this->assertEquals(array('name' => 'Taylor'), Session::$instance->session['data'][':new:']['errors']); - - $validator = Validator::make(array(), array()); - $validator->errors = array('name' => 'Taylor'); - - Redirect::to('')->with_errors($validator); - - $this->assertEquals(array('name' => 'Taylor'), Session::$instance->session['data'][':new:']['errors']); - } - - /** - * 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/request.test.php b/tests/cases/request.test.php deleted file mode 100644 index 438f7b12..00000000 --- a/tests/cases/request.test.php +++ /dev/null @@ -1,145 +0,0 @@ -assertEquals('POST', Request::method()); - - $_POST[Request::spoofer] = 'PUT'; - - $this->assertEquals('PUT', Request::method()); - } - - /** - * Test the Request::server method. - * - * @group laravel - */ - public function testServerMethodReturnsFromServerArray() - { - $_SERVER = array('TEST' => 'something', 'USER' => array('NAME' => 'taylor')); - - $this->assertEquals('something', Request::server('test')); - $this->assertEquals('taylor', Request::server('user.name')); - } - - /** - * Test the Request::ip method. - * - * @group laravel - */ - public function testIPMethodReturnsClientIPAddress() - { - $_SERVER['REMOTE_ADDR'] = 'something'; - $this->assertEquals('something', Request::ip()); - - $_SERVER['HTTP_CLIENT_IP'] = 'something'; - $this->assertEquals('something', Request::ip()); - - $_SERVER['HTTP_X_FORWARDED_FOR'] = 'something'; - $this->assertEquals('something', Request::ip()); - - $_SERVER = array(); - $this->assertEquals('0.0.0.0', Request::ip()); - } - - /** - * Test the Request::protocol method. - * - * @group laravel - */ - public function testProtocolMethodReturnsProtocol() - { - $_SERVER['SERVER_PROTOCOL'] = 'taylor'; - $this->assertEquals('taylor', Request::protocol()); - - unset($_SERVER['SERVER_PROTOCOL']); - $this->assertEquals('HTTP/1.1', Request::protocol()); - } - - /** - * Test the Request::secure method. - * - * @group laravel - */ - public function testSecureMethodsIndicatesIfHTTPS() - { - $_SERVER['HTTPS'] = 'on'; - - $this->assertTrue(Request::secure()); - - $_SERVER['HTTPS'] = 'off'; - - $this->assertFalse(Request::secure()); - } - - /** - * Test the Request::ajax method. - * - * @group laravel - */ - public function testAjaxMethodIndicatesWhenAjax() - { - $this->assertFalse(Request::ajax()); - - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'xmlhttprequest'; - - $this->assertTrue(Request::ajax()); - } - - /** - * Test the Request::forged method. - * - * @group laravel - */ - public function testForgedMethodIndicatesIfRequestWasForged() - { - Session::$instance = new SessionPayloadTokenStub; - - Input::$input = array(Session::csrf_token => 'Foo'); - - $this->assertTrue(Request::forged()); - - Input::$input = array(Session::csrf_token => 'Taylor'); - - $this->assertFalse(Request::forged()); - } - - /** - * Test the Request::route method. - * - * @group laravel - */ - public function testRouteMethodReturnsStaticRoute() - { - Request::$route = 'Taylor'; - - $this->assertEquals('Taylor', Request::route()); - } - -} \ No newline at end of file diff --git a/tests/cases/response.test.php b/tests/cases/response.test.php deleted file mode 100644 index 20d92e59..00000000 --- a/tests/cases/response.test.php +++ /dev/null @@ -1,98 +0,0 @@ - 'baz')); - - $this->assertEquals('foo', $response->content); - $this->assertEquals(201, $response->status); - $this->assertEquals(array('bar' => 'baz'), $response->headers); - } - - /** - * Test the Response::view method. - * - * @group laravel - */ - public function testViewMethodSetsContentToView() - { - $response = Response::view('home.index', array('name' => 'Taylor')); - - $this->assertEquals('home.index', $response->content->view); - $this->assertEquals('Taylor', $response->content->data['name']); - } - - /** - * Test the Response::error method. - * - * @group laravel - */ - public function testErrorMethodSetsContentToErrorView() - { - $response = Response::error('404', array('name' => 'Taylor')); - - $this->assertEquals(404, $response->status); - $this->assertEquals('error.404', $response->content->view); - $this->assertEquals('Taylor', $response->content->data['name']); - } - - /** - * Test the Response::prepare method. - * - * @group laravel - */ - public function testPrepareMethodCreatesAResponseInstanceFromGivenValue() - { - $response = Response::prepare('Taylor'); - - $this->assertInstanceOf('Laravel\\Response', $response); - $this->assertEquals('Taylor', $response->content); - - $response = Response::prepare(new Response('Taylor')); - - $this->assertInstanceOf('Laravel\\Response', $response); - $this->assertEquals('Taylor', $response->content); - } - - /** - * Test the Response::message method. - * - * @group laravel - */ - public function testMessageReturnsStatusCodeMessage() - { - $this->assertEquals('OK', Response::make('')->message()); - } - - /** - * Test the Response::header method. - * - * @group laravel - */ - public function testHeaderMethodSetsValueInHeaderArray() - { - $response = Response::make('')->header('foo', 'bar'); - - $this->assertEquals('bar', $response->headers['foo']); - } - - /** - * Test the Response::status method. - * - * @group laravel - */ - public function testStatusMethodSetsStatusCode() - { - $response = Response::make('')->status(404); - - $this->assertEquals(404, $response->status); - } - -} \ No newline at end of file diff --git a/tests/cases/route.test.php b/tests/cases/route.test.php deleted file mode 100644 index 48919135..00000000 --- a/tests/cases/route.test.php +++ /dev/null @@ -1,179 +0,0 @@ - 'profile')); - $this->assertTrue($route->is('profile')); - $this->assertFalse($route->is('something')); - } - - /** - * Test the basic execution of a route. - * - * @group laravel - */ - public function testBasicRoutesCanBeExecutedProperly() - { - $route = new Route('GET', '', array(function() { return 'Route!'; })); - - $this->assertEquals('Route!', $route->call()->content); - $this->assertInstanceOf('Laravel\\Response', $route->call()); - } - - /** - * Test that route parameters are passed into the handlers. - * - * @group laravel - */ - public function testRouteParametersArePassedIntoTheHandler() - { - $route = new Route('GET', '', array(function($var) { return $var; }), array('Taylor')); - - $this->assertEquals('Taylor', $route->call()->content); - $this->assertInstanceOf('Laravel\\Response', $route->call()); - } - - /** - * Test that calling a route calls the global before and after filters. - * - * @group laravel - */ - public function testCallingARouteCallsTheBeforeAndAfterFilters() - { - $route = new Route('GET', '', array(function() { return 'Hi!'; })); - - $_SERVER['before'] = false; - $_SERVER['after'] = false; - - $route->call(); - - $this->assertTrue($_SERVER['before']); - $this->assertTrue($_SERVER['after']); - } - - /** - * Test that before filters override the route response. - * - * @group laravel - */ - public function testBeforeFiltersOverrideTheRouteResponse() - { - Filter::register('test-before', function() - { - return 'Filtered!'; - }); - - $route = new Route('GET', '', array('before' => 'test-before', function() { - return 'Route!'; - })); - - $this->assertEquals('Filtered!', $route->call()->content); - } - - /** - * Test that after filters do not affect the route response. - * - * @group laravel - */ - public function testAfterFilterDoesNotAffectTheResponse() - { - $_SERVER['test-after'] = false; - - Filter::register('test-after', function() - { - $_SERVER['test-after'] = true; - return 'Filtered!'; - }); - - $route = new Route('GET', '', array('after' => 'test-after', function() - { - return 'Route!'; - })); - - $this->assertEquals('Route!', $route->call()->content); - $this->assertTrue($_SERVER['test-after']); - } - - /** - * Test that the route calls the appropriate controller method when delegating. - * - * @group laravel - */ - public function testControllerActionCalledWhenDelegating() - { - $_SERVER['REQUEST_METHOD'] = 'GET'; - - $route = new Route('GET', '', array('uses' => 'auth@index')); - - $this->assertEquals('action_index', $route->call()->content); - } - - /** - * Test that filter parameters are passed to the filter. - * - * @group laravel - */ - public function testFilterParametersArePassedToFilter() - { - Filter::register('test-params', function($var1, $var2) - { - return $var1.$var2; - }); - - $route = new Route('GET', '', array('before' => 'test-params:1,2')); - - $this->assertEquals('12', $route->call()->content); - } - - /** - * Test that multiple filters can be assigned to a route. - * - * @group laravel - */ - public function testMultipleFiltersCanBeAssignedToARoute() - { - $_SERVER['test-multi-1'] = false; - $_SERVER['test-multi-2'] = false; - - Filter::register('test-multi-1', function() { $_SERVER['test-multi-1'] = true; }); - Filter::register('test-multi-2', function() { $_SERVER['test-multi-2'] = true; }); - - $route = new Route('GET', '', array('before' => 'test-multi-1|test-multi-2')); - - $route->call(); - - $this->assertTrue($_SERVER['test-multi-1']); - $this->assertTrue($_SERVER['test-multi-2']); - } - -} \ No newline at end of file diff --git a/tests/cases/routing.test.php b/tests/cases/routing.test.php deleted file mode 100644 index 68a112a0..00000000 --- a/tests/cases/routing.test.php +++ /dev/null @@ -1,160 +0,0 @@ - 'home')); - Route::get('dashboard', array('as' => 'dashboard')); - - $home = Router::find('home'); - $dashboard = Router::find('dashboard'); - - $this->assertTrue(isset($home['/'])); - $this->assertTrue(isset($dashboard['dashboard'])); - } - - /** - * Test the basic routing mechanism. - * - * @group laravel - */ - public function testBasicRouteCanBeRouted() - { - Route::get('/', function() {}); - Route::get('home, main', function() {}); - - $this->assertEquals('/', Router::route('GET', '/')->uri); - $this->assertEquals('home', Router::route('GET', 'home')->uri); - $this->assertEquals('main', Router::route('GET', 'main')->uri); - } - - /** - * Test that the router can handle basic wildcards. - * - * @group laravel - */ - public function testWildcardRoutesCanBeRouted() - { - Route::get('user/(:num)', function() {}); - Route::get('profile/(:any)/(:num)', function() {}); - - $this->assertNull(Router::route('GET', 'user/1.5')); - $this->assertNull(Router::route('GET', 'user/taylor')); - $this->assertEquals(array(25), Router::route('GET', 'user/25')->parameters); - $this->assertEquals('user/(:num)', Router::route('GET', 'user/1')->uri); - - $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(array('taylor', 25), Router::route('GET', 'profile/taylor/25')->parameters); - $this->assertEquals('profile/(:any)/(:num)', Router::route('GET', 'profile/taylor/1')->uri); - } - - /** - * Test that optional wildcards can be routed. - * - * @group laravel - */ - public function testOptionalWildcardsCanBeRouted() - { - Route::get('user/(:num?)', function() {}); - Route::get('profile/(:any)/(:any?)', function() {}); - - $this->assertNull(Router::route('GET', 'user/taylor')); - $this->assertEquals('user/(:num?)', Router::route('GET', 'user')->uri); - $this->assertEquals(array(25), Router::route('GET', 'user/25')->parameters); - $this->assertEquals('user/(:num?)', Router::route('GET', 'user/1')->uri); - - $this->assertNull(Router::route('GET', 'profile/taylor/otwell/test')); - $this->assertEquals('profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor')->uri); - $this->assertEquals('profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor/25')->uri); - $this->assertEquals('profile/(:any)/(:any?)', Router::route('GET', 'profile/taylor/otwell')->uri); - $this->assertEquals(array('taylor', 'otwell'), Router::route('GET', 'profile/taylor/otwell')->parameters); - } - - /** - * Test that basic controller routing is working. - * - * @group laravel - */ - public function testBasicRouteToControllerIsRouted() - { - $this->assertEquals('auth@(:1)', Router::route('GET', 'auth')->action['uses']); - $this->assertEquals('home@(:1)', Router::route('GET', 'home/index')->action['uses']); - $this->assertEquals('home@(:1)', Router::route('GET', 'home/profile')->action['uses']); - $this->assertEquals('admin.panel@(:1)', Router::route('GET', 'admin/panel')->action['uses']); - $this->assertEquals('admin.panel@(:1)', 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('dashboard', Router::route('GET', 'dashboard')->uri); - } - - /** - * Test bundle controller route resolution. - * - * @group laravel - */ - public function testBundleControllersCanBeResolved() - { - $this->assertEquals('dashboard::panel@(:1)', Router::route('GET', 'dashboard/panel')->action['uses']); - $this->assertEquals('dashboard::panel@(:1)', Router::route('GET', 'dashboard/panel/show')->action['uses']); - } - - /** - * Test foreign characters can be used in routes. - * - * @group laravel - */ - public function testForeignCharsInRoutes() - { - Route::get(urlencode('مدرس_رياضيات').'/(:any)', function() {}); - Route::get(urlencode('مدرس_رياضيات'), function() {}); - Route::get(urlencode('ÇœŪ'), function() {}); - Route::get(urlencode('私は料理が大好き'), function() {}); - - $this->assertEquals(array(urlencode('مدرس_رياضيات')), Router::route('GET', urlencode('مدرس_رياضيات').'/'.urlencode('مدرس_رياضيات'))->parameters); - $this->assertEquals(urlencode('مدرس_رياضيات'), Router::route('GET', urlencode('مدرس_رياضيات'))->uri); - $this->assertEquals(urlencode('ÇœŪ'), Router::route('GET', urlencode('ÇœŪ'))->uri); - $this->assertEquals(urlencode('私は料理が大好き'), Router::route('GET', urlencode('私は料理が大好き'))->uri); - } - -} \ No newline at end of file diff --git a/tests/cases/session.test.php b/tests/cases/session.test.php deleted file mode 100644 index 2c7ccdc9..00000000 --- a/tests/cases/session.test.php +++ /dev/null @@ -1,441 +0,0 @@ -assertEquals('Foo', Session::test()); - } - - /** - * Test the Session::started method. - * - * @group laravel - */ - public function testStartedMethodIndicatesIfSessionIsStarted() - { - $this->assertFalse(Session::started()); - Session::$instance = 'foo'; - $this->assertTrue(Session::started()); - } - - /** - * Test the Payload::load method. - * - * @group laravel - */ - public function testLoadMethodCreatesNewSessionWithNullIDGiven() - { - $payload = $this->getPayload(); - $payload->load(null); - $this->verifyNewSession($payload); - } - - /** - * Test the Payload::load method. - * - * @group laravel - */ - public function testLoadMethodCreatesNewSessionWhenSessionIsExpired() - { - $payload = $this->getPayload(); - - $session = $this->getSession(); - $session['last_activity'] = time() - 10000; - - $payload->driver->expects($this->any()) - ->method('load') - ->will($this->returnValue($session)); - - $payload->load('foo'); - - $this->verifyNewSession($payload); - $this->assertTrue($payload->session['id'] !== $session['id']); - } - - /** - * Assert that a session is new. - * - * @param Payload $payload - * @return void - */ - protected function verifyNewSession($payload) - { - $this->assertFalse($payload->exists); - $this->assertTrue(isset($payload->session['id'])); - $this->assertEquals(array(), $payload->session['data'][':new:']); - $this->assertEquals(array(), $payload->session['data'][':old:']); - $this->assertTrue(isset($payload->session['data'][Session::csrf_token])); - } - - /** - * Test the Payload::load method. - * - * @group laravel - */ - public function testLoadMethodSetsValidSession() - { - $payload = $this->getPayload(); - - $session = $this->getSession(); - - $payload->driver->expects($this->any()) - ->method('load') - ->will($this->returnValue($session)); - - $payload->load('foo'); - - $this->assertEquals($session, $payload->session); - } - - /** - * Test the Payload::load method. - * - * @group laravel - */ - public function testLoadMethodSetsCSRFTokenIfDoesntExist() - { - $payload = $this->getPayload(); - - $session = $this->getSession(); - - unset($session['data']['csrf_token']); - - $payload->driver->expects($this->any()) - ->method('load') - ->will($this->returnValue($session)); - - $payload->load('foo'); - - $this->assertEquals('foo', $payload->session['id']); - $this->assertTrue(isset($payload->session['data']['csrf_token'])); - } - - /** - * Test the various data retrieval methods. - * - * @group laravel - */ - public function testSessionDataCanBeRetrievedProperly() - { - $payload = $this->getPayload(); - - $payload->session = $this->getSession(); - - $this->assertTrue($payload->has('name')); - $this->assertEquals('Taylor', $payload->get('name')); - $this->assertFalse($payload->has('foo')); - $this->assertEquals('Default', $payload->get('foo', 'Default')); - $this->assertTrue($payload->has('votes')); - $this->assertEquals(10, $payload->get('votes')); - $this->assertTrue($payload->has('state')); - $this->assertEquals('AR', $payload->get('state')); - } - - /** - * Test the various data manipulation methods. - * - * @group laravel - */ - public function testDataCanBeSetProperly() - { - $payload = $this->getPayload(); - - $payload->session = $this->getSession(); - - // Test the "put" and "flash" methods. - $payload->put('name', 'Weldon'); - $this->assertEquals('Weldon', $payload->session['data']['name']); - $payload->flash('language', 'php'); - $this->assertEquals('php', $payload->session['data'][':new:']['language']); - - // Test the "reflash" method. - $payload->session['data'][':new:'] = array('name' => 'Taylor'); - $payload->session['data'][':old:'] = array('age' => 25); - $payload->reflash(); - $this->assertEquals(array('name' => 'Taylor', 'age' => 25), $payload->session['data'][':new:']); - - // Test the "keep" method. - $payload->session['data'][':new:'] = array(); - $payload->keep(array('age')); - $this->assertEquals(25, $payload->session['data'][':new:']['age']); - } - - /** - * Test the Payload::forget method. - * - * @group laravel - */ - public function testSessionDataCanBeForgotten() - { - $payload = $this->getPayload(); - - $payload->session = $this->getSession(); - - $this->assertTrue(isset($payload->session['data']['name'])); - $payload->forget('name'); - $this->assertFalse(isset($payload->session['data']['name'])); - } - - /** - * Test the Payload::flush method. - * - * @group laravel - */ - public function testFlushMaintainsTokenButDeletesEverythingElse() - { - $payload = $this->getPayload(); - - $payload->session = $this->getSession(); - - $this->assertTrue(isset($payload->session['data']['name'])); - $payload->flush(); - $this->assertFalse(isset($payload->session['data']['name'])); - $this->assertEquals('bar', $payload->session['data']['csrf_token']); - $this->assertEquals(array(), $payload->session['data'][':new:']); - $this->assertEquals(array(), $payload->session['data'][':old:']); - } - - /** - * Test the Payload::regenerate method. - * - * @group laravel - */ - public function testRegenerateMethodSetsNewIDAndTurnsOffExistenceIndicator() - { - $payload = $this->getPayload(); - - $payload->sesion = $this->getSession(); - $payload->exists = true; - $payload->regenerate(); - - $this->assertFalse($payload->exists); - $this->assertTrue(strlen($payload->session['id']) == 40); - } - - /** - * Test the Payload::token method. - * - * @group laravel - */ - public function testTokenMethodReturnsCSRFToken() - { - $payload = $this->getPayload(); - $payload->session = $this->getSession(); - - $this->assertEquals('bar', $payload->token()); - } - - /** - * Test the Payload::save method. - * - * @group laravel - */ - public function testSaveMethodCorrectlyCallsDriver() - { - $payload = $this->getPayload(); - $session = $this->getSession(); - $payload->session = $session; - $payload->exists = true; - $config = Laravel\Config::get('session'); - - $expect = $session; - $expect['data'][':old:'] = $session['data'][':new:']; - $expect['data'][':new:'] = array(); - - $payload->driver->expects($this->once()) - ->method('save') - ->with($this->equalTo($expect), $this->equalTo($config), $this->equalTo(true)); - - $payload->save(); - - $this->assertEquals($session['data'][':new:'], $payload->session['data'][':old:']); - } - - /** - * Test the Payload::save method. - * - * @group laravel - */ - public function testSaveMethodSweepsIfSweeperAndOddsHitWithTimeGreaterThanThreshold() - { - Config::set('session.sweepage', array(100, 100)); - - $payload = $this->getPayload(); - $payload->driver = $this->getMock('Laravel\\Session\\Drivers\\File', array('save', 'sweep'), array(null)); - $payload->session = $this->getSession(); - - $expiration = time() - (Config::get('session.lifetime') * 60); - - // Here we set the time to the expected expiration minus 5 seconds, just to - // allow plenty of room for PHP execution. In the next test, we'll do the - // same thing except add 5 seconds to check that the time is between a - // given window. - $payload->driver->expects($this->once()) - ->method('sweep') - ->with($this->greaterThan($expiration - 5)); - - $payload->save(); - - Config::set('session.sweepage', array(2, 100)); - } - - /** - * Test the Payload::save method. - * - * @group laravel - */ - public function testSaveMethodSweepsIfSweeperAndOddsHitWithTimeLessThanThreshold() - { - Config::set('session.sweepage', array(100, 100)); - - $payload = $this->getPayload(); - $payload->driver = $this->getMock('Laravel\\Session\\Drivers\\File', array('save', 'sweep'), array(null)); - $payload->session = $this->getSession(); - - $expiration = time() - (Config::get('session.lifetime') * 60); - - $payload->driver->expects($this->once()) - ->method('sweep') - ->with($this->lessThan($expiration + 5)); - - $payload->save(); - - Config::set('session.sweepage', array(2, 100)); - } - - /** - * Test that the session sweeper is never called if not a sweeper. - * - * @group laravel - */ - public function testSweeperShouldntBeCalledIfDriverIsntSweeper() - { - Config::set('session.sweepage', array(100, 100)); - - $payload = $this->getPayload(); - $payload->driver = $this->getMock('Laravel\\Session\\Drivers\\APC', array('save', 'sweep'), array(), '', false); - $payload->session = $this->getSession(); - - $payload->driver->expects($this->never())->method('sweep'); - - $payload->save(); - - Config::set('session.sweepage', array(2, 100)); - } - - /** - * Test the Payload::save method. - * - * @group laravel - */ - public function testSaveMethodSetsCookieWithCorrectValues() - { - $payload = $this->getPayload(); - $payload->session = $this->getSession(); - $payload->save(); - - $this->assertTrue(isset(Cookie::$jar[Config::get('session.cookie')])); - - $cookie = Cookie::$jar[Config::get('session.cookie')]; - - $this->assertEquals('foo', $cookie['value']); - $this->assertEquals(Config::get('session.lifetime'), $cookie['minutes']); - $this->assertEquals(Config::get('session.domain'), $cookie['domain']); - $this->assertEquals(Config::get('session.path'), $cookie['path']); - $this->assertEquals(Config::get('session.secure'), $cookie['secure']); - } - - /** - * Test the Session::activity method. - * - * @group laravel - */ - public function testActivityMethodReturnsLastActivity() - { - $payload = $this->getPayload(); - $payload->session['last_activity'] = 10; - $this->assertEquals(10, $payload->activity()); - } - - /** - * Get a session payload instance. - * - * @return Payload - */ - protected function getPayload() - { - return new Payload($this->getMockDriver()); - } - - /** - * Get a mock driver instance. - * - * @return Driver - */ - protected function getMockDriver() - { - $mock = $this->getMock('Laravel\\Session\\Drivers\\Driver', array('id', 'load', 'save', 'delete')); - - $mock->expects($this->any())->method('id')->will($this->returnValue(Str::random(40))); - - return $mock; - } - - /** - * Get a dummy session. - * - * @return array - */ - protected function getSession() - { - return array( - 'id' => 'foo', - 'last_activity' => time(), - 'data' => array( - 'name' => 'Taylor', - 'age' => 25, - 'csrf_token' => 'bar', - ':new:' => array( - 'votes' => 10, - ), - ':old:' => array( - 'state' => 'AR', - ), - )); - } - -} \ No newline at end of file diff --git a/tests/cases/str.test.php b/tests/cases/str.test.php deleted file mode 100644 index 7daab540..00000000 --- a/tests/cases/str.test.php +++ /dev/null @@ -1,133 +0,0 @@ -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('users', Str::plural('user')); - $this->assertEquals('User', Str::singular('Users')); - $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))); - } - -} \ No newline at end of file diff --git a/tests/cases/uri.test.php b/tests/cases/uri.test.php deleted file mode 100644 index be779ecf..00000000 --- a/tests/cases/uri.test.php +++ /dev/null @@ -1,59 +0,0 @@ -assertEquals($expectation, URI::current()); - } - - /** - * Test the URI::segment method. - * - * @group laravel - */ - public function testSegmentMethodReturnsAURISegment() - { - $_SERVER['REQUEST_URI'] = 'http://localhost/index.php/user/profile'; - - $this->assertEquals('user', URI::segment(1)); - $this->assertEquals('profile', URI::segment(2)); - } - - /** - * Data provider for the URI::current test. - */ - public function requestUriProvider() - { - return array( - array('/index.php', '/'), - array('/index.php/', '/'), - array('http://localhost/user', 'user'), - array('http://localhost/user/', 'user'), - array('http://localhost/index.php', '/'), - array('http://localhost/index.php/', '/'), - array('http://localhost/index.php//', '/'), - array('http://localhost/index.php/user', 'user'), - array('http://localhost/index.php/user/', 'user'), - array('http://localhost/index.php/user/profile', 'user/profile'), - ); - } - -} \ No newline at end of file diff --git a/tests/cases/url.test.php b/tests/cases/url.test.php deleted file mode 100644 index d30ca7e4..00000000 --- a/tests/cases/url.test.php +++ /dev/null @@ -1,105 +0,0 @@ -assertEquals('http://localhost/index.php/user/profile', URL::to('user/profile')); - $this->assertEquals('https://localhost/index.php/user/profile', URL::to('user/profile', true)); - - Config::set('application.index', ''); - - $this->assertEquals('http://localhost/user/profile', URL::to('user/profile')); - $this->assertEquals('https://localhost/user/profile', URL::to('user/profile', true)); - - Config::set('application.ssl', false); - - $this->assertEquals('http://localhost/user/profile', URL::to('user/profile', true)); - } - - /** - * Test the URL::to_action method. - * - * @group laravel - */ - public function testToActionMethodGeneratesURLToControllerAction() - { - Route::get('foo/bar/(:any?)', 'foo@baz'); - $this->assertEquals('http://localhost/index.php/x/y', URL::to_action('x@y')); - $this->assertEquals('http://localhost/index.php/x/y/Taylor', URL::to_action('x@y', array('Taylor'))); - $this->assertEquals('http://localhost/index.php/foo/bar', URL::to_action('foo@baz')); - $this->assertEquals('http://localhost/index.php/foo/bar/Taylor', URL::to_action('foo@baz', array('Taylor'))); - } - - /** - * Test the URL::to_asset method. - * - * @group laravel - */ - public function testToAssetGeneratesURLWithoutFrontControllerInURL() - { - $this->assertEquals('http://localhost/image.jpg', URL::to_asset('image.jpg')); - $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg', true)); - - Config::set('application.index', ''); - - $this->assertEquals('http://localhost/image.jpg', URL::to_asset('image.jpg')); - $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg', true)); - - $_SERVER['HTTPS'] = 'on'; - - $this->assertEquals('https://localhost/image.jpg', URL::to_asset('image.jpg')); - } - - /** - * Test the URL::to_route method. - * - * @group laravel - */ - public function testToRouteMethodGeneratesURLsToRoutes() - { - Route::get('url/test', array('as' => 'url-test')); - Route::get('url/test/(:any)/(:any?)', array('as' => 'url-test-2')); - Route::get('url/secure/(:any)/(:any?)', array('as' => 'url-test-3', 'https' => true)); - - $this->assertEquals('http://localhost/index.php/url/test', URL::to_route('url-test')); - $this->assertEquals('http://localhost/index.php/url/test/taylor', URL::to_route('url-test-2', array('taylor'))); - $this->assertEquals('https://localhost/index.php/url/secure/taylor', URL::to_route('url-test-3', array('taylor'))); - $this->assertEquals('http://localhost/index.php/url/test/taylor/otwell', URL::to_route('url-test-2', array('taylor', 'otwell'))); - } - -} \ No newline at end of file diff --git a/tests/cases/validator.test.php b/tests/cases/validator.test.php deleted file mode 100644 index bde1cea1..00000000 --- a/tests/cases/validator.test.php +++ /dev/null @@ -1,669 +0,0 @@ - 'Taylor Otwell'); - $rules = array('name' => 'required'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['name'] = ''; - $this->assertFalse(Validator::make($input, $rules)->valid()); - - unset($input['name']); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - $_FILES['name']['tmp_name'] = 'foo'; - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['name']['tmp_name'] = ''; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the confirmed validation rule. - * - * @group laravel - */ - public function testTheConfirmedRule() - { - $input = array('password' => 'foo', 'password_confirmation' => 'foo'); - $rules = array('password' => 'confirmed'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['password_confirmation'] = 'foo_bar'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - - unset($input['password_confirmation']); - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the different validation rule. - * - * @group laravel - */ - public function testTheDifferentRule() - { - $input = array('password' => 'foo', 'password_confirmation' => 'bar'); - $rules = array('password' => 'different:password_confirmation'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['password_confirmation'] = 'foo'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - - unset($input['password_confirmation']); - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the accepted validation rule. - * - * @group laravel - */ - public function testTheAcceptedRule() - { - $input = array('terms' => '1'); - $rules = array('terms' => 'accepted'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['terms'] = 'yes'; - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['terms'] = '2'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // The accepted rule implies required, so should fail if field not present. - unset($input['terms']); - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the numeric validation rule. - * - * @group laravel - */ - public function testTheNumericRule() - { - $input = array('amount' => '1.21'); - $rules = array('amount' => 'numeric'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['amount'] = '1'; - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['amount'] = 1.2; - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['amount'] = '1.2a'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the integer validation rule. - * - * @group laravel - */ - public function testTheIntegerRule() - { - $input = array('amount' => '1'); - $rules = array('amount' => 'integer'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['amount'] = '0'; - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['amount'] = 1.2; - $this->assertFalse(Validator::make($input, $rules)->valid()); - - $input['amount'] = '1.2a'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the size validation rule. - * - * @group laravel - */ - public function testTheSizeRule() - { - $input = array('amount' => '1.21'); - $rules = array('amount' => 'numeric|size:1.21'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'numeric|size:1'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // If no numeric rule is on the field, it is treated as a string - $input = array('amount' => '111'); - $rules = array('amount' => 'size:3'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'size:4'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // The size rules checks kilobytes on files - $_FILES['photo']['tmp_name'] = 'foo'; - $_FILES['photo']['size'] = 10240; - $rules = array('photo' => 'size:10'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['photo']['size'] = 14000; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the between validation rule. - * - * @group laravel - */ - public function testTheBetweenRule() - { - $input = array('amount' => '1.21'); - $rules = array('amount' => 'numeric|between:1,2'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'numeric|between:2,3'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // If no numeric rule is on the field, it is treated as a string - $input = array('amount' => '111'); - $rules = array('amount' => 'between:1,3'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'between:100,111'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // The size rules checks kilobytes on files - $_FILES['photo']['tmp_name'] = 'foo'; - $_FILES['photo']['size'] = 10240; - $rules = array('photo' => 'between:9,11'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['photo']['size'] = 14000; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the between validation rule. - * - * @group laravel - */ - public function testTheMinRule() - { - $input = array('amount' => '1.21'); - $rules = array('amount' => 'numeric|min:1'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'numeric|min:2'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // If no numeric rule is on the field, it is treated as a string - $input = array('amount' => '01'); - $rules = array('amount' => 'min:2'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'min:3'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // The size rules checks kilobytes on files - $_FILES['photo']['tmp_name'] = 'foo'; - $_FILES['photo']['size'] = 10240; - $rules = array('photo' => 'min:9'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['photo']['size'] = 8000; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the between validation rule. - * - * @group laravel - */ - public function testTheMaxRule() - { - $input = array('amount' => '1.21'); - $rules = array('amount' => 'numeric|max:2'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'numeric|max:1'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // If no numeric rule is on the field, it is treated as a string - $input = array('amount' => '01'); - $rules = array('amount' => 'max:3'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $rules = array('amount' => 'max:1'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - // The size rules checks kilobytes on files - $_FILES['photo']['tmp_name'] = 'foo'; - $_FILES['photo']['size'] = 10240; - $rules = array('photo' => 'max:11'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['photo']['size'] = 140000; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the in validation rule. - * - * @group laravel - */ - public function testTheInRule() - { - $input = array('size' => 'L'); - $rules = array('size' => 'in:S,M,L'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['size'] = 'XL'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the not-in validation rule. - * - * @group laravel - */ - public function testTheNotInRule() - { - $input = array('size' => 'L'); - $rules = array('size' => 'not_in:S,M,L'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - $input['size'] = 'XL'; - $this->assertTrue(Validator::make($input, $rules)->valid()); - } - - /** - * Test the IP validation rule. - * - * @group laravel - */ - public function testTheIPRule() - { - $input = array('ip' => '192.168.1.1'); - $rules = array('ip' => 'ip'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['ip'] = '192.111'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the e-mail validation rule. - * - * @group laravel - */ - public function testTheEmailRule() - { - $input = array('email' => 'example@gmail.com'); - $rules = array('email' => 'email'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['email'] = 'blas-asok'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the URL validation rule. - * - * @group laravel - */ - public function testTheUrlRule() - { - $input = array('url' => 'http://www.google.com'); - $rules = array('url' => 'url'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['url'] = 'blas-asok'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the active URL validation rule. - * - * @group laravel - */ - public function testTheActiveUrlRule() - { - $input = array('url' => 'http://google.com'); - $rules = array('url' => 'active_url'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['url'] = 'http://asdlk-aselkaiwels.com'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the image validation rule. - * - * @group laravel - */ - public function testTheImageRule() - { - $_FILES['photo']['tmp_name'] = path('storage').'files/desert.jpg'; - $rules = array('photo' => 'image'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $_FILES['photo']['tmp_name'] = path('app').'routes.php'; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the alpha validation rule. - * - * @group laravel - */ - public function testTheAlphaRule() - { - $input = array('name' => 'TaylorOtwell'); - $rules = array('name' => 'alpha'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['name'] = 'Taylor Otwell'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the alpha_num validation rule. - * - * @group laravel - */ - public function testTheAlphaNumRule() - { - $input = array('name' => 'TaylorOtwell1'); - $rules = array('name' => 'alpha_num'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['name'] = 'Taylor Otwell'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the alpha_num validation rule. - * - * @group laravel - */ - public function testTheAlphaDashRule() - { - $input = array('name' => 'Taylor-Otwell_1'); - $rules = array('name' => 'alpha_dash'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['name'] = 'Taylor Otwell'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test the mimes validation rule. - * - * @group laravel - */ - public function testTheMimesRule() - { - $_FILES['file']['tmp_name'] = path('app').'routes.php'; - $rules = array('file' => 'mimes:php,txt'); - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $rules = array('file' => 'mimes:jpg,bmp'); - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - - $_FILES['file']['tmp_name'] = path('storage').'files/desert.jpg'; - $rules['file'] = 'mimes:jpg,bmp'; - $this->assertTrue(Validator::make($_FILES, $rules)->valid()); - - $rules['file'] = 'mimes:txt,bmp'; - $this->assertFalse(Validator::make($_FILES, $rules)->valid()); - } - - /** - * Test the unique validation rule. - * - * @group laravel - */ - public function testUniqueRule() - { - $input = array('code' => 'ZZ'); - $rules = array('code' => 'unique:validation_unique'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input = array('code' => 'AR'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - $rules = array('code' => 'unique:validation_unique,code,AR,code'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - } - - /** - * Tests the exists validation rule. - * - * @group laravel - */ - public function testExistsRule() - { - $input = array('code' => 'TX'); - $rules = array('code' => 'exists:validation_unique'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['code'] = array('TX', 'NY'); - $rules = array('code' => 'exists:validation_unique,code'); - $this->assertTrue(Validator::make($input, $rules)->valid()); - - $input['code'] = array('TX', 'XX'); - $this->assertFalse(Validator::make($input, $rules)->valid()); - - $input['code'] = 'XX'; - $this->assertFalse(Validator::make($input, $rules)->valid()); - } - - /** - * Test that the validator sets the correct messages. - * - * @group laravel - */ - public function testCorrectMessagesAreSet() - { - $lang = require path('app').'language/en/validation.php'; - - $input = array('email' => 'example-foo'); - $rules = array('name' => 'required', 'email' => 'required|email'); - $v = Validator::make($input, $rules); - $v->valid(); - $messages = $v->errors; - $this->assertInstanceOf('Laravel\\Messages', $messages); - $this->assertEquals(str_replace(':attribute', 'name', $lang['required']), $messages->first('name')); - $this->assertEquals(str_replace(':attribute', 'email', $lang['email']), $messages->first('email')); - } - - /** - * Test that custom messages are recognized. - * - * @group laravel - */ - public function testCustomMessagesAreRecognize() - { - $messages = array('required' => 'Required!'); - $rules = array('name' => 'required'); - $v = Validator::make(array(), $rules, $messages); - $v->valid(); - $this->assertEquals('Required!', $v->errors->first('name')); - - $messages['email_required'] = 'Email Required!'; - $rules = array('name' => 'required', 'email' => 'required'); - $v = Validator::make(array(), $rules, $messages); - $v->valid(); - $this->assertEquals('Required!', $v->errors->first('name')); - $this->assertEquals('Email Required!', $v->errors->first('email')); - - $rules = array('custom' => 'required'); - $v = Validator::make(array(), $rules); - $v->valid(); - $this->assertEquals('This field is required!', $v->errors->first('custom')); - } - - /** - * Test that size replacements are made on messages. - * - * @group laravel - */ - public function testNumericSizeReplacementsAreMade() - { - $lang = require path('app').'language/en/validation.php'; - - $input = array('amount' => 100); - $rules = array('amount' => 'numeric|size:80'); - $v = Validator::make($input, $rules); - $v->valid(); - $this->assertEquals(str_replace(array(':attribute', ':size'), array('amount', '80'), $lang['size']['numeric']), $v->errors->first('amount')); - - $rules = array('amount' => 'numeric|between:70,80'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min', ':max'), array('amount', '70', '80'), $lang['between']['numeric']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'numeric|min:120'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min'), array('amount', '120'), $lang['min']['numeric']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'numeric|max:20'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':max'), array('amount', '20'), $lang['max']['numeric']); - $this->assertEquals($expect, $v->errors->first('amount')); - } - - /** - * Test that string size replacements are made on messages. - * - * @group laravel - */ - public function testStringSizeReplacementsAreMade() - { - $lang = require path('app').'language/en/validation.php'; - - $input = array('amount' => '100'); - $rules = array('amount' => 'size:80'); - $v = Validator::make($input, $rules); - $v->valid(); - $this->assertEquals(str_replace(array(':attribute', ':size'), array('amount', '80'), $lang['size']['string']), $v->errors->first('amount')); - - $rules = array('amount' => 'between:70,80'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min', ':max'), array('amount', '70', '80'), $lang['between']['string']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'min:120'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min'), array('amount', '120'), $lang['min']['string']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'max:2'); - $v = Validator::make($input, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':max'), array('amount', '2'), $lang['max']['string']); - $this->assertEquals($expect, $v->errors->first('amount')); - } - - /** - * Test that string size replacements are made on messages. - * - * @group laravel - */ - public function testFileSizeReplacementsAreMade() - { - $lang = require path('app').'language/en/validation.php'; - - $_FILES['amount']['tmp_name'] = 'foo'; - $_FILES['amount']['size'] = 10000; - $rules = array('amount' => 'size:80'); - $v = Validator::make($_FILES, $rules); - $v->valid(); - $this->assertEquals(str_replace(array(':attribute', ':size'), array('amount', '80'), $lang['size']['file']), $v->errors->first('amount')); - - $rules = array('amount' => 'between:70,80'); - $v = Validator::make($_FILES, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min', ':max'), array('amount', '70', '80'), $lang['between']['file']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'min:120'); - $v = Validator::make($_FILES, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':min'), array('amount', '120'), $lang['min']['file']); - $this->assertEquals($expect, $v->errors->first('amount')); - - $rules = array('amount' => 'max:2'); - $v = Validator::make($_FILES, $rules); - $v->valid(); - $expect = str_replace(array(':attribute', ':max'), array('amount', '2'), $lang['max']['file']); - $this->assertEquals($expect, $v->errors->first('amount')); - } - - /** - * Test that values get replaced in messages. - * - * @group laravel - */ - public function testValuesGetReplaced() - { - $lang = require path('app').'language/en/validation.php'; - - $_FILES['file']['tmp_name'] = path('storage').'files/desert.jpg'; - $rules = array('file' => 'mimes:php,txt'); - $v = Validator::make($_FILES, $rules); - $v->valid(); - - $expect = str_replace(array(':attribute', ':values'), array('file', 'php, txt'), $lang['mimes']); - $this->assertEquals($expect, $v->errors->first('file')); - } - - /** - * Test custom attribute names are replaced. - * - * @group laravel - */ - public function testCustomAttributesAreReplaced() - { - $lang = require path('app').'language/en/validation.php'; - - $rules = array('test_attribute' => 'required'); - $v = Validator::make(array(), $rules); - $v->valid(); - - $expect = str_replace(':attribute', 'attribute', $lang['required']); - $this->assertEquals($expect, $v->errors->first('test_attribute')); - } - -} \ No newline at end of file diff --git a/tests/cases/view.test.php b/tests/cases/view.test.php deleted file mode 100644 index 92491b97..00000000 --- a/tests/cases/view.test.php +++ /dev/null @@ -1,237 +0,0 @@ -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(path('app').'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); - } - -} \ No newline at end of file diff --git a/tests/storage/cache/.gitignore b/tests/storage/cache/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/storage/database/application.sqlite b/tests/storage/database/application.sqlite deleted file mode 100644 index fbfc2ae0..00000000 Binary files a/tests/storage/database/application.sqlite and /dev/null differ diff --git a/tests/storage/files/desert.jpg b/tests/storage/files/desert.jpg deleted file mode 100644 index 0b88c913..00000000 Binary files a/tests/storage/files/desert.jpg and /dev/null differ diff --git a/tests/storage/logs/.gitignore b/tests/storage/logs/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/storage/sessions/.gitignore b/tests/storage/sessions/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/storage/views/.gitignore b/tests/storage/views/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php b/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php deleted file mode 100644 index 1295d0ae..00000000 --- a/vendor/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3. - * - * It is able to load classes that use either: - * - * * The technical interoperability standards for PHP 5.3 namespaces and - * class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md); - * - * * The PEAR naming convention for classes (http://pear.php.net/). - * - * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be - * looked for in a list of locations to ease the vendoring of a sub-set of - * classes for large projects. - * - * Example usage: - * - * require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - * require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; - * - * use Symfony\Component\ClassLoader\ApcUniversalClassLoader; - * - * $loader = new ApcUniversalClassLoader('apc.prefix.'); - * - * // register classes with namespaces - * $loader->registerNamespaces(array( - * 'Symfony\Component' => __DIR__.'/component', - * 'Symfony' => __DIR__.'/framework', - * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'), - * )); - * - * // register a library using the PEAR naming convention - * $loader->registerPrefixes(array( - * 'Swift_' => __DIR__.'/Swift', - * )); - * - * // activate the autoloader - * $loader->register(); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * @author Fabien Potencier - * @author Kris Wallsmith - * - * @api - */ -class ApcUniversalClassLoader extends UniversalClassLoader -{ - private $prefix; - - /** - * Constructor. - * - * @param string $prefix A prefix to create a namespace in APC - * - * @api - */ - public function __construct($prefix) - { - if (!extension_loaded('apc')) { - throw new \RuntimeException('Unable to use ApcUniversalClassLoader as APC is not enabled.'); - } - - $this->prefix = $prefix; - } - - /** - * Finds a file by class name while caching lookups to APC. - * - * @param string $class A class name to resolve to file - */ - public function findFile($class) - { - if (false === $file = apc_fetch($this->prefix.$class)) { - apc_store($this->prefix.$class, $file = parent::findFile($class)); - } - - return $file; - } -} diff --git a/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php b/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php deleted file mode 100644 index 49d3da37..00000000 --- a/vendor/Symfony/Component/ClassLoader/ClassCollectionLoader.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ClassCollectionLoader. - * - * @author Fabien Potencier - */ -class ClassCollectionLoader -{ - static private $loaded; - - /** - * Loads a list of classes and caches them in one big file. - * - * @param array $classes An array of classes to load - * @param string $cacheDir A cache directory - * @param string $name The cache name prefix - * @param Boolean $autoReload Whether to flush the cache when the cache is stale or not - * @param Boolean $adaptive Whether to remove already declared classes or not - * @param string $extension File extension of the resulting file - * - * @throws \InvalidArgumentException When class can't be loaded - */ - static public function load($classes, $cacheDir, $name, $autoReload, $adaptive = false, $extension = '.php') - { - // each $name can only be loaded once per PHP process - if (isset(self::$loaded[$name])) { - return; - } - - self::$loaded[$name] = true; - - if ($adaptive) { - // don't include already declared classes - $classes = array_diff($classes, get_declared_classes(), get_declared_interfaces()); - - // the cache is different depending on which classes are already declared - $name = $name.'-'.substr(md5(implode('|', $classes)), 0, 5); - } - - $cache = $cacheDir.'/'.$name.$extension; - - // auto-reload - $reload = false; - if ($autoReload) { - $metadata = $cacheDir.'/'.$name.$extension.'.meta'; - if (!is_file($metadata) || !is_file($cache)) { - $reload = true; - } else { - $time = filemtime($cache); - $meta = unserialize(file_get_contents($metadata)); - - if ($meta[1] != $classes) { - $reload = true; - } else { - foreach ($meta[0] as $resource) { - if (!is_file($resource) || filemtime($resource) > $time) { - $reload = true; - - break; - } - } - } - } - } - - if (!$reload && is_file($cache)) { - require_once $cache; - - return; - } - - $files = array(); - $content = ''; - foreach ($classes as $class) { - if (!class_exists($class) && !interface_exists($class) && (!function_exists('trait_exists') || !trait_exists($class))) { - throw new \InvalidArgumentException(sprintf('Unable to load class "%s"', $class)); - } - - $r = new \ReflectionClass($class); - $files[] = $r->getFileName(); - - $c = preg_replace(array('/^\s*<\?php/', '/\?>\s*$/'), '', file_get_contents($r->getFileName())); - - // add namespace declaration for global code - if (!$r->inNamespace()) { - $c = "\nnamespace\n{\n".self::stripComments($c)."\n}\n"; - } else { - $c = self::fixNamespaceDeclarations(' - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * ClassMapGenerator - * - * @author Gyula Sallai - */ -class ClassMapGenerator -{ - /** - * Generate a class map file - * - * @param array|string $dirs Directories or a single path to search in - * @param string $file The name of the class map file - */ - static public function dump($dirs, $file) - { - $dirs = (array) $dirs; - $maps = array(); - - foreach ($dirs as $dir) { - $maps = array_merge($maps, static::createMap($dir)); - } - - file_put_contents($file, sprintf('isFile()) { - continue; - } - - $path = $file->getRealPath(); - - if (pathinfo($path, PATHINFO_EXTENSION) !== 'php') { - continue; - } - - $classes = self::findClasses($path); - - foreach ($classes as $class) { - $map[$class] = $path; - } - - } - - return $map; - } - - /** - * Extract the classes in the given file - * - * @param string $path The file to check - * - * @return array The found classes - */ - static private function findClasses($path) - { - $contents = file_get_contents($path); - $tokens = token_get_all($contents); - $T_TRAIT = version_compare(PHP_VERSION, '5.4', '<') ? -1 : T_TRAIT; - - $classes = array(); - - $namespace = ''; - for ($i = 0, $max = count($tokens); $i < $max; $i++) { - $token = $tokens[$i]; - - if (is_string($token)) { - continue; - } - - $class = ''; - - switch ($token[0]) { - case T_NAMESPACE: - $namespace = ''; - // If there is a namespace, extract it - while (($t = $tokens[++$i]) && is_array($t)) { - if (in_array($t[0], array(T_STRING, T_NS_SEPARATOR))) { - $namespace .= $t[1]; - } - } - $namespace .= '\\'; - break; - case T_CLASS: - case T_INTERFACE: - case $T_TRAIT: - // Find the classname - while (($t = $tokens[++$i]) && is_array($t)) { - if (T_STRING === $t[0]) { - $class .= $t[1]; - } elseif ($class !== '' && T_WHITESPACE == $t[0]) { - break; - } - } - - $classes[] = ltrim($namespace . $class, '\\'); - break; - default: - break; - } - } - - return $classes; - } -} diff --git a/vendor/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php b/vendor/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php deleted file mode 100644 index 8cc6747f..00000000 --- a/vendor/Symfony/Component/ClassLoader/DebugUniversalClassLoader.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * Checks that the class is actually declared in the included file. - * - * @author Fabien Potencier - */ -class DebugUniversalClassLoader extends UniversalClassLoader -{ - /** - * Replaces all regular UniversalClassLoader instances by a DebugUniversalClassLoader ones. - */ - static public function enable() - { - if (!is_array($functions = spl_autoload_functions())) { - return; - } - - foreach ($functions as $function) { - spl_autoload_unregister($function); - } - - foreach ($functions as $function) { - if (is_array($function) && $function[0] instanceof UniversalClassLoader) { - $loader = new static(); - $loader->registerNamespaceFallbacks($function[0]->getNamespaceFallbacks()); - $loader->registerPrefixFallbacks($function[0]->getPrefixFallbacks()); - $loader->registerNamespaces($function[0]->getNamespaces()); - $loader->registerPrefixes($function[0]->getPrefixes()); - $loader->useIncludePath($function[0]->getUseIncludePath()); - - $function[0] = $loader; - } - - spl_autoload_register($function); - } - } - - /** - * {@inheritDoc} - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - - if (!class_exists($class, false) && !interface_exists($class, false) && (!function_exists('trait_exists') || !trait_exists($class, false))) { - throw new \RuntimeException(sprintf('The autoloader expected class "%s" to be defined in file "%s". The file was found but the class was not in it, the class name or namespace probably has a typo.', $class, $file)); - } - } - } -} diff --git a/vendor/Symfony/Component/ClassLoader/LICENSE b/vendor/Symfony/Component/ClassLoader/LICENSE deleted file mode 100644 index cdffe7ae..00000000 --- a/vendor/Symfony/Component/ClassLoader/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2012 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/Symfony/Component/ClassLoader/MapClassLoader.php b/vendor/Symfony/Component/ClassLoader/MapClassLoader.php deleted file mode 100644 index cf17d426..00000000 --- a/vendor/Symfony/Component/ClassLoader/MapClassLoader.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * A class loader that uses a mapping file to look up paths. - * - * @author Fabien Potencier - */ -class MapClassLoader -{ - private $map = array(); - - /** - * Constructor. - * - * @param array $map A map where keys are classes and values the absolute file path - */ - public function __construct(array $map) - { - $this->map = $map; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - */ - public function loadClass($class) - { - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - - if (isset($this->map[$class])) { - require $this->map[$class]; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|null The path, if found - */ - public function findFile($class) - { - if ('\\' === $class[0]) { - $class = substr($class, 1); - } - - if (isset($this->map[$class])) { - return $this->map[$class]; - } - } -} diff --git a/vendor/Symfony/Component/ClassLoader/README.md b/vendor/Symfony/Component/ClassLoader/README.md deleted file mode 100644 index bdfcb8e2..00000000 --- a/vendor/Symfony/Component/ClassLoader/README.md +++ /dev/null @@ -1,60 +0,0 @@ -ClassLoader Component -===================== - -ClassLoader loads your project classes automatically if they follow some -standard PHP conventions. - -The Universal ClassLoader is able to autoload classes that implement the PSR-0 -standard or the PEAR naming convention. - -First, register the autoloader: - - require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - - use Symfony\Component\ClassLoader\UniversalClassLoader; - - $loader = new UniversalClassLoader(); - $loader->register(); - -Then, register some namespaces with the `registerNamespace()` method: - - $loader->registerNamespace('Symfony', __DIR__.'/src'); - $loader->registerNamespace('Monolog', __DIR__.'/vendor/monolog/src'); - -The `registerNamespace()` method takes a namespace prefix and a path where to -look for the classes as arguments. - -You can also register a sub-namespaces: - - $loader->registerNamespace('Doctrine\\Common', __DIR__.'/vendor/doctrine-common/lib'); - -The order of registration is significant and the first registered namespace -takes precedence over later registered one. - -You can also register more than one path for a given namespace: - - $loader->registerNamespace('Symfony', array(__DIR__.'/src', __DIR__.'/symfony/src')); - -Alternatively, you can use the `registerNamespaces()` method to register more -than one namespace at once: - - $loader->registerNamespaces(array( - 'Symfony' => array(__DIR__.'/src', __DIR__.'/symfony/src'), - 'Doctrine\\Common' => __DIR__.'/vendor/doctrine-common/lib', - 'Doctrine' => __DIR__.'/vendor/doctrine/lib', - 'Monolog' => __DIR__.'/vendor/monolog/src', - )); - -For better performance, you can use the APC based version of the universal -class loader: - - require_once __DIR__.'/src/Symfony/Component/ClassLoader/UniversalClassLoader.php'; - require_once __DIR__.'/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php'; - - use Symfony\Component\ClassLoader\ApcUniversalClassLoader; - - $loader = new ApcUniversalClassLoader('apc.prefix.'); - -Furthermore, the component provides tools to aggregate classes into a single -file, which is especially useful to improve performance on servers that do not -provide byte caches. diff --git a/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php b/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php deleted file mode 100644 index 60f245ad..00000000 --- a/vendor/Symfony/Component/ClassLoader/UniversalClassLoader.php +++ /dev/null @@ -1,319 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\ClassLoader; - -/** - * UniversalClassLoader implements a "universal" autoloader for PHP 5.3. - * - * It is able to load classes that use either: - * - * * The technical interoperability standards for PHP 5.3 namespaces and - * class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md); - * - * * The PEAR naming convention for classes (http://pear.php.net/). - * - * Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be - * looked for in a list of locations to ease the vendoring of a sub-set of - * classes for large projects. - * - * Example usage: - * - * $loader = new UniversalClassLoader(); - * - * // register classes with namespaces - * $loader->registerNamespaces(array( - * 'Symfony\Component' => __DIR__.'/component', - * 'Symfony' => __DIR__.'/framework', - * 'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'), - * )); - * - * // register a library using the PEAR naming convention - * $loader->registerPrefixes(array( - * 'Swift_' => __DIR__.'/Swift', - * )); - * - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->useIncludePath(true); - * - * // activate the autoloader - * $loader->register(); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * @author Fabien Potencier - * - * @api - */ -class UniversalClassLoader -{ - private $namespaces = array(); - private $prefixes = array(); - private $namespaceFallbacks = array(); - private $prefixFallbacks = array(); - private $useIncludePath = false; - - /** - * Turns on searching the include for class files. Allows easy loading - * of installed PEAR packages - * - * @param Boolean $useIncludePath - */ - public function useIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return Boolean - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Gets the configured namespaces. - * - * @return array A hash with namespaces as keys and directories as values - */ - public function getNamespaces() - { - return $this->namespaces; - } - - /** - * Gets the configured class prefixes. - * - * @return array A hash with class prefixes as keys and directories as values - */ - public function getPrefixes() - { - return $this->prefixes; - } - - /** - * Gets the directory(ies) to use as a fallback for namespaces. - * - * @return array An array of directories - */ - public function getNamespaceFallbacks() - { - return $this->namespaceFallbacks; - } - - /** - * Gets the directory(ies) to use as a fallback for class prefixes. - * - * @return array An array of directories - */ - public function getPrefixFallbacks() - { - return $this->prefixFallbacks; - } - - /** - * Registers the directory to use as a fallback for namespaces. - * - * @param array $dirs An array of directories - * - * @api - */ - public function registerNamespaceFallbacks(array $dirs) - { - $this->namespaceFallbacks = $dirs; - } - - /** - * Registers a directory to use as a fallback for namespaces. - * - * @param string $dir A directory - */ - public function registerNamespaceFallback($dir) - { - $this->namespaceFallbacks[] = $dir; - } - - /** - * Registers directories to use as a fallback for class prefixes. - * - * @param array $dirs An array of directories - * - * @api - */ - public function registerPrefixFallbacks(array $dirs) - { - $this->prefixFallbacks = $dirs; - } - - /** - * Registers a directory to use as a fallback for class prefixes. - * - * @param string $dir A directory - */ - public function registerPrefixFallback($dir) - { - $this->prefixFallbacks[] = $dir; - } - - /** - * Registers an array of namespaces - * - * @param array $namespaces An array of namespaces (namespaces as keys and locations as values) - * - * @api - */ - public function registerNamespaces(array $namespaces) - { - foreach ($namespaces as $namespace => $locations) { - $this->namespaces[$namespace] = (array) $locations; - } - } - - /** - * Registers a namespace. - * - * @param string $namespace The namespace - * @param array|string $paths The location(s) of the namespace - * - * @api - */ - public function registerNamespace($namespace, $paths) - { - $this->namespaces[$namespace] = (array) $paths; - } - - /** - * Registers an array of classes using the PEAR naming convention. - * - * @param array $classes An array of classes (prefixes as keys and locations as values) - * - * @api - */ - public function registerPrefixes(array $classes) - { - foreach ($classes as $prefix => $locations) { - $this->prefixes[$prefix] = (array) $locations; - } - } - - /** - * Registers a set of classes using the PEAR naming convention. - * - * @param string $prefix The classes prefix - * @param array|string $paths The location(s) of the classes - * - * @api - */ - public function registerPrefix($prefix, $paths) - { - $this->prefixes[$prefix] = (array) $paths; - } - - /** - * Registers this instance as an autoloader. - * - * @param Boolean $prepend Whether to prepend the autoloader or not - * - * @api - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - require $file; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|null The path, if found - */ - public function findFile($class) - { - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $namespace = substr($class, 0, $pos); - $className = substr($class, $pos + 1); - $normalizedClass = str_replace('\\', DIRECTORY_SEPARATOR, $namespace).DIRECTORY_SEPARATOR.str_replace('_', DIRECTORY_SEPARATOR, $className).'.php'; - foreach ($this->namespaces as $ns => $dirs) { - if (0 !== strpos($namespace, $ns)) { - continue; - } - - foreach ($dirs as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - foreach ($this->namespaceFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - - } else { - // PEAR-like class name - $normalizedClass = str_replace('_', DIRECTORY_SEPARATOR, $class).'.php'; - foreach ($this->prefixes as $prefix => $dirs) { - if (0 !== strpos($class, $prefix)) { - continue; - } - - foreach ($dirs as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - foreach ($this->prefixFallbacks as $dir) { - $file = $dir.DIRECTORY_SEPARATOR.$normalizedClass; - if (is_file($file)) { - return $file; - } - } - } - - if ($this->useIncludePath && $file = stream_resolve_include_path($normalizedClass)) { - return $file; - } - } -} diff --git a/vendor/Symfony/Component/ClassLoader/composer.json b/vendor/Symfony/Component/ClassLoader/composer.json deleted file mode 100644 index 2608f041..00000000 --- a/vendor/Symfony/Component/ClassLoader/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "symfony/class-loader", - "type": "library", - "description": "Symfony ClassLoader Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\ClassLoader": "" } - }, - "target-dir": "Symfony/Component/ClassLoader", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -} diff --git a/vendor/Symfony/Component/Console/Application.php b/vendor/Symfony/Component/Console/Application.php deleted file mode 100644 index e04940ab..00000000 --- a/vendor/Symfony/Component/Console/Application.php +++ /dev/null @@ -1,1007 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console; - -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\ArgvInput; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\ConsoleOutputInterface; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Command\HelpCommand; -use Symfony\Component\Console\Command\ListCommand; -use Symfony\Component\Console\Helper\HelperSet; -use Symfony\Component\Console\Helper\FormatterHelper; -use Symfony\Component\Console\Helper\DialogHelper; - -/** - * An Application is the container for a collection of commands. - * - * It is the main entry point of a Console application. - * - * This class is optimized for a standard CLI environment. - * - * Usage: - * - * $app = new Application('myapp', '1.0 (stable)'); - * $app->add(new SimpleCommand()); - * $app->run(); - * - * @author Fabien Potencier - * - * @api - */ -class Application -{ - private $commands; - private $wantHelps = false; - private $runningCommand; - private $name; - private $version; - private $catchExceptions; - private $autoExit; - private $definition; - private $helperSet; - - /** - * Constructor. - * - * @param string $name The name of the application - * @param string $version The version of the application - * - * @api - */ - public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') - { - $this->name = $name; - $this->version = $version; - $this->catchExceptions = true; - $this->autoExit = true; - $this->commands = array(); - $this->helperSet = $this->getDefaultHelperSet(); - $this->definition = $this->getDefaultInputDefinition(); - - foreach ($this->getDefaultCommands() as $command) { - $this->add($command); - } - } - - /** - * Runs the current application. - * - * @param InputInterface $input An Input instance - * @param OutputInterface $output An Output instance - * - * @return integer 0 if everything went fine, or an error code - * - * @throws \Exception When doRun returns Exception - * - * @api - */ - public function run(InputInterface $input = null, OutputInterface $output = null) - { - if (null === $input) { - $input = new ArgvInput(); - } - - if (null === $output) { - $output = new ConsoleOutput(); - } - - try { - $statusCode = $this->doRun($input, $output); - } catch (\Exception $e) { - if (!$this->catchExceptions) { - throw $e; - } - - if ($output instanceof ConsoleOutputInterface) { - $this->renderException($e, $output->getErrorOutput()); - } else { - $this->renderException($e, $output); - } - $statusCode = $e->getCode(); - - $statusCode = is_numeric($statusCode) && $statusCode ? $statusCode : 1; - } - - if ($this->autoExit) { - if ($statusCode > 255) { - $statusCode = 255; - } - // @codeCoverageIgnoreStart - exit($statusCode); - // @codeCoverageIgnoreEnd - } - - return $statusCode; - } - - /** - * Runs the current application. - * - * @param InputInterface $input An Input instance - * @param OutputInterface $output An Output instance - * - * @return integer 0 if everything went fine, or an error code - */ - public function doRun(InputInterface $input, OutputInterface $output) - { - $name = $this->getCommandName($input); - - if (true === $input->hasParameterOption(array('--ansi'))) { - $output->setDecorated(true); - } elseif (true === $input->hasParameterOption(array('--no-ansi'))) { - $output->setDecorated(false); - } - - if (true === $input->hasParameterOption(array('--help', '-h'))) { - if (!$name) { - $name = 'help'; - $input = new ArrayInput(array('command' => 'help')); - } else { - $this->wantHelps = true; - } - } - - if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) { - $input->setInteractive(false); - } - - if (function_exists('posix_isatty') && $this->getHelperSet()->has('dialog')) { - $inputStream = $this->getHelperSet()->get('dialog')->getInputStream(); - if (!posix_isatty($inputStream)) { - $input->setInteractive(false); - } - } - - if (true === $input->hasParameterOption(array('--quiet', '-q'))) { - $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); - } elseif (true === $input->hasParameterOption(array('--verbose', '-v'))) { - $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); - } - - if (true === $input->hasParameterOption(array('--version', '-V'))) { - $output->writeln($this->getLongVersion()); - - return 0; - } - - if (!$name) { - $name = 'list'; - $input = new ArrayInput(array('command' => 'list')); - } - - // the command name MUST be the first element of the input - $command = $this->find($name); - - $this->runningCommand = $command; - $statusCode = $command->run($input, $output); - $this->runningCommand = null; - - return is_numeric($statusCode) ? $statusCode : 0; - } - - /** - * Set a helper set to be used with the command. - * - * @param HelperSet $helperSet The helper set - * - * @api - */ - public function setHelperSet(HelperSet $helperSet) - { - $this->helperSet = $helperSet; - } - - /** - * Get the helper set associated with the command. - * - * @return HelperSet The HelperSet instance associated with this command - * - * @api - */ - public function getHelperSet() - { - return $this->helperSet; - } - - /** - * Gets the InputDefinition related to this Application. - * - * @return InputDefinition The InputDefinition instance - */ - public function getDefinition() - { - return $this->definition; - } - - /** - * Gets the help message. - * - * @return string A help message. - */ - public function getHelp() - { - $messages = array( - $this->getLongVersion(), - '', - 'Usage:', - sprintf(" [options] command [arguments]\n"), - 'Options:', - ); - - foreach ($this->getDefinition()->getOptions() as $option) { - $messages[] = sprintf(' %-29s %s %s', - '--'.$option->getName().'', - $option->getShortcut() ? '-'.$option->getShortcut().'' : ' ', - $option->getDescription() - ); - } - - return implode(PHP_EOL, $messages); - } - - /** - * Sets whether to catch exceptions or not during commands execution. - * - * @param Boolean $boolean Whether to catch exceptions or not during commands execution - * - * @api - */ - public function setCatchExceptions($boolean) - { - $this->catchExceptions = (Boolean) $boolean; - } - - /** - * Sets whether to automatically exit after a command execution or not. - * - * @param Boolean $boolean Whether to automatically exit after a command execution or not - * - * @api - */ - public function setAutoExit($boolean) - { - $this->autoExit = (Boolean) $boolean; - } - - /** - * Gets the name of the application. - * - * @return string The application name - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the application name. - * - * @param string $name The application name - * - * @api - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * Gets the application version. - * - * @return string The application version - * - * @api - */ - public function getVersion() - { - return $this->version; - } - - /** - * Sets the application version. - * - * @param string $version The application version - * - * @api - */ - public function setVersion($version) - { - $this->version = $version; - } - - /** - * Returns the long version of the application. - * - * @return string The long application version - * - * @api - */ - public function getLongVersion() - { - if ('UNKNOWN' !== $this->getName() && 'UNKNOWN' !== $this->getVersion()) { - return sprintf('%s version %s', $this->getName(), $this->getVersion()); - } - - return 'Console Tool'; - } - - /** - * Registers a new command. - * - * @param string $name The command name - * - * @return Command The newly created command - * - * @api - */ - public function register($name) - { - return $this->add(new Command($name)); - } - - /** - * Adds an array of command objects. - * - * @param Command[] $commands An array of commands - * - * @api - */ - public function addCommands(array $commands) - { - foreach ($commands as $command) { - $this->add($command); - } - } - - /** - * Adds a command object. - * - * If a command with the same name already exists, it will be overridden. - * - * @param Command $command A Command object - * - * @return Command The registered command - * - * @api - */ - public function add(Command $command) - { - $command->setApplication($this); - - if (!$command->isEnabled()) { - $command->setApplication(null); - - return; - } - - $this->commands[$command->getName()] = $command; - - foreach ($command->getAliases() as $alias) { - $this->commands[$alias] = $command; - } - - return $command; - } - - /** - * Returns a registered command by name or alias. - * - * @param string $name The command name or alias - * - * @return Command A Command object - * - * @throws \InvalidArgumentException When command name given does not exist - * - * @api - */ - public function get($name) - { - if (!isset($this->commands[$name])) { - throw new \InvalidArgumentException(sprintf('The command "%s" does not exist.', $name)); - } - - $command = $this->commands[$name]; - - if ($this->wantHelps) { - $this->wantHelps = false; - - $helpCommand = $this->get('help'); - $helpCommand->setCommand($command); - - return $helpCommand; - } - - return $command; - } - - /** - * Returns true if the command exists, false otherwise. - * - * @param string $name The command name or alias - * - * @return Boolean true if the command exists, false otherwise - * - * @api - */ - public function has($name) - { - return isset($this->commands[$name]); - } - - /** - * Returns an array of all unique namespaces used by currently registered commands. - * - * It does not returns the global namespace which always exists. - * - * @return array An array of namespaces - */ - public function getNamespaces() - { - $namespaces = array(); - foreach ($this->commands as $command) { - $namespaces[] = $this->extractNamespace($command->getName()); - - foreach ($command->getAliases() as $alias) { - $namespaces[] = $this->extractNamespace($alias); - } - } - - return array_values(array_unique(array_filter($namespaces))); - } - - /** - * Finds a registered namespace by a name or an abbreviation. - * - * @param string $namespace A namespace or abbreviation to search for - * - * @return string A registered namespace - * - * @throws \InvalidArgumentException When namespace is incorrect or ambiguous - */ - public function findNamespace($namespace) - { - $allNamespaces = array(); - foreach ($this->getNamespaces() as $n) { - $allNamespaces[$n] = explode(':', $n); - } - - $found = array(); - foreach (explode(':', $namespace) as $i => $part) { - $abbrevs = static::getAbbreviations(array_unique(array_values(array_filter(array_map(function ($p) use ($i) { return isset($p[$i]) ? $p[$i] : ''; }, $allNamespaces))))); - - if (!isset($abbrevs[$part])) { - $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace); - - if (1 <= $i) { - $part = implode(':', $found).':'.$part; - } - - if ($alternatives = $this->findAlternativeNamespace($part, $abbrevs)) { - $message .= "\n\nDid you mean one of these?\n "; - $message .= implode("\n ", $alternatives); - } - - throw new \InvalidArgumentException($message); - } - - if (count($abbrevs[$part]) > 1) { - throw new \InvalidArgumentException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions($abbrevs[$part]))); - } - - $found[] = $abbrevs[$part][0]; - } - - return implode(':', $found); - } - - /** - * Finds a command by name or alias. - * - * Contrary to get, this command tries to find the best - * match if you give it an abbreviation of a name or alias. - * - * @param string $name A command name or a command alias - * - * @return Command A Command instance - * - * @throws \InvalidArgumentException When command name is incorrect or ambiguous - * - * @api - */ - public function find($name) - { - // namespace - $namespace = ''; - $searchName = $name; - if (false !== $pos = strrpos($name, ':')) { - $namespace = $this->findNamespace(substr($name, 0, $pos)); - $searchName = $namespace.substr($name, $pos); - } - - // name - $commands = array(); - foreach ($this->commands as $command) { - if ($this->extractNamespace($command->getName()) == $namespace) { - $commands[] = $command->getName(); - } - } - - $abbrevs = static::getAbbreviations(array_unique($commands)); - if (isset($abbrevs[$searchName]) && 1 == count($abbrevs[$searchName])) { - return $this->get($abbrevs[$searchName][0]); - } - - if (isset($abbrevs[$searchName]) && count($abbrevs[$searchName]) > 1) { - $suggestions = $this->getAbbreviationSuggestions($abbrevs[$searchName]); - - throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions)); - } - - // aliases - $aliases = array(); - foreach ($this->commands as $command) { - foreach ($command->getAliases() as $alias) { - if ($this->extractNamespace($alias) == $namespace) { - $aliases[] = $alias; - } - } - } - - $aliases = static::getAbbreviations(array_unique($aliases)); - if (!isset($aliases[$searchName])) { - $message = sprintf('Command "%s" is not defined.', $name); - - if ($alternatives = $this->findAlternativeCommands($searchName, $abbrevs)) { - $message .= "\n\nDid you mean one of these?\n "; - $message .= implode("\n ", $alternatives); - } - - throw new \InvalidArgumentException($message); - } - - if (count($aliases[$searchName]) > 1) { - throw new \InvalidArgumentException(sprintf('Command "%s" is ambiguous (%s).', $name, $this->getAbbreviationSuggestions($aliases[$searchName]))); - } - - return $this->get($aliases[$searchName][0]); - } - - /** - * Gets the commands (registered in the given namespace if provided). - * - * The array keys are the full names and the values the command instances. - * - * @param string $namespace A namespace name - * - * @return array An array of Command instances - * - * @api - */ - public function all($namespace = null) - { - if (null === $namespace) { - return $this->commands; - } - - $commands = array(); - foreach ($this->commands as $name => $command) { - if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) { - $commands[$name] = $command; - } - } - - return $commands; - } - - /** - * Returns an array of possible abbreviations given a set of names. - * - * @param array $names An array of names - * - * @return array An array of abbreviations - */ - static public function getAbbreviations($names) - { - $abbrevs = array(); - foreach ($names as $name) { - for ($len = strlen($name) - 1; $len > 0; --$len) { - $abbrev = substr($name, 0, $len); - if (!isset($abbrevs[$abbrev])) { - $abbrevs[$abbrev] = array($name); - } else { - $abbrevs[$abbrev][] = $name; - } - } - } - - // Non-abbreviations always get entered, even if they aren't unique - foreach ($names as $name) { - $abbrevs[$name] = array($name); - } - - return $abbrevs; - } - - /** - * Returns a text representation of the Application. - * - * @param string $namespace An optional namespace name - * @param boolean $raw Whether to return raw command list - * - * @return string A string representing the Application - */ - public function asText($namespace = null, $raw = false) - { - $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands; - - $width = 0; - foreach ($commands as $command) { - $width = strlen($command->getName()) > $width ? strlen($command->getName()) : $width; - } - $width += 2; - - if ($raw) { - $messages = array(); - foreach ($this->sortCommands($commands) as $space => $commands) { - foreach ($commands as $name => $command) { - $messages[] = sprintf("%-${width}s %s", $name, $command->getDescription()); - } - } - - return implode(PHP_EOL, $messages); - } - - $messages = array($this->getHelp(), ''); - if ($namespace) { - $messages[] = sprintf("Available commands for the \"%s\" namespace:", $namespace); - } else { - $messages[] = 'Available commands:'; - } - - // add commands by namespace - foreach ($this->sortCommands($commands) as $space => $commands) { - if (!$namespace && '_global' !== $space) { - $messages[] = ''.$space.''; - } - - foreach ($commands as $name => $command) { - $messages[] = sprintf(" %-${width}s %s", $name, $command->getDescription()); - } - } - - return implode(PHP_EOL, $messages); - } - - /** - * Returns an XML representation of the Application. - * - * @param string $namespace An optional namespace name - * @param Boolean $asDom Whether to return a DOM or an XML string - * - * @return string|DOMDocument An XML string representing the Application - */ - public function asXml($namespace = null, $asDom = false) - { - $commands = $namespace ? $this->all($this->findNamespace($namespace)) : $this->commands; - - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->appendChild($xml = $dom->createElement('symfony')); - - $xml->appendChild($commandsXML = $dom->createElement('commands')); - - if ($namespace) { - $commandsXML->setAttribute('namespace', $namespace); - } else { - $namespacesXML = $dom->createElement('namespaces'); - $xml->appendChild($namespacesXML); - } - - // add commands by namespace - foreach ($this->sortCommands($commands) as $space => $commands) { - if (!$namespace) { - $namespaceArrayXML = $dom->createElement('namespace'); - $namespacesXML->appendChild($namespaceArrayXML); - $namespaceArrayXML->setAttribute('id', $space); - } - - foreach ($commands as $name => $command) { - if ($name !== $command->getName()) { - continue; - } - - if (!$namespace) { - $commandXML = $dom->createElement('command'); - $namespaceArrayXML->appendChild($commandXML); - $commandXML->appendChild($dom->createTextNode($name)); - } - - $node = $command->asXml(true)->getElementsByTagName('command')->item(0); - $node = $dom->importNode($node, true); - - $commandsXML->appendChild($node); - } - } - - return $asDom ? $dom : $dom->saveXml(); - } - - /** - * Renders a catched exception. - * - * @param Exception $e An exception instance - * @param OutputInterface $output An OutputInterface instance - */ - public function renderException($e, $output) - { - $strlen = function ($string) { - if (!function_exists('mb_strlen')) { - return strlen($string); - } - - if (false === $encoding = mb_detect_encoding($string)) { - return strlen($string); - } - - return mb_strlen($string, $encoding); - }; - - do { - $title = sprintf(' [%s] ', get_class($e)); - $len = $strlen($title); - $lines = array(); - foreach (explode("\n", $e->getMessage()) as $line) { - $lines[] = sprintf(' %s ', $line); - $len = max($strlen($line) + 4, $len); - } - - $messages = array(str_repeat(' ', $len), $title.str_repeat(' ', $len - $strlen($title))); - - foreach ($lines as $line) { - $messages[] = $line.str_repeat(' ', $len - $strlen($line)); - } - - $messages[] = str_repeat(' ', $len); - - $output->writeln(""); - $output->writeln(""); - foreach ($messages as $message) { - $output->writeln(''.$message.''); - } - $output->writeln(""); - $output->writeln(""); - - if (OutputInterface::VERBOSITY_VERBOSE === $output->getVerbosity()) { - $output->writeln('Exception trace:'); - - // exception related properties - $trace = $e->getTrace(); - array_unshift($trace, array( - 'function' => '', - 'file' => $e->getFile() != null ? $e->getFile() : 'n/a', - 'line' => $e->getLine() != null ? $e->getLine() : 'n/a', - 'args' => array(), - )); - - for ($i = 0, $count = count($trace); $i < $count; $i++) { - $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : ''; - $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : ''; - $function = $trace[$i]['function']; - $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a'; - $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a'; - - $output->writeln(sprintf(' %s%s%s() at %s:%s', $class, $type, $function, $file, $line)); - } - - $output->writeln(""); - $output->writeln(""); - } - } while ($e = $e->getPrevious()); - - if (null !== $this->runningCommand) { - $output->writeln(sprintf('%s', sprintf($this->runningCommand->getSynopsis(), $this->getName()))); - $output->writeln(""); - $output->writeln(""); - } - } - - /** - * Gets the name of the command based on input. - * - * @param InputInterface $input The input interface - * - * @return string The command name - */ - protected function getCommandName(InputInterface $input) - { - return $input->getFirstArgument('command'); - } - - /** - * Gets the default input definition. - * - * @return InputDefinition An InputDefinition instance - */ - protected function getDefaultInputDefinition() - { - return new InputDefinition(array( - new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), - - new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), - new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'), - new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'), - new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'), - new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'), - new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'), - new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'), - )); - } - - /** - * Gets the default commands that should always be available. - * - * @return array An array of default Command instances - */ - protected function getDefaultCommands() - { - return array(new HelpCommand(), new ListCommand()); - } - - /** - * Gets the default helper set with the helpers that should always be available. - * - * @return HelperSet A HelperSet instance - */ - protected function getDefaultHelperSet() - { - return new HelperSet(array( - new FormatterHelper(), - new DialogHelper(), - )); - } - - /** - * Sorts commands in alphabetical order. - * - * @param array $commands An associative array of commands to sort - * - * @return array A sorted array of commands - */ - private function sortCommands($commands) - { - $namespacedCommands = array(); - foreach ($commands as $name => $command) { - $key = $this->extractNamespace($name, 1); - if (!$key) { - $key = '_global'; - } - - $namespacedCommands[$key][$name] = $command; - } - ksort($namespacedCommands); - - foreach ($namespacedCommands as &$commands) { - ksort($commands); - } - - return $namespacedCommands; - } - - /** - * Returns abbreviated suggestions in string format. - * - * @param array $abbrevs Abbreviated suggestions to convert - * - * @return string A formatted string of abbreviated suggestions - */ - private function getAbbreviationSuggestions($abbrevs) - { - return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : ''); - } - - /** - * Returns the namespace part of the command name. - * - * @param string $name The full name of the command - * @param string $limit The maximum number of parts of the namespace - * - * @return string The namespace of the command - */ - private function extractNamespace($name, $limit = null) - { - $parts = explode(':', $name); - array_pop($parts); - - return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit)); - } - - /** - * Finds alternative commands of $name - * - * @param string $name The full name of the command - * @param array $abbrevs The abbreviations - * - * @return array A sorted array of similar commands - */ - private function findAlternativeCommands($name, $abbrevs) - { - $callback = function($item) { - return $item->getName(); - }; - - return $this->findAlternatives($name, $this->commands, $abbrevs, $callback); - } - - /** - * Finds alternative namespace of $name - * - * @param string $name The full name of the namespace - * @param array $abbrevs The abbreviations - * - * @return array A sorted array of similar namespace - */ - private function findAlternativeNamespace($name, $abbrevs) - { - return $this->findAlternatives($name, $this->getNamespaces(), $abbrevs); - } - - /** - * Finds alternative of $name among $collection, - * if nothing is found in $collection, try in $abbrevs - * - * @param string $name The string - * @param array|Traversable $collection The collecion - * @param array $abbrevs The abbreviations - * @param Closure|string|array $callback The callable to transform collection item before comparison - * - * @return array A sorted array of similar string - */ - private function findAlternatives($name, $collection, $abbrevs, $callback = null) { - $alternatives = array(); - - foreach ($collection as $item) { - if (null !== $callback) { - $item = call_user_func($callback, $item); - } - - $lev = levenshtein($name, $item); - if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) { - $alternatives[$item] = $lev; - } - } - - if (!$alternatives) { - foreach ($abbrevs as $key => $values) { - $lev = levenshtein($name, $key); - if ($lev <= strlen($name) / 3 || false !== strpos($key, $name)) { - foreach ($values as $value) { - $alternatives[$value] = $lev; - } - } - } - } - - asort($alternatives); - - return array_keys($alternatives); - } -} diff --git a/vendor/Symfony/Component/Console/Command/Command.php b/vendor/Symfony/Component/Console/Command/Command.php deleted file mode 100644 index 033a95c7..00000000 --- a/vendor/Symfony/Component/Console/Command/Command.php +++ /dev/null @@ -1,612 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Command; - -use Symfony\Component\Console\Input\InputDefinition; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Helper\HelperSet; - -/** - * Base class for all commands. - * - * @author Fabien Potencier - * - * @api - */ -class Command -{ - private $application; - private $name; - private $aliases; - private $definition; - private $help; - private $description; - private $ignoreValidationErrors; - private $applicationDefinitionMerged; - private $code; - private $synopsis; - private $helperSet; - - /** - * Constructor. - * - * @param string $name The name of the command - * - * @throws \LogicException When the command name is empty - * - * @api - */ - public function __construct($name = null) - { - $this->definition = new InputDefinition(); - $this->ignoreValidationErrors = false; - $this->applicationDefinitionMerged = false; - $this->aliases = array(); - - if (null !== $name) { - $this->setName($name); - } - - $this->configure(); - - if (!$this->name) { - throw new \LogicException('The command name cannot be empty.'); - } - } - - /** - * Ignores validation errors. - * - * This is mainly useful for the help command. - */ - public function ignoreValidationErrors() - { - $this->ignoreValidationErrors = true; - } - - /** - * Sets the application instance for this command. - * - * @param Application $application An Application instance - * - * @api - */ - public function setApplication(Application $application = null) - { - $this->application = $application; - if ($application) { - $this->setHelperSet($application->getHelperSet()); - } else { - $this->helperSet = null; - } - } - - /** - * Sets the helper set. - * - * @param HelperSet $helperSet A HelperSet instance - */ - public function setHelperSet(HelperSet $helperSet) - { - $this->helperSet = $helperSet; - } - - /** - * Gets the helper set. - * - * @return HelperSet A HelperSet instance - */ - public function getHelperSet() - { - return $this->helperSet; - } - - /** - * Gets the application instance for this command. - * - * @return Application An Application instance - * - * @api - */ - public function getApplication() - { - return $this->application; - } - - /** - * Checks whether the command is enabled or not in the current environment - * - * Override this to check for x or y and return false if the command can not - * run properly under the current conditions. - * - * @return Boolean - */ - public function isEnabled() - { - return true; - } - - /** - * Configures the current command. - */ - protected function configure() - { - } - - /** - * Executes the current command. - * - * This method is not abstract because you can use this class - * as a concrete class. In this case, instead of defining the - * execute() method, you set the code to execute by passing - * a Closure to the setCode() method. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - * - * @return integer 0 if everything went fine, or an error code - * - * @throws \LogicException When this abstract method is not implemented - * @see setCode() - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - throw new \LogicException('You must override the execute() method in the concrete command class.'); - } - - /** - * Interacts with the user. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - */ - protected function interact(InputInterface $input, OutputInterface $output) - { - } - - /** - * Initializes the command just after the input has been validated. - * - * This is mainly useful when a lot of commands extends one main command - * where some things need to be initialized based on the input arguments and options. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - */ - protected function initialize(InputInterface $input, OutputInterface $output) - { - } - - /** - * Runs the command. - * - * The code to execute is either defined directly with the - * setCode() method or by overriding the execute() method - * in a sub-class. - * - * @param InputInterface $input An InputInterface instance - * @param OutputInterface $output An OutputInterface instance - * - * @see setCode() - * @see execute() - * - * @api - */ - public function run(InputInterface $input, OutputInterface $output) - { - // force the creation of the synopsis before the merge with the app definition - $this->getSynopsis(); - - // add the application arguments and options - $this->mergeApplicationDefinition(); - - // bind the input against the command specific arguments/options - try { - $input->bind($this->definition); - } catch (\Exception $e) { - if (!$this->ignoreValidationErrors) { - throw $e; - } - } - - $this->initialize($input, $output); - - if ($input->isInteractive()) { - $this->interact($input, $output); - } - - $input->validate(); - - if ($this->code) { - return call_user_func($this->code, $input, $output); - } - - return $this->execute($input, $output); - } - - /** - * Sets the code to execute when running this command. - * - * If this method is used, it overrides the code defined - * in the execute() method. - * - * @param \Closure $code A \Closure - * - * @return Command The current instance - * - * @see execute() - * - * @api - */ - public function setCode(\Closure $code) - { - $this->code = $code; - - return $this; - } - - /** - * Merges the application definition with the command definition. - */ - private function mergeApplicationDefinition() - { - if (null === $this->application || true === $this->applicationDefinitionMerged) { - return; - } - - $currentArguments = $this->definition->getArguments(); - $this->definition->setArguments($this->application->getDefinition()->getArguments()); - $this->definition->addArguments($currentArguments); - - $this->definition->addOptions($this->application->getDefinition()->getOptions()); - - $this->applicationDefinitionMerged = true; - } - - /** - * Sets an array of argument and option instances. - * - * @param array|InputDefinition $definition An array of argument and option instances or a definition instance - * - * @return Command The current instance - * - * @api - */ - public function setDefinition($definition) - { - if ($definition instanceof InputDefinition) { - $this->definition = $definition; - } else { - $this->definition->setDefinition($definition); - } - - $this->applicationDefinitionMerged = false; - - return $this; - } - - /** - * Gets the InputDefinition attached to this Command. - * - * @return InputDefinition An InputDefinition instance - * - * @api - */ - public function getDefinition() - { - return $this->definition; - } - - /** - * Gets the InputDefinition to be used to create XML and Text representations of this Command. - * - * Can be overridden to provide the original command representation when it would otherwise - * be changed by merging with the application InputDefinition. - * - * @return InputDefinition An InputDefinition instance - */ - protected function getNativeDefinition() - { - return $this->getDefinition(); - } - - /** - * Adds an argument. - * - * @param string $name The argument name - * @param integer $mode The argument mode: InputArgument::REQUIRED or InputArgument::OPTIONAL - * @param string $description A description text - * @param mixed $default The default value (for InputArgument::OPTIONAL mode only) - * - * @return Command The current instance - * - * @api - */ - public function addArgument($name, $mode = null, $description = '', $default = null) - { - $this->definition->addArgument(new InputArgument($name, $mode, $description, $default)); - - return $this; - } - - /** - * Adds an option. - * - * @param string $name The option name - * @param string $shortcut The shortcut (can be null) - * @param integer $mode The option mode: One of the InputOption::VALUE_* constants - * @param string $description A description text - * @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE) - * - * @return Command The current instance - * - * @api - */ - public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null) - { - $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default)); - - return $this; - } - - /** - * Sets the name of the command. - * - * This method can set both the namespace and the name if - * you separate them by a colon (:) - * - * $command->setName('foo:bar'); - * - * @param string $name The command name - * - * @return Command The current instance - * - * @throws \InvalidArgumentException When command name given is empty - * - * @api - */ - public function setName($name) - { - $this->validateName($name); - - $this->name = $name; - - return $this; - } - - /** - * Returns the command name. - * - * @return string The command name - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the description for the command. - * - * @param string $description The description for the command - * - * @return Command The current instance - * - * @api - */ - public function setDescription($description) - { - $this->description = $description; - - return $this; - } - - /** - * Returns the description for the command. - * - * @return string The description for the command - * - * @api - */ - public function getDescription() - { - return $this->description; - } - - /** - * Sets the help for the command. - * - * @param string $help The help for the command - * - * @return Command The current instance - * - * @api - */ - public function setHelp($help) - { - $this->help = $help; - - return $this; - } - - /** - * Returns the help for the command. - * - * @return string The help for the command - * - * @api - */ - public function getHelp() - { - return $this->help; - } - - /** - * Returns the processed help for the command replacing the %command.name% and - * %command.full_name% patterns with the real values dynamically. - * - * @return string The processed help for the command - */ - public function getProcessedHelp() - { - $name = $this->name; - - $placeholders = array( - '%command.name%', - '%command.full_name%' - ); - $replacements = array( - $name, - $_SERVER['PHP_SELF'].' '.$name - ); - - return str_replace($placeholders, $replacements, $this->getHelp()); - } - - /** - * Sets the aliases for the command. - * - * @param array $aliases An array of aliases for the command - * - * @return Command The current instance - * - * @api - */ - public function setAliases($aliases) - { - foreach ($aliases as $alias) { - $this->validateName($alias); - } - - $this->aliases = $aliases; - - return $this; - } - - /** - * Returns the aliases for the command. - * - * @return array An array of aliases for the command - * - * @api - */ - public function getAliases() - { - return $this->aliases; - } - - /** - * Returns the synopsis for the command. - * - * @return string The synopsis - */ - public function getSynopsis() - { - if (null === $this->synopsis) { - $this->synopsis = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis())); - } - - return $this->synopsis; - } - - /** - * Gets a helper instance by name. - * - * @param string $name The helper name - * - * @return mixed The helper value - * - * @throws \InvalidArgumentException if the helper is not defined - * - * @api - */ - public function getHelper($name) - { - return $this->helperSet->get($name); - } - - /** - * Returns a text representation of the command. - * - * @return string A string representing the command - */ - public function asText() - { - $messages = array( - 'Usage:', - ' '.$this->getSynopsis(), - '', - ); - - if ($this->getAliases()) { - $messages[] = 'Aliases: '.implode(', ', $this->getAliases()).''; - } - - $messages[] = $this->getNativeDefinition()->asText(); - - if ($help = $this->getProcessedHelp()) { - $messages[] = 'Help:'; - $messages[] = ' '.str_replace("\n", "\n ", $help)."\n"; - } - - return implode("\n", $messages); - } - - /** - * Returns an XML representation of the command. - * - * @param Boolean $asDom Whether to return a DOM or an XML string - * - * @return string|DOMDocument An XML string representing the command - */ - public function asXml($asDom = false) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->appendChild($commandXML = $dom->createElement('command')); - $commandXML->setAttribute('id', $this->name); - $commandXML->setAttribute('name', $this->name); - - $commandXML->appendChild($usageXML = $dom->createElement('usage')); - $usageXML->appendChild($dom->createTextNode(sprintf($this->getSynopsis(), ''))); - - $commandXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getDescription()))); - - $commandXML->appendChild($helpXML = $dom->createElement('help')); - $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $this->getProcessedHelp()))); - - $commandXML->appendChild($aliasesXML = $dom->createElement('aliases')); - foreach ($this->getAliases() as $alias) { - $aliasesXML->appendChild($aliasXML = $dom->createElement('alias')); - $aliasXML->appendChild($dom->createTextNode($alias)); - } - - $definition = $this->getNativeDefinition()->asXml(true); - $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('arguments')->item(0), true)); - $commandXML->appendChild($dom->importNode($definition->getElementsByTagName('options')->item(0), true)); - - return $asDom ? $dom : $dom->saveXml(); - } - - private function validateName($name) - { - if (!preg_match('/^[^\:]+(\:[^\:]+)*$/', $name)) { - throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); - } - } -} diff --git a/vendor/Symfony/Component/Console/Command/HelpCommand.php b/vendor/Symfony/Component/Console/Command/HelpCommand.php deleted file mode 100644 index 93c81045..00000000 --- a/vendor/Symfony/Component/Console/Command/HelpCommand.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Command; - -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; -use Symfony\Component\Console\Command\Command; - -/** - * HelpCommand displays the help for a given command. - * - * @author Fabien Potencier - */ -class HelpCommand extends Command -{ - private $command; - - /** - * {@inheritdoc} - */ - protected function configure() - { - $this->ignoreValidationErrors(); - - $this - ->setName('help') - ->setDefinition(array( - new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'), - new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), - )) - ->setDescription('Displays help for a command') - ->setHelp(<<%command.name% command displays help for a given command: - - php %command.full_name% list - -You can also output the help as XML by using the --xml option: - - php %command.full_name% --xml list -EOF - ) - ; - } - - /** - * Sets the command - * - * @param Command $command The command to set - */ - public function setCommand(Command $command) - { - $this->command = $command; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - if (null === $this->command) { - $this->command = $this->getApplication()->get($input->getArgument('command_name')); - } - - if ($input->getOption('xml')) { - $output->writeln($this->command->asXml(), OutputInterface::OUTPUT_RAW); - } else { - $output->writeln($this->command->asText()); - } - - $this->command = null; - } -} diff --git a/vendor/Symfony/Component/Console/Command/ListCommand.php b/vendor/Symfony/Component/Console/Command/ListCommand.php deleted file mode 100644 index 032de16c..00000000 --- a/vendor/Symfony/Component/Console/Command/ListCommand.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Command; - -use Symfony\Component\Console\Input\InputArgument; -use Symfony\Component\Console\Input\InputOption; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\Output; -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputDefinition; - -/** - * ListCommand displays the list of all available commands for the application. - * - * @author Fabien Potencier - */ -class ListCommand extends Command -{ - /** - * {@inheritdoc} - */ - protected function configure() - { - $this - ->setName('list') - ->setDefinition($this->createDefinition()) - ->setDescription('Lists commands') - ->setHelp(<<%command.name% command lists all commands: - - php %command.full_name% - -You can also display the commands for a specific namespace: - - php %command.full_name% test - -You can also output the information as XML by using the --xml option: - - php %command.full_name% --xml - -It's also possible to get raw list of commands (useful for embedding command runner): - - php %command.full_name% --raw -EOF - ) - ; - } - - /** - * {@inheritdoc} - */ - protected function getNativeDefinition() - { - return $this->createDefinition(); - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output) - { - if ($input->getOption('xml')) { - $output->writeln($this->getApplication()->asXml($input->getArgument('namespace')), OutputInterface::OUTPUT_RAW); - } else { - $output->writeln($this->getApplication()->asText($input->getArgument('namespace'), $input->getOption('raw'))); - } - } - - private function createDefinition() - { - return new InputDefinition(array( - new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'), - new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'), - new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'), - )); - } -} diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php deleted file mode 100644 index 8d60c74f..00000000 --- a/vendor/Symfony/Component/Console/Formatter/OutputFormatter.php +++ /dev/null @@ -1,192 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Formatter; - -/** - * Formatter class for console output. - * - * @author Konstantin Kudryashov - * - * @api - */ -class OutputFormatter implements OutputFormatterInterface -{ - /** - * The pattern to phrase the format. - */ - const FORMAT_PATTERN = '#<([a-z][a-z0-9_=;-]+)>(.*?)#is'; - - private $decorated; - private $styles = array(); - - /** - * Initializes console output formatter. - * - * @param Boolean $decorated Whether this formatter should actually decorate strings - * @param array $styles Array of "name => FormatterStyle" instances - * - * @api - */ - public function __construct($decorated = null, array $styles = array()) - { - $this->decorated = (Boolean) $decorated; - - $this->setStyle('error', new OutputFormatterStyle('white', 'red')); - $this->setStyle('info', new OutputFormatterStyle('green')); - $this->setStyle('comment', new OutputFormatterStyle('yellow')); - $this->setStyle('question', new OutputFormatterStyle('black', 'cyan')); - - foreach ($styles as $name => $style) { - $this->setStyle($name, $style); - } - } - - /** - * Sets the decorated flag. - * - * @param Boolean $decorated Whether to decorate the messages or not - * - * @api - */ - public function setDecorated($decorated) - { - $this->decorated = (Boolean) $decorated; - } - - /** - * Gets the decorated flag. - * - * @return Boolean true if the output will decorate messages, false otherwise - * - * @api - */ - public function isDecorated() - { - return $this->decorated; - } - - /** - * Sets a new style. - * - * @param string $name The style name - * @param OutputFormatterStyleInterface $style The style instance - * - * @api - */ - public function setStyle($name, OutputFormatterStyleInterface $style) - { - $this->styles[strtolower($name)] = $style; - } - - /** - * Checks if output formatter has style with specified name. - * - * @param string $name - * - * @return Boolean - * - * @api - */ - public function hasStyle($name) - { - return isset($this->styles[strtolower($name)]); - } - - /** - * Gets style options from style with specified name. - * - * @param string $name - * - * @return OutputFormatterStyleInterface - * - * @throws \InvalidArgumentException When style isn't defined - * - * @api - */ - public function getStyle($name) - { - if (!$this->hasStyle($name)) { - throw new \InvalidArgumentException('Undefined style: '.$name); - } - - return $this->styles[strtolower($name)]; - } - - /** - * Formats a message according to the given styles. - * - * @param string $message The message to style - * - * @return string The styled message - * - * @api - */ - public function format($message) - { - return preg_replace_callback(self::FORMAT_PATTERN, array($this, 'replaceStyle'), $message); - } - - /** - * Replaces style of the output. - * - * @param array $match - * - * @return string The replaced style - */ - private function replaceStyle($match) - { - if (!$this->isDecorated()) { - return $match[2]; - } - - if (isset($this->styles[strtolower($match[1])])) { - $style = $this->styles[strtolower($match[1])]; - } else { - $style = $this->createStyleFromString($match[1]); - - if (false === $style) { - return $match[0]; - } - } - - return $style->apply($this->format($match[2])); - } - - /** - * Tries to create new style instance from string. - * - * @param string $string - * - * @return Symfony\Component\Console\Format\FormatterStyle|Boolean false if string is not format string - */ - private function createStyleFromString($string) - { - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) { - return false; - } - - $style = new OutputFormatterStyle(); - foreach ($matches as $match) { - array_shift($match); - - if ('fg' == $match[0]) { - $style->setForeground($match[1]); - } elseif ('bg' == $match[0]) { - $style->setBackground($match[1]); - } else { - $style->setOption($match[1]); - } - } - - return $style; - } -} diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php deleted file mode 100644 index f14657ce..00000000 --- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterInterface.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Formatter; - -/** - * Formatter interface for console output. - * - * @author Konstantin Kudryashov - * - * @api - */ -interface OutputFormatterInterface -{ - /** - * Sets the decorated flag. - * - * @param Boolean $decorated Whether to decorate the messages or not - * - * @api - */ - function setDecorated($decorated); - - /** - * Gets the decorated flag. - * - * @return Boolean true if the output will decorate messages, false otherwise - * - * @api - */ - function isDecorated(); - - /** - * Sets a new style. - * - * @param string $name The style name - * @param OutputFormatterStyleInterface $style The style instance - * - * @api - */ - function setStyle($name, OutputFormatterStyleInterface $style); - - /** - * Checks if output formatter has style with specified name. - * - * @param string $name - * - * @return Boolean - * - * @api - */ - function hasStyle($name); - - /** - * Gets style options from style with specified name. - * - * @param string $name - * - * @return OutputFormatterStyleInterface - * - * @api - */ - function getStyle($name); - - /** - * Formats a message according to the given styles. - * - * @param string $message The message to style - * - * @return string The styled message - * - * @api - */ - function format($message); -} diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php deleted file mode 100644 index dc88f2a8..00000000 --- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyle.php +++ /dev/null @@ -1,218 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Formatter; - -/** - * Formatter style class for defining styles. - * - * @author Konstantin Kudryashov - * - * @api - */ -class OutputFormatterStyle implements OutputFormatterStyleInterface -{ - static private $availableForegroundColors = array( - 'black' => 30, - 'red' => 31, - 'green' => 32, - 'yellow' => 33, - 'blue' => 34, - 'magenta' => 35, - 'cyan' => 36, - 'white' => 37 - ); - static private $availableBackgroundColors = array( - 'black' => 40, - 'red' => 41, - 'green' => 42, - 'yellow' => 43, - 'blue' => 44, - 'magenta' => 45, - 'cyan' => 46, - 'white' => 47 - ); - static private $availableOptions = array( - 'bold' => 1, - 'underscore' => 4, - 'blink' => 5, - 'reverse' => 7, - 'conceal' => 8 - ); - - private $foreground; - private $background; - private $options = array(); - - /** - * Initializes output formatter style. - * - * @param string $foreground style foreground color name - * @param string $background style background color name - * @param array $options style options - * - * @api - */ - public function __construct($foreground = null, $background = null, array $options = array()) - { - if (null !== $foreground) { - $this->setForeground($foreground); - } - if (null !== $background) { - $this->setBackground($background); - } - if (count($options)) { - $this->setOptions($options); - } - } - - /** - * Sets style foreground color. - * - * @param string $color color name - * - * @throws \InvalidArgumentException When the color name isn't defined - * - * @api - */ - public function setForeground($color = null) - { - if (null === $color) { - $this->foreground = null; - - return; - } - - if (!isset(static::$availableForegroundColors[$color])) { - throw new \InvalidArgumentException(sprintf( - 'Invalid foreground color specified: "%s". Expected one of (%s)', - $color, - implode(', ', array_keys(static::$availableForegroundColors)) - )); - } - - $this->foreground = static::$availableForegroundColors[$color]; - } - - /** - * Sets style background color. - * - * @param string $color color name - * - * @throws \InvalidArgumentException When the color name isn't defined - * - * @api - */ - public function setBackground($color = null) - { - if (null === $color) { - $this->background = null; - - return; - } - - if (!isset(static::$availableBackgroundColors[$color])) { - throw new \InvalidArgumentException(sprintf( - 'Invalid background color specified: "%s". Expected one of (%s)', - $color, - implode(', ', array_keys(static::$availableBackgroundColors)) - )); - } - - $this->background = static::$availableBackgroundColors[$color]; - } - - /** - * Sets some specific style option. - * - * @param string $option option name - * - * @throws \InvalidArgumentException When the option name isn't defined - * - * @api - */ - public function setOption($option) - { - if (!isset(static::$availableOptions[$option])) { - throw new \InvalidArgumentException(sprintf( - 'Invalid option specified: "%s". Expected one of (%s)', - $option, - implode(', ', array_keys(static::$availableOptions)) - )); - } - - if (false === array_search(static::$availableOptions[$option], $this->options)) { - $this->options[] = static::$availableOptions[$option]; - } - } - - /** - * Unsets some specific style option. - * - * @param string $option option name - * - * @throws \InvalidArgumentException When the option name isn't defined - * - */ - public function unsetOption($option) - { - if (!isset(static::$availableOptions[$option])) { - throw new \InvalidArgumentException(sprintf( - 'Invalid option specified: "%s". Expected one of (%s)', - $option, - implode(', ', array_keys(static::$availableOptions)) - )); - } - - $pos = array_search(static::$availableOptions[$option], $this->options); - if (false !== $pos) { - unset($this->options[$pos]); - } - } - - /** - * Sets multiple style options at once. - * - * @param array $options - */ - public function setOptions(array $options) - { - $this->options = array(); - - foreach ($options as $option) { - $this->setOption($option); - } - } - - /** - * Applies the style to a given text. - * - * @param string $text The text to style - * - * @return string - */ - public function apply($text) - { - $codes = array(); - - if (null !== $this->foreground) { - $codes[] = $this->foreground; - } - if (null !== $this->background) { - $codes[] = $this->background; - } - if (count($this->options)) { - $codes = array_merge($codes, $this->options); - } - - return sprintf("\033[%sm%s\033[0m", implode(';', $codes), $text); - } -} diff --git a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php b/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php deleted file mode 100644 index 212cb86f..00000000 --- a/vendor/Symfony/Component/Console/Formatter/OutputFormatterStyleInterface.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Formatter; - -/** - * Formatter style interface for defining styles. - * - * @author Konstantin Kudryashov - * - * @api - */ -interface OutputFormatterStyleInterface -{ - /** - * Sets style foreground color. - * - * @param string $color color name - * - * @api - */ - function setForeground($color = null); - - /** - * Sets style background color. - * - * @param string $color color name - * - * @api - */ - function setBackground($color = null); - - /** - * Sets some specific style option. - * - * @param string $option option name - * - * @api - */ - function setOption($option); - - /** - * Unsets some specific style option. - * - * @param string $option option name - */ - function unsetOption($option); - - /** - * Sets multiple style options at once. - * - * @param array $options - */ - function setOptions(array $options); - - /** - * Applies the style to a given text. - * - * @param string $text The text to style - * - * @return string - */ - function apply($text); -} diff --git a/vendor/Symfony/Component/Console/Helper/DialogHelper.php b/vendor/Symfony/Component/Console/Helper/DialogHelper.php deleted file mode 100644 index e15fdd18..00000000 --- a/vendor/Symfony/Component/Console/Helper/DialogHelper.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Output\OutputInterface; - -/** - * The Dialog class provides helpers to interact with the user. - * - * @author Fabien Potencier - */ -class DialogHelper extends Helper -{ - private $inputStream; - - /** - * Asks a question to the user. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param string $default The default answer if none is given by the user - * - * @return string The user answer - * - * @throws \RuntimeException If there is no data to read in the input stream - */ - public function ask(OutputInterface $output, $question, $default = null) - { - $output->write($question); - - $ret = fgets($this->inputStream ?: STDIN, 4096); - if (false === $ret) { - throw new \RuntimeException('Aborted'); - } - $ret = trim($ret); - - return strlen($ret) > 0 ? $ret : $default; - } - - /** - * Asks a confirmation to the user. - * - * The question will be asked until the user answers by nothing, yes, or no. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param Boolean $default The default answer if the user enters nothing - * - * @return Boolean true if the user has confirmed, false otherwise - */ - public function askConfirmation(OutputInterface $output, $question, $default = true) - { - $answer = 'z'; - while ($answer && !in_array(strtolower($answer[0]), array('y', 'n'))) { - $answer = $this->ask($output, $question); - } - - if (false === $default) { - return $answer && 'y' == strtolower($answer[0]); - } - - return !$answer || 'y' == strtolower($answer[0]); - } - - /** - * Asks for a value and validates the response. - * - * The validator receives the data to validate. It must return the - * validated data when the data is valid and throw an exception - * otherwise. - * - * @param OutputInterface $output An Output instance - * @param string|array $question The question to ask - * @param callback $validator A PHP callback - * @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite) - * @param string $default The default answer if none is given by the user - * - * @return mixed - * - * @throws \Exception When any of the validators return an error - */ - public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null) - { - $error = null; - while (false === $attempts || $attempts--) { - if (null !== $error) { - $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error')); - } - - $value = $this->ask($output, $question, $default); - - try { - return call_user_func($validator, $value); - } catch (\Exception $error) { - } - } - - throw $error; - } - - /** - * Sets the input stream to read from when interacting with the user. - * - * This is mainly useful for testing purpose. - * - * @param resource $stream The input stream - */ - public function setInputStream($stream) - { - $this->inputStream = $stream; - } - - /** - * Returns the helper's input stream - * - * @return string - */ - public function getInputStream() - { - return $this->inputStream; - } - - /** - * Returns the helper's canonical name. - */ - public function getName() - { - return 'dialog'; - } -} diff --git a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php b/vendor/Symfony/Component/Console/Helper/FormatterHelper.php deleted file mode 100644 index d3f613bb..00000000 --- a/vendor/Symfony/Component/Console/Helper/FormatterHelper.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -/** - * The Formatter class provides helpers to format messages. - * - * @author Fabien Potencier - */ -class FormatterHelper extends Helper -{ - /** - * Formats a message within a section. - * - * @param string $section The section name - * @param string $message The message - * @param string $style The style to apply to the section - */ - public function formatSection($section, $message, $style = 'info') - { - return sprintf('<%s>[%s] %s', $style, $section, $style, $message); - } - - /** - * Formats a message as a block of text. - * - * @param string|array $messages The message to write in the block - * @param string $style The style to apply to the whole block - * @param Boolean $large Whether to return a large block - * - * @return string The formatter message - */ - public function formatBlock($messages, $style, $large = false) - { - $messages = (array) $messages; - - $len = 0; - $lines = array(); - foreach ($messages as $message) { - $lines[] = sprintf($large ? ' %s ' : ' %s ', $message); - $len = max($this->strlen($message) + ($large ? 4 : 2), $len); - } - - $messages = $large ? array(str_repeat(' ', $len)) : array(); - foreach ($lines as $line) { - $messages[] = $line.str_repeat(' ', $len - $this->strlen($line)); - } - if ($large) { - $messages[] = str_repeat(' ', $len); - } - - foreach ($messages as &$message) { - $message = sprintf('<%s>%s', $style, $message, $style); - } - - return implode("\n", $messages); - } - - /** - * Returns the length of a string, using mb_strlen if it is available. - * - * @param string $string The string to check its length - * - * @return integer The length of the string - */ - private function strlen($string) - { - if (!function_exists('mb_strlen')) { - return strlen($string); - } - - if (false === $encoding = mb_detect_encoding($string)) { - return strlen($string); - } - - return mb_strlen($string, $encoding); - } - - /** - * Returns the helper's canonical name. - * - * @return string The canonical name of the helper - */ - public function getName() - { - return 'formatter'; - } -} diff --git a/vendor/Symfony/Component/Console/Helper/Helper.php b/vendor/Symfony/Component/Console/Helper/Helper.php deleted file mode 100644 index 28488caf..00000000 --- a/vendor/Symfony/Component/Console/Helper/Helper.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -/** - * Helper is the base class for all helper classes. - * - * @author Fabien Potencier - */ -abstract class Helper implements HelperInterface -{ - protected $helperSet = null; - - /** - * Sets the helper set associated with this helper. - * - * @param HelperSet $helperSet A HelperSet instance - */ - public function setHelperSet(HelperSet $helperSet = null) - { - $this->helperSet = $helperSet; - } - - /** - * Gets the helper set associated with this helper. - * - * @return HelperSet A HelperSet instance - */ - public function getHelperSet() - { - return $this->helperSet; - } -} diff --git a/vendor/Symfony/Component/Console/Helper/HelperInterface.php b/vendor/Symfony/Component/Console/Helper/HelperInterface.php deleted file mode 100644 index 25ee5139..00000000 --- a/vendor/Symfony/Component/Console/Helper/HelperInterface.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -/** - * HelperInterface is the interface all helpers must implement. - * - * @author Fabien Potencier - * - * @api - */ -interface HelperInterface -{ - /** - * Sets the helper set associated with this helper. - * - * @param HelperSet $helperSet A HelperSet instance - * - * @api - */ - function setHelperSet(HelperSet $helperSet = null); - - /** - * Gets the helper set associated with this helper. - * - * @return HelperSet A HelperSet instance - * - * @api - */ - function getHelperSet(); - - /** - * Returns the canonical name of this helper. - * - * @return string The canonical name - * - * @api - */ - function getName(); -} diff --git a/vendor/Symfony/Component/Console/Helper/HelperSet.php b/vendor/Symfony/Component/Console/Helper/HelperSet.php deleted file mode 100644 index 0092c4c3..00000000 --- a/vendor/Symfony/Component/Console/Helper/HelperSet.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Helper; - -use Symfony\Component\Console\Command\Command; - -/** - * HelperSet represents a set of helpers to be used with a command. - * - * @author Fabien Potencier - */ -class HelperSet -{ - private $helpers; - private $command; - - /** - * Constructor. - * - * @param Helper[] $helpers An array of helper. - */ - public function __construct(array $helpers = array()) - { - $this->helpers = array(); - foreach ($helpers as $alias => $helper) { - $this->set($helper, is_int($alias) ? null : $alias); - } - } - - /** - * Sets a helper. - * - * @param HelperInterface $helper The helper instance - * @param string $alias An alias - */ - public function set(HelperInterface $helper, $alias = null) - { - $this->helpers[$helper->getName()] = $helper; - if (null !== $alias) { - $this->helpers[$alias] = $helper; - } - - $helper->setHelperSet($this); - } - - /** - * Returns true if the helper if defined. - * - * @param string $name The helper name - * - * @return Boolean true if the helper is defined, false otherwise - */ - public function has($name) - { - return isset($this->helpers[$name]); - } - - /** - * Gets a helper value. - * - * @param string $name The helper name - * - * @return HelperInterface The helper instance - * - * @throws \InvalidArgumentException if the helper is not defined - */ - public function get($name) - { - if (!$this->has($name)) { - throw new \InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name)); - } - - return $this->helpers[$name]; - } - - /** - * Sets the command associated with this helper set. - * - * @param Command $command A Command instance - */ - public function setCommand(Command $command = null) - { - $this->command = $command; - } - - /** - * Gets the command associated with this helper set. - * - * @return Command A Command instance - */ - public function getCommand() - { - return $this->command; - } -} diff --git a/vendor/Symfony/Component/Console/Input/ArgvInput.php b/vendor/Symfony/Component/Console/Input/ArgvInput.php deleted file mode 100644 index f0cfb141..00000000 --- a/vendor/Symfony/Component/Console/Input/ArgvInput.php +++ /dev/null @@ -1,311 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * ArgvInput represents an input coming from the CLI arguments. - * - * Usage: - * - * $input = new ArgvInput(); - * - * By default, the `$_SERVER['argv']` array is used for the input values. - * - * This can be overridden by explicitly passing the input values in the constructor: - * - * $input = new ArgvInput($_SERVER['argv']); - * - * If you pass it yourself, don't forget that the first element of the array - * is the name of the running application. - * - * When passing an argument to the constructor, be sure that it respects - * the same rules as the argv one. It's almost always better to use the - * `StringInput` when you want to provide your own input. - * - * @author Fabien Potencier - * - * @see http://www.gnu.org/software/libc/manual/html_node/Argument-Syntax.html - * @see http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02 - * - * @api - */ -class ArgvInput extends Input -{ - private $tokens; - private $parsed; - - /** - * Constructor. - * - * @param array $argv An array of parameters from the CLI (in the argv format) - * @param InputDefinition $definition A InputDefinition instance - * - * @api - */ - public function __construct(array $argv = null, InputDefinition $definition = null) - { - if (null === $argv) { - $argv = $_SERVER['argv']; - } - - // strip the application name - array_shift($argv); - - $this->tokens = $argv; - - parent::__construct($definition); - } - - protected function setTokens(array $tokens) - { - $this->tokens = $tokens; - } - - /** - * Processes command line arguments. - */ - protected function parse() - { - $parseOptions = true; - $this->parsed = $this->tokens; - while (null !== $token = array_shift($this->parsed)) { - if ($parseOptions && '--' == $token) { - $parseOptions = false; - } elseif ($parseOptions && 0 === strpos($token, '--')) { - $this->parseLongOption($token); - } elseif ($parseOptions && '-' === $token[0]) { - $this->parseShortOption($token); - } else { - $this->parseArgument($token); - } - } - } - - /** - * Parses a short option. - * - * @param string $token The current token. - */ - private function parseShortOption($token) - { - $name = substr($token, 1); - - if (strlen($name) > 1) { - if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) { - // an option with a value (with no space) - $this->addShortOption($name[0], substr($name, 1)); - } else { - $this->parseShortOptionSet($name); - } - } else { - $this->addShortOption($name, null); - } - } - - /** - * Parses a short option set. - * - * @param string $name The current token - * - * @throws \RuntimeException When option given doesn't exist - */ - private function parseShortOptionSet($name) - { - $len = strlen($name); - for ($i = 0; $i < $len; $i++) { - if (!$this->definition->hasShortcut($name[$i])) { - throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); - } - - $option = $this->definition->getOptionForShortcut($name[$i]); - if ($option->acceptValue()) { - $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1)); - - break; - } else { - $this->addLongOption($option->getName(), true); - } - } - } - - /** - * Parses a long option. - * - * @param string $token The current token - */ - private function parseLongOption($token) - { - $name = substr($token, 2); - - if (false !== $pos = strpos($name, '=')) { - $this->addLongOption(substr($name, 0, $pos), substr($name, $pos + 1)); - } else { - $this->addLongOption($name, null); - } - } - - /** - * Parses an argument. - * - * @param string $token The current token - * - * @throws \RuntimeException When too many arguments are given - */ - private function parseArgument($token) - { - $c = count($this->arguments); - - // if input is expecting another argument, add it - if ($this->definition->hasArgument($c)) { - $arg = $this->definition->getArgument($c); - $this->arguments[$arg->getName()] = $arg->isArray()? array($token) : $token; - - // if last argument isArray(), append token to last argument - } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { - $arg = $this->definition->getArgument($c - 1); - $this->arguments[$arg->getName()][] = $token; - - // unexpected argument - } else { - throw new \RuntimeException('Too many arguments.'); - } - } - - /** - * Adds a short option value. - * - * @param string $shortcut The short option key - * @param mixed $value The value for the option - * - * @throws \RuntimeException When option given doesn't exist - */ - private function addShortOption($shortcut, $value) - { - if (!$this->definition->hasShortcut($shortcut)) { - throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut)); - } - - $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); - } - - /** - * Adds a long option value. - * - * @param string $name The long option key - * @param mixed $value The value for the option - * - * @throws \RuntimeException When option given doesn't exist - */ - private function addLongOption($name, $value) - { - if (!$this->definition->hasOption($name)) { - throw new \RuntimeException(sprintf('The "--%s" option does not exist.', $name)); - } - - $option = $this->definition->getOption($name); - - if (null === $value && $option->acceptValue()) { - // if option accepts an optional or mandatory argument - // let's see if there is one provided - $next = array_shift($this->parsed); - if ('-' !== $next[0]) { - $value = $next; - } else { - array_unshift($this->parsed, $next); - } - } - - if (null === $value) { - if ($option->isValueRequired()) { - throw new \RuntimeException(sprintf('The "--%s" option requires a value.', $name)); - } - - $value = $option->isValueOptional() ? $option->getDefault() : true; - } - - if ($option->isArray()) { - $this->options[$name][] = $value; - } else { - $this->options[$name] = $value; - } - } - - /** - * Returns the first argument from the raw parameters (not parsed). - * - * @return string The value of the first argument or null otherwise - */ - public function getFirstArgument() - { - foreach ($this->tokens as $token) { - if ($token && '-' === $token[0]) { - continue; - } - - return $token; - } - } - - /** - * Returns true if the raw parameters (not parsed) contain a value. - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The value(s) to look for in the raw parameters (can be an array) - * - * @return Boolean true if the value is contained in the raw parameters - */ - public function hasParameterOption($values) - { - $values = (array) $values; - - foreach ($this->tokens as $v) { - if (in_array($v, $values)) { - return true; - } - } - - return false; - } - - /** - * Returns the value of a raw option (not parsed). - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The value(s) to look for in the raw parameters (can be an array) - * @param mixed $default The default value to return if no result is found - * - * @return mixed The option value - */ - public function getParameterOption($values, $default = false) - { - $values = (array) $values; - - $tokens = $this->tokens; - while ($token = array_shift($tokens)) { - foreach ($values as $value) { - if (0 === strpos($token, $value)) { - if (false !== $pos = strpos($token, '=')) { - return substr($token, $pos + 1); - } - - return array_shift($tokens); - } - } - } - - return $default; - } -} diff --git a/vendor/Symfony/Component/Console/Input/ArrayInput.php b/vendor/Symfony/Component/Console/Input/ArrayInput.php deleted file mode 100644 index c9d8ee98..00000000 --- a/vendor/Symfony/Component/Console/Input/ArrayInput.php +++ /dev/null @@ -1,190 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * ArrayInput represents an input provided as an array. - * - * Usage: - * - * $input = new ArrayInput(array('name' => 'foo', '--bar' => 'foobar')); - * - * @author Fabien Potencier - * - * @api - */ -class ArrayInput extends Input -{ - private $parameters; - - /** - * Constructor. - * - * @param array $parameters An array of parameters - * @param InputDefinition $definition A InputDefinition instance - * - * @api - */ - public function __construct(array $parameters, InputDefinition $definition = null) - { - $this->parameters = $parameters; - - parent::__construct($definition); - } - - /** - * Returns the first argument from the raw parameters (not parsed). - * - * @return string The value of the first argument or null otherwise - */ - public function getFirstArgument() - { - foreach ($this->parameters as $key => $value) { - if ($key && '-' === $key[0]) { - continue; - } - - return $value; - } - } - - /** - * Returns true if the raw parameters (not parsed) contain a value. - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The values to look for in the raw parameters (can be an array) - * - * @return Boolean true if the value is contained in the raw parameters - */ - public function hasParameterOption($values) - { - $values = (array) $values; - - foreach ($this->parameters as $k => $v) { - if (!is_int($k)) { - $v = $k; - } - - if (in_array($v, $values)) { - return true; - } - } - - return false; - } - - /** - * Returns the value of a raw option (not parsed). - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The value(s) to look for in the raw parameters (can be an array) - * @param mixed $default The default value to return if no result is found - * - * @return mixed The option value - */ - public function getParameterOption($values, $default = false) - { - $values = (array) $values; - - foreach ($this->parameters as $k => $v) { - if (is_int($k) && in_array($v, $values)) { - return true; - } elseif (in_array($k, $values)) { - return $v; - } - } - - return $default; - } - - /** - * Processes command line arguments. - */ - protected function parse() - { - foreach ($this->parameters as $key => $value) { - if (0 === strpos($key, '--')) { - $this->addLongOption(substr($key, 2), $value); - } elseif ('-' === $key[0]) { - $this->addShortOption(substr($key, 1), $value); - } else { - $this->addArgument($key, $value); - } - } - } - - /** - * Adds a short option value. - * - * @param string $shortcut The short option key - * @param mixed $value The value for the option - * - * @throws \InvalidArgumentException When option given doesn't exist - */ - private function addShortOption($shortcut, $value) - { - if (!$this->definition->hasShortcut($shortcut)) { - throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); - } - - $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value); - } - - /** - * Adds a long option value. - * - * @param string $name The long option key - * @param mixed $value The value for the option - * - * @throws \InvalidArgumentException When option given doesn't exist - * @throws \InvalidArgumentException When a required value is missing - */ - private function addLongOption($name, $value) - { - if (!$this->definition->hasOption($name)) { - throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); - } - - $option = $this->definition->getOption($name); - - if (null === $value) { - if ($option->isValueRequired()) { - throw new \InvalidArgumentException(sprintf('The "--%s" option requires a value.', $name)); - } - - $value = $option->isValueOptional() ? $option->getDefault() : true; - } - - $this->options[$name] = $value; - } - - /** - * Adds an argument value. - * - * @param string $name The argument name - * @param mixed $value The value for the argument - * - * @throws \InvalidArgumentException When argument given doesn't exist - */ - private function addArgument($name, $value) - { - if (!$this->definition->hasArgument($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); - } - - $this->arguments[$name] = $value; - } -} diff --git a/vendor/Symfony/Component/Console/Input/Input.php b/vendor/Symfony/Component/Console/Input/Input.php deleted file mode 100644 index 70291be7..00000000 --- a/vendor/Symfony/Component/Console/Input/Input.php +++ /dev/null @@ -1,211 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * Input is the base class for all concrete Input classes. - * - * Three concrete classes are provided by default: - * - * * `ArgvInput`: The input comes from the CLI arguments (argv) - * * `StringInput`: The input is provided as a string - * * `ArrayInput`: The input is provided as an array - * - * @author Fabien Potencier - */ -abstract class Input implements InputInterface -{ - protected $definition; - protected $options; - protected $arguments; - protected $interactive = true; - - /** - * Constructor. - * - * @param InputDefinition $definition A InputDefinition instance - */ - public function __construct(InputDefinition $definition = null) - { - if (null === $definition) { - $this->definition = new InputDefinition(); - } else { - $this->bind($definition); - $this->validate(); - } - } - - /** - * Binds the current Input instance with the given arguments and options. - * - * @param InputDefinition $definition A InputDefinition instance - */ - public function bind(InputDefinition $definition) - { - $this->arguments = array(); - $this->options = array(); - $this->definition = $definition; - - $this->parse(); - } - - /** - * Processes command line arguments. - */ - abstract protected function parse(); - - /** - * Validates the input. - * - * @throws \RuntimeException When not enough arguments are given - */ - public function validate() - { - if (count($this->arguments) < $this->definition->getArgumentRequiredCount()) { - throw new \RuntimeException('Not enough arguments.'); - } - } - - /** - * Checks if the input is interactive. - * - * @return Boolean Returns true if the input is interactive - */ - public function isInteractive() - { - return $this->interactive; - } - - /** - * Sets the input interactivity. - * - * @param Boolean $interactive If the input should be interactive - */ - public function setInteractive($interactive) - { - $this->interactive = (Boolean) $interactive; - } - - /** - * Returns the argument values. - * - * @return array An array of argument values - */ - public function getArguments() - { - return array_merge($this->definition->getArgumentDefaults(), $this->arguments); - } - - /** - * Returns the argument value for a given argument name. - * - * @param string $name The argument name - * - * @return mixed The argument value - * - * @throws \InvalidArgumentException When argument given doesn't exist - */ - public function getArgument($name) - { - if (!$this->definition->hasArgument($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); - } - - return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); - } - - /** - * Sets an argument value by name. - * - * @param string $name The argument name - * @param string $value The argument value - * - * @throws \InvalidArgumentException When argument given doesn't exist - */ - public function setArgument($name, $value) - { - if (!$this->definition->hasArgument($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); - } - - $this->arguments[$name] = $value; - } - - /** - * Returns true if an InputArgument object exists by name or position. - * - * @param string|integer $name The InputArgument name or position - * - * @return Boolean true if the InputArgument object exists, false otherwise - */ - public function hasArgument($name) - { - return $this->definition->hasArgument($name); - } - - /** - * Returns the options values. - * - * @return array An array of option values - */ - public function getOptions() - { - return array_merge($this->definition->getOptionDefaults(), $this->options); - } - - /** - * Returns the option value for a given option name. - * - * @param string $name The option name - * - * @return mixed The option value - * - * @throws \InvalidArgumentException When option given doesn't exist - */ - public function getOption($name) - { - if (!$this->definition->hasOption($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); - } - - return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); - } - - /** - * Sets an option value by name. - * - * @param string $name The option name - * @param string $value The option value - * - * @throws \InvalidArgumentException When option given doesn't exist - */ - public function setOption($name, $value) - { - if (!$this->definition->hasOption($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); - } - - $this->options[$name] = $value; - } - - /** - * Returns true if an InputOption object exists by name. - * - * @param string $name The InputOption name - * - * @return Boolean true if the InputOption object exists, false otherwise - */ - public function hasOption($name) - { - return $this->definition->hasOption($name); - } -} diff --git a/vendor/Symfony/Component/Console/Input/InputArgument.php b/vendor/Symfony/Component/Console/Input/InputArgument.php deleted file mode 100644 index e7cc9353..00000000 --- a/vendor/Symfony/Component/Console/Input/InputArgument.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * Represents a command line argument. - * - * @author Fabien Potencier - * - * @api - */ -class InputArgument -{ - const REQUIRED = 1; - const OPTIONAL = 2; - const IS_ARRAY = 4; - - private $name; - private $mode; - private $default; - private $description; - - /** - * Constructor. - * - * @param string $name The argument name - * @param integer $mode The argument mode: self::REQUIRED or self::OPTIONAL - * @param string $description A description text - * @param mixed $default The default value (for self::OPTIONAL mode only) - * - * @throws \InvalidArgumentException When argument mode is not valid - * - * @api - */ - public function __construct($name, $mode = null, $description = '', $default = null) - { - if (null === $mode) { - $mode = self::OPTIONAL; - } elseif (!is_int($mode) || $mode > 7 || $mode < 1) { - throw new \InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode)); - } - - $this->name = $name; - $this->mode = $mode; - $this->description = $description; - - $this->setDefault($default); - } - - /** - * Returns the argument name. - * - * @return string The argument name - */ - public function getName() - { - return $this->name; - } - - /** - * Returns true if the argument is required. - * - * @return Boolean true if parameter mode is self::REQUIRED, false otherwise - */ - public function isRequired() - { - return self::REQUIRED === (self::REQUIRED & $this->mode); - } - - /** - * Returns true if the argument can take multiple values. - * - * @return Boolean true if mode is self::IS_ARRAY, false otherwise - */ - public function isArray() - { - return self::IS_ARRAY === (self::IS_ARRAY & $this->mode); - } - - /** - * Sets the default value. - * - * @param mixed $default The default value - * - * @throws \LogicException When incorrect default value is given - */ - public function setDefault($default = null) - { - if (self::REQUIRED === $this->mode && null !== $default) { - throw new \LogicException('Cannot set a default value except for Parameter::OPTIONAL mode.'); - } - - if ($this->isArray()) { - if (null === $default) { - $default = array(); - } elseif (!is_array($default)) { - throw new \LogicException('A default value for an array argument must be an array.'); - } - } - - $this->default = $default; - } - - /** - * Returns the default value. - * - * @return mixed The default value - */ - public function getDefault() - { - return $this->default; - } - - /** - * Returns the description text. - * - * @return string The description text - */ - public function getDescription() - { - return $this->description; - } -} diff --git a/vendor/Symfony/Component/Console/Input/InputDefinition.php b/vendor/Symfony/Component/Console/Input/InputDefinition.php deleted file mode 100644 index ffae4fe9..00000000 --- a/vendor/Symfony/Component/Console/Input/InputDefinition.php +++ /dev/null @@ -1,533 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * A InputDefinition represents a set of valid command line arguments and options. - * - * Usage: - * - * $definition = new InputDefinition(array( - * new InputArgument('name', InputArgument::REQUIRED), - * new InputOption('foo', 'f', InputOption::VALUE_REQUIRED), - * )); - * - * @author Fabien Potencier - * - * @api - */ -class InputDefinition -{ - private $arguments; - private $requiredCount; - private $hasAnArrayArgument = false; - private $hasOptional; - private $options; - private $shortcuts; - - /** - * Constructor. - * - * @param array $definition An array of InputArgument and InputOption instance - * - * @api - */ - public function __construct(array $definition = array()) - { - $this->setDefinition($definition); - } - - /** - * Sets the definition of the input. - * - * @param array $definition The definition array - * - * @api - */ - public function setDefinition(array $definition) - { - $arguments = array(); - $options = array(); - foreach ($definition as $item) { - if ($item instanceof InputOption) { - $options[] = $item; - } else { - $arguments[] = $item; - } - } - - $this->setArguments($arguments); - $this->setOptions($options); - } - - /** - * Sets the InputArgument objects. - * - * @param array $arguments An array of InputArgument objects - * - * @api - */ - public function setArguments($arguments = array()) - { - $this->arguments = array(); - $this->requiredCount = 0; - $this->hasOptional = false; - $this->hasAnArrayArgument = false; - $this->addArguments($arguments); - } - - /** - * Adds an array of InputArgument objects. - * - * @param InputArgument[] $arguments An array of InputArgument objects - * - * @api - */ - public function addArguments($arguments = array()) - { - if (null !== $arguments) { - foreach ($arguments as $argument) { - $this->addArgument($argument); - } - } - } - - /** - * Adds an InputArgument object. - * - * @param InputArgument $argument An InputArgument object - * - * @throws \LogicException When incorrect argument is given - * - * @api - */ - public function addArgument(InputArgument $argument) - { - if (isset($this->arguments[$argument->getName()])) { - throw new \LogicException(sprintf('An argument with name "%s" already exist.', $argument->getName())); - } - - if ($this->hasAnArrayArgument) { - throw new \LogicException('Cannot add an argument after an array argument.'); - } - - if ($argument->isRequired() && $this->hasOptional) { - throw new \LogicException('Cannot add a required argument after an optional one.'); - } - - if ($argument->isArray()) { - $this->hasAnArrayArgument = true; - } - - if ($argument->isRequired()) { - ++$this->requiredCount; - } else { - $this->hasOptional = true; - } - - $this->arguments[$argument->getName()] = $argument; - } - - /** - * Returns an InputArgument by name or by position. - * - * @param string|integer $name The InputArgument name or position - * - * @return InputArgument An InputArgument object - * - * @throws \InvalidArgumentException When argument given doesn't exist - * - * @api - */ - public function getArgument($name) - { - $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; - - if (!$this->hasArgument($name)) { - throw new \InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); - } - - return $arguments[$name]; - } - - /** - * Returns true if an InputArgument object exists by name or position. - * - * @param string|integer $name The InputArgument name or position - * - * @return Boolean true if the InputArgument object exists, false otherwise - * - * @api - */ - public function hasArgument($name) - { - $arguments = is_int($name) ? array_values($this->arguments) : $this->arguments; - - return isset($arguments[$name]); - } - - /** - * Gets the array of InputArgument objects. - * - * @return array An array of InputArgument objects - * - * @api - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Returns the number of InputArguments. - * - * @return integer The number of InputArguments - */ - public function getArgumentCount() - { - return $this->hasAnArrayArgument ? PHP_INT_MAX : count($this->arguments); - } - - /** - * Returns the number of required InputArguments. - * - * @return integer The number of required InputArguments - */ - public function getArgumentRequiredCount() - { - return $this->requiredCount; - } - - /** - * Gets the default values. - * - * @return array An array of default values - */ - public function getArgumentDefaults() - { - $values = array(); - foreach ($this->arguments as $argument) { - $values[$argument->getName()] = $argument->getDefault(); - } - - return $values; - } - - /** - * Sets the InputOption objects. - * - * @param array $options An array of InputOption objects - * - * @api - */ - public function setOptions($options = array()) - { - $this->options = array(); - $this->shortcuts = array(); - $this->addOptions($options); - } - - /** - * Adds an array of InputOption objects. - * - * @param InputOption[] $options An array of InputOption objects - * - * @api - */ - public function addOptions($options = array()) - { - foreach ($options as $option) { - $this->addOption($option); - } - } - - /** - * Adds an InputOption object. - * - * @param InputOption $option An InputOption object - * - * @throws \LogicException When option given already exist - * - * @api - */ - public function addOption(InputOption $option) - { - if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) { - throw new \LogicException(sprintf('An option named "%s" already exist.', $option->getName())); - } elseif (isset($this->shortcuts[$option->getShortcut()]) && !$option->equals($this->options[$this->shortcuts[$option->getShortcut()]])) { - throw new \LogicException(sprintf('An option with shortcut "%s" already exist.', $option->getShortcut())); - } - - $this->options[$option->getName()] = $option; - if ($option->getShortcut()) { - $this->shortcuts[$option->getShortcut()] = $option->getName(); - } - } - - /** - * Returns an InputOption by name. - * - * @param string $name The InputOption name - * - * @return InputOption A InputOption object - * - * @api - */ - public function getOption($name) - { - if (!$this->hasOption($name)) { - throw new \InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name)); - } - - return $this->options[$name]; - } - - /** - * Returns true if an InputOption object exists by name. - * - * @param string $name The InputOption name - * - * @return Boolean true if the InputOption object exists, false otherwise - * - * @api - */ - public function hasOption($name) - { - return isset($this->options[$name]); - } - - /** - * Gets the array of InputOption objects. - * - * @return array An array of InputOption objects - * - * @api - */ - public function getOptions() - { - return $this->options; - } - - /** - * Returns true if an InputOption object exists by shortcut. - * - * @param string $name The InputOption shortcut - * - * @return Boolean true if the InputOption object exists, false otherwise - */ - public function hasShortcut($name) - { - return isset($this->shortcuts[$name]); - } - - /** - * Gets an InputOption by shortcut. - * - * @param string $shortcut the Shortcut name - * - * @return InputOption An InputOption object - */ - public function getOptionForShortcut($shortcut) - { - return $this->getOption($this->shortcutToName($shortcut)); - } - - /** - * Gets an array of default values. - * - * @return array An array of all default values - */ - public function getOptionDefaults() - { - $values = array(); - foreach ($this->options as $option) { - $values[$option->getName()] = $option->getDefault(); - } - - return $values; - } - - /** - * Returns the InputOption name given a shortcut. - * - * @param string $shortcut The shortcut - * - * @return string The InputOption name - * - * @throws \InvalidArgumentException When option given does not exist - */ - private function shortcutToName($shortcut) - { - if (!isset($this->shortcuts[$shortcut])) { - throw new \InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut)); - } - - return $this->shortcuts[$shortcut]; - } - - /** - * Gets the synopsis. - * - * @return string The synopsis - */ - public function getSynopsis() - { - $elements = array(); - foreach ($this->getOptions() as $option) { - $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : ''; - $elements[] = sprintf('['.($option->isValueRequired() ? '%s--%s="..."' : ($option->isValueOptional() ? '%s--%s[="..."]' : '%s--%s')).']', $shortcut, $option->getName()); - } - - foreach ($this->getArguments() as $argument) { - $elements[] = sprintf($argument->isRequired() ? '%s' : '[%s]', $argument->getName().($argument->isArray() ? '1' : '')); - - if ($argument->isArray()) { - $elements[] = sprintf('... [%sN]', $argument->getName()); - } - } - - return implode(' ', $elements); - } - - /** - * Returns a textual representation of the InputDefinition. - * - * @return string A string representing the InputDefinition - */ - public function asText() - { - // find the largest option or argument name - $max = 0; - foreach ($this->getOptions() as $option) { - $nameLength = strlen($option->getName()) + 2; - if ($option->getShortcut()) { - $nameLength += strlen($option->getShortcut()) + 3; - } - - $max = max($max, $nameLength); - } - foreach ($this->getArguments() as $argument) { - $max = max($max, strlen($argument->getName())); - } - ++$max; - - $text = array(); - - if ($this->getArguments()) { - $text[] = 'Arguments:'; - foreach ($this->getArguments() as $argument) { - if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) { - $default = sprintf(' (default: %s)', $this->formatDefaultValue($argument->getDefault())); - } else { - $default = ''; - } - - $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $argument->getDescription()); - - $text[] = sprintf(" %-${max}s %s%s", $argument->getName(), $description, $default); - } - - $text[] = ''; - } - - if ($this->getOptions()) { - $text[] = 'Options:'; - - foreach ($this->getOptions() as $option) { - if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) { - $default = sprintf(' (default: %s)', $this->formatDefaultValue($option->getDefault())); - } else { - $default = ''; - } - - $multiple = $option->isArray() ? ' (multiple values allowed)' : ''; - $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $option->getDescription()); - - $optionMax = $max - strlen($option->getName()) - 2; - $text[] = sprintf(" %s %-${optionMax}s%s%s%s", - '--'.$option->getName(), - $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', - $description, - $default, - $multiple - ); - } - - $text[] = ''; - } - - return implode("\n", $text); - } - - /** - * Returns an XML representation of the InputDefinition. - * - * @param Boolean $asDom Whether to return a DOM or an XML string - * - * @return string|DOMDocument An XML string representing the InputDefinition - */ - public function asXml($asDom = false) - { - $dom = new \DOMDocument('1.0', 'UTF-8'); - $dom->formatOutput = true; - $dom->appendChild($definitionXML = $dom->createElement('definition')); - - $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments')); - foreach ($this->getArguments() as $argument) { - $argumentsXML->appendChild($argumentXML = $dom->createElement('argument')); - $argumentXML->setAttribute('name', $argument->getName()); - $argumentXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0); - $argumentXML->setAttribute('is_array', $argument->isArray() ? 1 : 0); - $argumentXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode($argument->getDescription())); - - $argumentXML->appendChild($defaultsXML = $dom->createElement('defaults')); - $defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array())); - foreach ($defaults as $default) { - $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); - $defaultXML->appendChild($dom->createTextNode($default)); - } - } - - $definitionXML->appendChild($optionsXML = $dom->createElement('options')); - foreach ($this->getOptions() as $option) { - $optionsXML->appendChild($optionXML = $dom->createElement('option')); - $optionXML->setAttribute('name', '--'.$option->getName()); - $optionXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : ''); - $optionXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0); - $optionXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0); - $optionXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0); - $optionXML->appendChild($descriptionXML = $dom->createElement('description')); - $descriptionXML->appendChild($dom->createTextNode($option->getDescription())); - - if ($option->acceptValue()) { - $optionXML->appendChild($defaultsXML = $dom->createElement('defaults')); - $defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array())); - foreach ($defaults as $default) { - $defaultsXML->appendChild($defaultXML = $dom->createElement('default')); - $defaultXML->appendChild($dom->createTextNode($default)); - } - } - } - - return $asDom ? $dom : $dom->saveXml(); - } - - private function formatDefaultValue($default) - { - if (is_array($default) && $default === array_values($default)) { - return sprintf("array('%s')", implode("', '", $default)); - } - - return str_replace("\n", '', var_export($default, true)); - } -} diff --git a/vendor/Symfony/Component/Console/Input/InputInterface.php b/vendor/Symfony/Component/Console/Input/InputInterface.php deleted file mode 100644 index a4a62234..00000000 --- a/vendor/Symfony/Component/Console/Input/InputInterface.php +++ /dev/null @@ -1,152 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * InputInterface is the interface implemented by all input classes. - * - * @author Fabien Potencier - */ -interface InputInterface -{ - /** - * Returns the first argument from the raw parameters (not parsed). - * - * @return string The value of the first argument or null otherwise - */ - function getFirstArgument(); - - /** - * Returns true if the raw parameters (not parsed) contain a value. - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The values to look for in the raw parameters (can be an array) - * - * @return Boolean true if the value is contained in the raw parameters - */ - function hasParameterOption($values); - - /** - * Returns the value of a raw option (not parsed). - * - * This method is to be used to introspect the input parameters - * before they have been validated. It must be used carefully. - * - * @param string|array $values The value(s) to look for in the raw parameters (can be an array) - * @param mixed $default The default value to return if no result is found - * - * @return mixed The option value - */ - function getParameterOption($values, $default = false); - - /** - * Binds the current Input instance with the given arguments and options. - * - * @param InputDefinition $definition A InputDefinition instance - */ - function bind(InputDefinition $definition); - - /** - * Validates if arguments given are correct. - * - * Throws an exception when not enough arguments are given. - * - * @throws \RuntimeException - */ - function validate(); - - /** - * Returns all the given arguments merged with the default values. - * - * @return array - */ - function getArguments(); - - /** - * Gets argument by name. - * - * @param string $name The name of the argument - * - * @return mixed - */ - function getArgument($name); - - /** - * Sets an argument value by name. - * - * @param string $name The argument name - * @param string $value The argument value - * - * @throws \InvalidArgumentException When argument given doesn't exist - */ - function setArgument($name, $value); - - /** - * Returns true if an InputArgument object exists by name or position. - * - * @param string|integer $name The InputArgument name or position - * - * @return Boolean true if the InputArgument object exists, false otherwise - */ - function hasArgument($name); - - /** - * Returns all the given options merged with the default values. - * - * @return array - */ - function getOptions(); - - /** - * Gets an option by name. - * - * @param string $name The name of the option - * - * @return mixed - */ - function getOption($name); - - /** - * Sets an option value by name. - * - * @param string $name The option name - * @param string $value The option value - * - * @throws \InvalidArgumentException When option given doesn't exist - */ - function setOption($name, $value); - - /** - * Returns true if an InputOption object exists by name. - * - * @param string $name The InputOption name - * - * @return Boolean true if the InputOption object exists, false otherwise - */ - function hasOption($name); - - /** - * Is this input means interactive? - * - * @return Boolean - */ - function isInteractive(); - - /** - * Sets the input interactivity. - * - * @param Boolean $interactive If the input should be interactive - */ - function setInteractive($interactive); -} diff --git a/vendor/Symfony/Component/Console/Input/InputOption.php b/vendor/Symfony/Component/Console/Input/InputOption.php deleted file mode 100644 index 0f260455..00000000 --- a/vendor/Symfony/Component/Console/Input/InputOption.php +++ /dev/null @@ -1,201 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * Represents a command line option. - * - * @author Fabien Potencier - * - * @api - */ -class InputOption -{ - const VALUE_NONE = 1; - const VALUE_REQUIRED = 2; - const VALUE_OPTIONAL = 4; - const VALUE_IS_ARRAY = 8; - - private $name; - private $shortcut; - private $mode; - private $default; - private $description; - - /** - * Constructor. - * - * @param string $name The option name - * @param string $shortcut The shortcut (can be null) - * @param integer $mode The option mode: One of the VALUE_* constants - * @param string $description A description text - * @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE) - * - * @throws \InvalidArgumentException If option mode is invalid or incompatible - * - * @api - */ - public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null) - { - if (0 === strpos($name, '--')) { - $name = substr($name, 2); - } - - if (empty($shortcut)) { - $shortcut = null; - } - - if (null !== $shortcut) { - if ('-' === $shortcut[0]) { - $shortcut = substr($shortcut, 1); - } - } - - if (null === $mode) { - $mode = self::VALUE_NONE; - } elseif (!is_int($mode) || $mode > 15 || $mode < 1) { - throw new \InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode)); - } - - $this->name = $name; - $this->shortcut = $shortcut; - $this->mode = $mode; - $this->description = $description; - - if ($this->isArray() && !$this->acceptValue()) { - throw new \InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.'); - } - - $this->setDefault($default); - } - - /** - * Returns the option shortcut. - * - * @return string The shortcut - */ - public function getShortcut() - { - return $this->shortcut; - } - - /** - * Returns the option name. - * - * @return string The name - */ - public function getName() - { - return $this->name; - } - - /** - * Returns true if the option accepts a value. - * - * @return Boolean true if value mode is not self::VALUE_NONE, false otherwise - */ - public function acceptValue() - { - return $this->isValueRequired() || $this->isValueOptional(); - } - - /** - * Returns true if the option requires a value. - * - * @return Boolean true if value mode is self::VALUE_REQUIRED, false otherwise - */ - public function isValueRequired() - { - return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode); - } - - /** - * Returns true if the option takes an optional value. - * - * @return Boolean true if value mode is self::VALUE_OPTIONAL, false otherwise - */ - public function isValueOptional() - { - return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode); - } - - /** - * Returns true if the option can take multiple values. - * - * @return Boolean true if mode is self::VALUE_IS_ARRAY, false otherwise - */ - public function isArray() - { - return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode); - } - - /** - * Sets the default value. - * - * @param mixed $default The default value - * - * @throws \LogicException When incorrect default value is given - */ - public function setDefault($default = null) - { - if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) { - throw new \LogicException('Cannot set a default value when using Option::VALUE_NONE mode.'); - } - - if ($this->isArray()) { - if (null === $default) { - $default = array(); - } elseif (!is_array($default)) { - throw new \LogicException('A default value for an array option must be an array.'); - } - } - - $this->default = $this->acceptValue() ? $default : false; - } - - /** - * Returns the default value. - * - * @return mixed The default value - */ - public function getDefault() - { - return $this->default; - } - - /** - * Returns the description text. - * - * @return string The description text - */ - public function getDescription() - { - return $this->description; - } - - /** - * Checks whether the given option equals this one - * - * @param InputOption $option option to compare - * @return Boolean - */ - public function equals(InputOption $option) - { - return $option->getName() === $this->getName() - && $option->getShortcut() === $this->getShortcut() - && $option->getDefault() === $this->getDefault() - && $option->isArray() === $this->isArray() - && $option->isValueRequired() === $this->isValueRequired() - && $option->isValueOptional() === $this->isValueOptional() - ; - } -} diff --git a/vendor/Symfony/Component/Console/Input/StringInput.php b/vendor/Symfony/Component/Console/Input/StringInput.php deleted file mode 100644 index 72b725bd..00000000 --- a/vendor/Symfony/Component/Console/Input/StringInput.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Input; - -/** - * StringInput represents an input provided as a string. - * - * Usage: - * - * $input = new StringInput('foo --bar="foobar"'); - * - * @author Fabien Potencier - * - * @api - */ -class StringInput extends ArgvInput -{ - const REGEX_STRING = '([^ ]+?)(?: |(?setTokens($this->tokenize($input)); - } - - /** - * Tokenizes a string. - * - * @param string $input The input to tokenize - * - * @throws \InvalidArgumentException When unable to parse input (should never happen) - */ - private function tokenize($input) - { - $input = preg_replace('/(\r\n|\r|\n|\t)/', ' ', $input); - - $tokens = array(); - $length = strlen($input); - $cursor = 0; - while ($cursor < $length) { - if (preg_match('/\s+/A', $input, $match, null, $cursor)) { - } elseif (preg_match('/([^="\' ]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) { - $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, strlen($match[3]) - 2))); - } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) { - $tokens[] = stripcslashes(substr($match[0], 1, strlen($match[0]) - 2)); - } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) { - $tokens[] = stripcslashes($match[1]); - } else { - // should never happen - // @codeCoverageIgnoreStart - throw new \InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10))); - // @codeCoverageIgnoreEnd - } - - $cursor += strlen($match[0]); - } - - return $tokens; - } -} diff --git a/vendor/Symfony/Component/Console/LICENSE b/vendor/Symfony/Component/Console/LICENSE deleted file mode 100644 index cdffe7ae..00000000 --- a/vendor/Symfony/Component/Console/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2012 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php b/vendor/Symfony/Component/Console/Output/ConsoleOutput.php deleted file mode 100644 index 1cce3326..00000000 --- a/vendor/Symfony/Component/Console/Output/ConsoleOutput.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -use Symfony\Component\Console\Formatter\OutputFormatter; -use Symfony\Component\Console\Formatter\OutputFormatterInterface; -use Symfony\Component\Console\Output\ConsoleOutputInterface; - -/** - * ConsoleOutput is the default class for all CLI output. It uses STDOUT. - * - * This class is a convenient wrapper around `StreamOutput`. - * - * $output = new ConsoleOutput(); - * - * This is equivalent to: - * - * $output = new StreamOutput(fopen('php://stdout', 'w')); - * - * @author Fabien Potencier - * - * @api - */ -class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface -{ - private $stderr; - - /** - * Constructor. - * - * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, - * self::VERBOSITY_VERBOSE) - * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) - * @param OutputFormatter $formatter Output formatter instance - * - * @api - */ - public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) - { - parent::__construct(fopen('php://stdout', 'w'), $verbosity, $decorated, $formatter); - $this->stderr = new StreamOutput(fopen('php://stderr', 'w'), $verbosity, $decorated, $formatter); - } - - public function setDecorated($decorated) - { - parent::setDecorated($decorated); - $this->stderr->setDecorated($decorated); - } - - public function setFormatter(OutputFormatterInterface $formatter) - { - parent::setFormatter($formatter); - $this->stderr->setFormatter($formatter); - } - - public function setVerbosity($level) - { - parent::setVerbosity($level); - $this->stderr->setVerbosity($level); - } - - /** - * @return OutputInterface - */ - public function getErrorOutput() - { - return $this->stderr; - } - - public function setErrorOutput(OutputInterface $error) - { - $this->stderr = $error; - } -} diff --git a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php b/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php deleted file mode 100644 index 5006b800..00000000 --- a/vendor/Symfony/Component/Console/Output/ConsoleOutputInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -use Symfony\Component\Console\Output\OutputInterface; - -/** - * ConsoleOutputInterface is the interface implemented by ConsoleOutput class. - * This adds information about stderr output stream. - * - * @author Dariusz Górecki - */ -interface ConsoleOutputInterface extends OutputInterface -{ - /** - * @return OutputInterface - */ - public function getErrorOutput(); - - public function setErrorOutput(OutputInterface $error); -} diff --git a/vendor/Symfony/Component/Console/Output/NullOutput.php b/vendor/Symfony/Component/Console/Output/NullOutput.php deleted file mode 100644 index f6c99ab0..00000000 --- a/vendor/Symfony/Component/Console/Output/NullOutput.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -/** - * NullOutput suppresses all output. - * - * $output = new NullOutput(); - * - * @author Fabien Potencier - * - * @api - */ -class NullOutput extends Output -{ - /** - * Writes a message to the output. - * - * @param string $message A message to write to the output - * @param Boolean $newline Whether to add a newline or not - */ - public function doWrite($message, $newline) - { - } -} diff --git a/vendor/Symfony/Component/Console/Output/Output.php b/vendor/Symfony/Component/Console/Output/Output.php deleted file mode 100644 index 22278801..00000000 --- a/vendor/Symfony/Component/Console/Output/Output.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -use Symfony\Component\Console\Formatter\OutputFormatterInterface; -use Symfony\Component\Console\Formatter\OutputFormatter; - -/** - * Base class for output classes. - * - * There are three levels of verbosity: - * - * * normal: no option passed (normal output - information) - * * verbose: -v (more output - debug) - * * quiet: -q (no output) - * - * @author Fabien Potencier - * - * @api - */ -abstract class Output implements OutputInterface -{ - private $verbosity; - private $formatter; - - /** - * Constructor. - * - * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, self::VERBOSITY_VERBOSE) - * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) - * @param OutputFormatterInterface $formatter Output formatter instance - * - * @api - */ - public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) - { - $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity; - $this->formatter = null === $formatter ? new OutputFormatter() : $formatter; - $this->formatter->setDecorated((Boolean) $decorated); - } - - /** - * Sets output formatter. - * - * @param OutputFormatterInterface $formatter - * - * @api - */ - public function setFormatter(OutputFormatterInterface $formatter) - { - $this->formatter = $formatter; - } - - /** - * Returns current output formatter instance. - * - * @return OutputFormatterInterface - * - * @api - */ - public function getFormatter() - { - return $this->formatter; - } - - /** - * Sets the decorated flag. - * - * @param Boolean $decorated Whether to decorate the messages or not - * - * @api - */ - public function setDecorated($decorated) - { - $this->formatter->setDecorated((Boolean) $decorated); - } - - /** - * Gets the decorated flag. - * - * @return Boolean true if the output will decorate messages, false otherwise - * - * @api - */ - public function isDecorated() - { - return $this->formatter->isDecorated(); - } - - /** - * Sets the verbosity of the output. - * - * @param integer $level The level of verbosity - * - * @api - */ - public function setVerbosity($level) - { - $this->verbosity = (int) $level; - } - - /** - * Gets the current verbosity of the output. - * - * @return integer The current level of verbosity - * - * @api - */ - public function getVerbosity() - { - return $this->verbosity; - } - - /** - * Writes a message to the output and adds a newline at the end. - * - * @param string|array $messages The message as an array of lines of a single string - * @param integer $type The type of output - * - * @api - */ - public function writeln($messages, $type = 0) - { - $this->write($messages, true, $type); - } - - /** - * Writes a message to the output. - * - * @param string|array $messages The message as an array of lines of a single string - * @param Boolean $newline Whether to add a newline or not - * @param integer $type The type of output - * - * @throws \InvalidArgumentException When unknown output type is given - * - * @api - */ - public function write($messages, $newline = false, $type = 0) - { - if (self::VERBOSITY_QUIET === $this->verbosity) { - return; - } - - $messages = (array) $messages; - - foreach ($messages as $message) { - switch ($type) { - case OutputInterface::OUTPUT_NORMAL: - $message = $this->formatter->format($message); - break; - case OutputInterface::OUTPUT_RAW: - break; - case OutputInterface::OUTPUT_PLAIN: - $message = strip_tags($this->formatter->format($message)); - break; - default: - throw new \InvalidArgumentException(sprintf('Unknown output type given (%s)', $type)); - } - - $this->doWrite($message, $newline); - } - } - - /** - * Writes a message to the output. - * - * @param string $message A message to write to the output - * @param Boolean $newline Whether to add a newline or not - */ - abstract public function doWrite($message, $newline); -} diff --git a/vendor/Symfony/Component/Console/Output/OutputInterface.php b/vendor/Symfony/Component/Console/Output/OutputInterface.php deleted file mode 100644 index 8423d48c..00000000 --- a/vendor/Symfony/Component/Console/Output/OutputInterface.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -use Symfony\Component\Console\Formatter\OutputFormatterInterface; - -/** - * OutputInterface is the interface implemented by all Output classes. - * - * @author Fabien Potencier - * - * @api - */ -interface OutputInterface -{ - const VERBOSITY_QUIET = 0; - const VERBOSITY_NORMAL = 1; - const VERBOSITY_VERBOSE = 2; - - const OUTPUT_NORMAL = 0; - const OUTPUT_RAW = 1; - const OUTPUT_PLAIN = 2; - - /** - * Writes a message to the output. - * - * @param string|array $messages The message as an array of lines of a single string - * @param Boolean $newline Whether to add a newline or not - * @param integer $type The type of output - * - * @throws \InvalidArgumentException When unknown output type is given - * - * @api - */ - function write($messages, $newline = false, $type = 0); - - /** - * Writes a message to the output and adds a newline at the end. - * - * @param string|array $messages The message as an array of lines of a single string - * @param integer $type The type of output - * - * @api - */ - function writeln($messages, $type = 0); - - /** - * Sets the verbosity of the output. - * - * @param integer $level The level of verbosity - * - * @api - */ - function setVerbosity($level); - - /** - * Gets the current verbosity of the output. - * - * @return integer The current level of verbosity - * - * @api - */ - function getVerbosity(); - - /** - * Sets the decorated flag. - * - * @param Boolean $decorated Whether to decorate the messages or not - * - * @api - */ - function setDecorated($decorated); - - /** - * Gets the decorated flag. - * - * @return Boolean true if the output will decorate messages, false otherwise - * - * @api - */ - function isDecorated(); - - /** - * Sets output formatter. - * - * @param OutputFormatterInterface $formatter - * - * @api - */ - function setFormatter(OutputFormatterInterface $formatter); - - /** - * Returns current output formatter instance. - * - * @return OutputFormatterInterface - * - * @api - */ - function getFormatter(); -} diff --git a/vendor/Symfony/Component/Console/Output/StreamOutput.php b/vendor/Symfony/Component/Console/Output/StreamOutput.php deleted file mode 100644 index de1720ff..00000000 --- a/vendor/Symfony/Component/Console/Output/StreamOutput.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Output; - -use Symfony\Component\Console\Formatter\OutputFormatterInterface; - -/** - * StreamOutput writes the output to a given stream. - * - * Usage: - * - * $output = new StreamOutput(fopen('php://stdout', 'w')); - * - * As `StreamOutput` can use any stream, you can also use a file: - * - * $output = new StreamOutput(fopen('/path/to/output.log', 'a', false)); - * - * @author Fabien Potencier - * - * @api - */ -class StreamOutput extends Output -{ - private $stream; - - /** - * Constructor. - * - * @param mixed $stream A stream resource - * @param integer $verbosity The verbosity level (self::VERBOSITY_QUIET, self::VERBOSITY_NORMAL, - * self::VERBOSITY_VERBOSE) - * @param Boolean $decorated Whether to decorate messages or not (null for auto-guessing) - * @param OutputFormatter $formatter Output formatter instance - * - * @throws \InvalidArgumentException When first argument is not a real stream - * - * @api - */ - public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null) - { - if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { - throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); - } - - $this->stream = $stream; - - if (null === $decorated) { - $decorated = $this->hasColorSupport($decorated); - } - - parent::__construct($verbosity, $decorated, $formatter); - } - - /** - * Gets the stream attached to this StreamOutput instance. - * - * @return resource A stream resource - */ - public function getStream() - { - return $this->stream; - } - - /** - * Writes a message to the output. - * - * @param string $message A message to write to the output - * @param Boolean $newline Whether to add a newline or not - * - * @throws \RuntimeException When unable to write output (should never happen) - */ - public function doWrite($message, $newline) - { - if (false === @fwrite($this->stream, $message.($newline ? PHP_EOL : ''))) { - // @codeCoverageIgnoreStart - // should never happen - throw new \RuntimeException('Unable to write output.'); - // @codeCoverageIgnoreEnd - } - - fflush($this->stream); - } - - /** - * Returns true if the stream supports colorization. - * - * Colorization is disabled if not supported by the stream: - * - * - windows without ansicon - * - non tty consoles - * - * @return Boolean true if the stream supports colorization, false otherwise - */ - protected function hasColorSupport() - { - // @codeCoverageIgnoreStart - if (DIRECTORY_SEPARATOR == '\\') { - return false !== getenv('ANSICON'); - } - - return function_exists('posix_isatty') && @posix_isatty($this->stream); - // @codeCoverageIgnoreEnd - } -} diff --git a/vendor/Symfony/Component/Console/README.md b/vendor/Symfony/Component/Console/README.md deleted file mode 100644 index d903776a..00000000 --- a/vendor/Symfony/Component/Console/README.md +++ /dev/null @@ -1,48 +0,0 @@ -Console Component -================= - -Console eases the creation of beautiful and testable command line interfaces. - -The Application object manages the CLI application: - - use Symfony\Component\Console\Application; - - $console = new Application(); - $console->run(); - -The ``run()`` method parses the arguments and options passed on the command -line and executes the right command. - -Registering a new command can easily be done via the ``register()`` method, -which returns a ``Command`` instance: - - use Symfony\Component\Console\Input\InputInterface; - use Symfony\Component\Console\Input\InputArgument; - use Symfony\Component\Console\Input\InputOption; - use Symfony\Component\Console\Output\OutputInterface; - - $console - ->register('ls') - ->setDefinition(array( - new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'), - )) - ->setDescription('Displays the files in the given directory') - ->setCode(function (InputInterface $input, OutputInterface $output) { - $dir = $input->getArgument('dir'); - - $output->writeln(sprintf('Dir listing for %s', $dir)); - }) - ; - -You can also register new commands via classes. - -The component provides a lot of features like output coloring, input and -output abstractions (so that you can easily unit-test your commands), -validation, automatic help messages, ... - -Resources ---------- - -Unit tests: - -https://github.com/symfony/symfony/tree/master/tests/Symfony/Tests/Component/Console diff --git a/vendor/Symfony/Component/Console/Shell.php b/vendor/Symfony/Component/Console/Shell.php deleted file mode 100644 index 6b89b048..00000000 --- a/vendor/Symfony/Component/Console/Shell.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Input\StringInput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Process\ProcessBuilder; -use Symfony\Component\Process\PhpExecutableFinder; - -/** - * A Shell wraps an Application to add shell capabilities to it. - * - * Support for history and completion only works with a PHP compiled - * with readline support (either --with-readline or --with-libedit) - * - * @author Fabien Potencier - * @author Martin Hasoň - */ -class Shell -{ - private $application; - private $history; - private $output; - private $hasReadline; - private $prompt; - private $processIsolation; - - /** - * Constructor. - * - * If there is no readline support for the current PHP executable - * a \RuntimeException exception is thrown. - * - * @param Application $application An application instance - */ - public function __construct(Application $application) - { - $this->hasReadline = function_exists('readline'); - $this->application = $application; - $this->history = getenv('HOME').'/.history_'.$application->getName(); - $this->output = new ConsoleOutput(); - $this->prompt = $application->getName().' > '; - $this->processIsolation = false; - } - - /** - * Runs the shell. - */ - public function run() - { - $this->application->setAutoExit(false); - $this->application->setCatchExceptions(true); - - if ($this->hasReadline) { - readline_read_history($this->history); - readline_completion_function(array($this, 'autocompleter')); - } - - $this->output->writeln($this->getHeader()); - $php = null; - if ($this->processIsolation) { - $finder = new PhpExecutableFinder(); - $php = $finder->find(); - $this->output->writeln(<<Running with process isolation, you should consider this: - * each command is executed as separate process, - * commands don't support interactivity, all params must be passed explicitly, - * commands output is not colorized. - -EOF - ); - } - - while (true) { - $command = $this->readline(); - - if (false === $command) { - $this->output->writeln("\n"); - - break; - } - - if ($this->hasReadline) { - readline_add_history($command); - readline_write_history($this->history); - } - - if ($this->processIsolation) { - $pb = new ProcessBuilder(); - - $process = $pb - ->add($php) - ->add($_SERVER['argv'][0]) - ->add($command) - ->inheritEnvironmentVariables(true) - ->getProcess() - ; - - $output = $this->output; - $process->run(function($type, $data) use ($output) { - $output->writeln($data); - }); - - $ret = $process->getExitCode(); - } else { - $ret = $this->application->run(new StringInput($command), $this->output); - } - - if (0 !== $ret) { - $this->output->writeln(sprintf('The command terminated with an error status (%s)', $ret)); - } - } - } - - /** - * Returns the shell header. - * - * @return string The header string - */ - protected function getHeader() - { - return <<{$this->application->getName()} shell ({$this->application->getVersion()}). - -At the prompt, type help for some help, -or list to get a list of available commands. - -To exit the shell, type ^D. - -EOF; - } - - /** - * Tries to return autocompletion for the current entered text. - * - * @param string $text The last segment of the entered text - * @return Boolean|array A list of guessed strings or true - */ - private function autocompleter($text) - { - $info = readline_info(); - $text = substr($info['line_buffer'], 0, $info['end']); - - if ($info['point'] !== $info['end']) { - return true; - } - - // task name? - if (false === strpos($text, ' ') || !$text) { - return array_keys($this->application->all()); - } - - // options and arguments? - try { - $command = $this->application->find(substr($text, 0, strpos($text, ' '))); - } catch (\Exception $e) { - return true; - } - - $list = array('--help'); - foreach ($command->getDefinition()->getOptions() as $option) { - $list[] = '--'.$option->getName(); - } - - return $list; - } - - /** - * Reads a single line from standard input. - * - * @return string The single line from standard input - */ - private function readline() - { - if ($this->hasReadline) { - $line = readline($this->prompt); - } else { - $this->output->write($this->prompt); - $line = fgets(STDIN, 1024); - $line = (!$line && strlen($line) == 0) ? false : rtrim($line); - } - - return $line; - } - - public function getProcessIsolation() - { - return $this->processIsolation; - } - - public function setProcessIsolation($processIsolation) - { - $this->processIsolation = (Boolean) $processIsolation; - } -} diff --git a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php b/vendor/Symfony/Component/Console/Tester/ApplicationTester.php deleted file mode 100644 index 9412fbab..00000000 --- a/vendor/Symfony/Component/Console/Tester/ApplicationTester.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Tester; - -use Symfony\Component\Console\Application; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Output\StreamOutput; - -/** - * @author Fabien Potencier - */ -class ApplicationTester -{ - private $application; - private $input; - private $output; - - /** - * Constructor. - * - * @param Application $application An Application instance to test. - */ - public function __construct(Application $application) - { - $this->application = $application; - } - - /** - * Executes the application. - * - * Available options: - * - * * interactive: Sets the input interactive flag - * * decorated: Sets the output decorated flag - * * verbosity: Sets the output verbosity flag - * - * @param array $input An array of arguments and options - * @param array $options An array of options - * - * @return integer The command exit code - */ - public function run(array $input, $options = array()) - { - $this->input = new ArrayInput($input); - if (isset($options['interactive'])) { - $this->input->setInteractive($options['interactive']); - } - - $this->output = new StreamOutput(fopen('php://memory', 'w', false)); - if (isset($options['decorated'])) { - $this->output->setDecorated($options['decorated']); - } - if (isset($options['verbosity'])) { - $this->output->setVerbosity($options['verbosity']); - } - - return $this->application->run($this->input, $this->output); - } - - /** - * Gets the display returned by the last execution of the application. - * - * @return string The display - */ - public function getDisplay() - { - rewind($this->output->getStream()); - - return stream_get_contents($this->output->getStream()); - } - - /** - * Gets the input instance used by the last execution of the application. - * - * @return InputInterface The current input instance - */ - public function getInput() - { - return $this->input; - } - - /** - * Gets the output instance used by the last execution of the application. - * - * @return OutputInterface The current output instance - */ - public function getOutput() - { - return $this->output; - } -} diff --git a/vendor/Symfony/Component/Console/Tester/CommandTester.php b/vendor/Symfony/Component/Console/Tester/CommandTester.php deleted file mode 100644 index 52be2781..00000000 --- a/vendor/Symfony/Component/Console/Tester/CommandTester.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Console\Tester; - -use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\ArrayInput; -use Symfony\Component\Console\Output\StreamOutput; - -/** - * @author Fabien Potencier - */ -class CommandTester -{ - private $command; - private $input; - private $output; - - /** - * Constructor. - * - * @param Command $command A Command instance to test. - */ - public function __construct(Command $command) - { - $this->command = $command; - } - - /** - * Executes the command. - * - * Available options: - * - * * interactive: Sets the input interactive flag - * * decorated: Sets the output decorated flag - * * verbosity: Sets the output verbosity flag - * - * @param array $input An array of arguments and options - * @param array $options An array of options - * - * @return integer The command exit code - */ - public function execute(array $input, array $options = array()) - { - $this->input = new ArrayInput($input); - if (isset($options['interactive'])) { - $this->input->setInteractive($options['interactive']); - } - - $this->output = new StreamOutput(fopen('php://memory', 'w', false)); - if (isset($options['decorated'])) { - $this->output->setDecorated($options['decorated']); - } - if (isset($options['verbosity'])) { - $this->output->setVerbosity($options['verbosity']); - } - - return $this->command->run($this->input, $this->output); - } - - /** - * Gets the display returned by the last execution of the command. - * - * @return string The display - */ - public function getDisplay() - { - rewind($this->output->getStream()); - - return stream_get_contents($this->output->getStream()); - } - - /** - * Gets the input instance used by the last execution of the command. - * - * @return InputInterface The current input instance - */ - public function getInput() - { - return $this->input; - } - - /** - * Gets the output instance used by the last execution of the command. - * - * @return OutputInterface The current output instance - */ - public function getOutput() - { - return $this->output; - } -} diff --git a/vendor/Symfony/Component/Console/composer.json b/vendor/Symfony/Component/Console/composer.json deleted file mode 100644 index 961212ec..00000000 --- a/vendor/Symfony/Component/Console/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "symfony/console", - "type": "library", - "description": "Symfony Console Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.2" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\Console": "" } - }, - "target-dir": "Symfony/Component/Console", - "extra": { - "branch-alias": { - "dev-master": "2.1-dev" - } - } -}