The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below.
A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.
');
+ }
+}
diff --git a/strillonews/vendor/slim/slim/Slim/View.php b/strillonews/vendor/slim/slim/Slim/View.php
new file mode 100644
index 0000000..eff83aa
--- /dev/null
+++ b/strillonews/vendor/slim/slim/Slim/View.php
@@ -0,0 +1,282 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+namespace Slim;
+
+/**
+ * View
+ *
+ * The view is responsible for rendering a template. The view
+ * should subclass \Slim\View and implement this interface:
+ *
+ * public render(string $template);
+ *
+ * This method should render the specified template and return
+ * the resultant string.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class View
+{
+ /**
+ * Data available to the view templates
+ * @var \Slim\Helper\Set
+ */
+ protected $data;
+
+ /**
+ * Path to templates base directory (without trailing slash)
+ * @var string
+ */
+ protected $templatesDirectory;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->data = new \Slim\Helper\Set();
+ }
+
+ /********************************************************************************
+ * Data methods
+ *******************************************************************************/
+
+ /**
+ * Does view data have value with key?
+ * @param string $key
+ * @return boolean
+ */
+ public function has($key)
+ {
+ return $this->data->has($key);
+ }
+
+ /**
+ * Return view data value with key
+ * @param string $key
+ * @return mixed
+ */
+ public function get($key)
+ {
+ return $this->data->get($key);
+ }
+
+ /**
+ * Set view data value with key
+ * @param string $key
+ * @param mixed $value
+ */
+ public function set($key, $value)
+ {
+ $this->data->set($key, $value);
+ }
+
+ /**
+ * Set view data value as Closure with key
+ * @param string $key
+ * @param mixed $value
+ */
+ public function keep($key, Closure $value)
+ {
+ $this->data->keep($key, $value);
+ }
+
+ /**
+ * Return view data
+ * @return array
+ */
+ public function all()
+ {
+ return $this->data->all();
+ }
+
+ /**
+ * Replace view data
+ * @param array $data
+ */
+ public function replace(array $data)
+ {
+ $this->data->replace($data);
+ }
+
+ /**
+ * Clear view data
+ */
+ public function clear()
+ {
+ $this->data->clear();
+ }
+
+ /********************************************************************************
+ * Legacy data methods
+ *******************************************************************************/
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Get data from view
+ */
+ public function getData($key = null)
+ {
+ if (!is_null($key)) {
+ return isset($this->data[$key]) ? $this->data[$key] : null;
+ } else {
+ return $this->data->all();
+ }
+ }
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Set data for view
+ */
+ public function setData()
+ {
+ $args = func_get_args();
+ if (count($args) === 1 && is_array($args[0])) {
+ $this->data->replace($args[0]);
+ } elseif (count($args) === 2) {
+ // Ensure original behavior is maintained. DO NOT invoke stored Closures.
+ if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
+ $this->data->set($args[0], $this->data->protect($args[1]));
+ } else {
+ $this->data->set($args[0], $args[1]);
+ }
+ } else {
+ throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
+ }
+ }
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Append data to view
+ * @param array $data
+ */
+ public function appendData($data)
+ {
+ if (!is_array($data)) {
+ throw new \InvalidArgumentException('Cannot append view data. Expected array argument.');
+ }
+ $this->data->replace($data);
+ }
+
+ /********************************************************************************
+ * Resolve template paths
+ *******************************************************************************/
+
+ /**
+ * Set the base directory that contains view templates
+ * @param string $directory
+ * @throws \InvalidArgumentException If directory is not a directory
+ */
+ public function setTemplatesDirectory($directory)
+ {
+ $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR);
+ }
+
+ /**
+ * Get templates base directory
+ * @return string
+ */
+ public function getTemplatesDirectory()
+ {
+ return $this->templatesDirectory;
+ }
+
+ /**
+ * Get fully qualified path to template file using templates base directory
+ * @param string $file The template file pathname relative to templates base directory
+ * @return string
+ */
+ public function getTemplatePathname($file)
+ {
+ return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);
+ }
+
+ /********************************************************************************
+ * Rendering
+ *******************************************************************************/
+
+ /**
+ * Display template
+ *
+ * This method echoes the rendered template to the current output buffer
+ *
+ * @param string $template Pathname of template file relative to templates directory
+ * @param array $data Any additonal data to be passed to the template.
+ */
+ public function display($template, $data = null)
+ {
+ echo $this->fetch($template, $data);
+ }
+
+ /**
+ * Return the contents of a rendered template file
+ *
+ * @param string $template The template pathname, relative to the template base directory
+ * @param array $data Any additonal data to be passed to the template.
+ * @return string The rendered template
+ */
+ public function fetch($template, $data = null)
+ {
+ return $this->render($template, $data);
+ }
+
+ /**
+ * Render a template file
+ *
+ * NOTE: This method should be overridden by custom view subclasses
+ *
+ * @param string $template The template pathname, relative to the template base directory
+ * @param array $data Any additonal data to be passed to the template.
+ * @return string The rendered template
+ * @throws \RuntimeException If resolved template pathname is not a valid file
+ */
+ protected function render($template, $data = null)
+ {
+ $templatePathname = $this->getTemplatePathname($template);
+ if (!is_file($templatePathname)) {
+ throw new \RuntimeException("View cannot render `$template` because the template does not exist");
+ }
+
+ $data = array_merge($this->data->all(), (array) $data);
+ extract($data);
+ ob_start();
+ require $templatePathname;
+
+ return ob_get_clean();
+ }
+}
diff --git a/strillonews/vendor/slim/slim/composer.json b/strillonews/vendor/slim/slim/composer.json
new file mode 100644
index 0000000..0becfe6
--- /dev/null
+++ b/strillonews/vendor/slim/slim/composer.json
@@ -0,0 +1,24 @@
+{
+ "name": "slim/slim",
+ "type": "library",
+ "description": "Slim Framework, a PHP micro framework",
+ "keywords": ["microframework","rest","router"],
+ "homepage": "http://github.com/codeguy/Slim",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Josh Lockhart",
+ "email": "info@joshlockhart.com",
+ "homepage": "http://www.joshlockhart.com/"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "suggest": {
+ "ext-mcrypt": "Required for HTTP cookie encryption"
+ },
+ "autoload": {
+ "psr-0": { "Slim": "." }
+ }
+}
diff --git a/strillonews/vendor/slim/slim/index.php b/strillonews/vendor/slim/slim/index.php
new file mode 100644
index 0000000..9bfd62d
--- /dev/null
+++ b/strillonews/vendor/slim/slim/index.php
@@ -0,0 +1,169 @@
+get(
+ '/',
+ function () {
+ $template = <<
+
+
+
+ Slim Framework for PHP 5
+
+
+
+
+
+
+ Welcome to Slim!
+
+ Congratulations! Your Slim application is running. If this is
+ your first time using Slim, start with this "Hello World" Tutorial.
+
+
+
+ Slim Framework Community
+
+ Support Forum and Knowledge Base
+
+ Visit the Slim support forum and knowledge base
+ to read announcements, chat with fellow Slim users, ask questions, help others, or show off your cool
+ Slim Framework apps.
+
+
+ Twitter
+
+ Follow @slimphp on Twitter to receive the very latest news
+ and updates about the framework.
+
+
+
+ Slim Framework Extras
+
+ Custom View classes for Smarty, Twig, Mustache, and other template
+ frameworks are available online in a separate repository.
+
+ Browse the Extras Repository
+
+
+
+EOT;
+ echo $template;
+ }
+);
+
+// POST route
+$app->post(
+ '/post',
+ function () {
+ echo 'This is a POST route';
+ }
+);
+
+// PUT route
+$app->put(
+ '/put',
+ function () {
+ echo 'This is a PUT route';
+ }
+);
+
+// PATCH route
+$app->patch('/patch', function () {
+ echo 'This is a PATCH route';
+});
+
+// DELETE route
+$app->delete(
+ '/delete',
+ function () {
+ echo 'This is a DELETE route';
+ }
+);
+
+/**
+ * Step 4: Run the Slim application
+ *
+ * This method should be called last. This executes the Slim application
+ * and returns the HTTP response to the HTTP client.
+ */
+$app->run();
diff --git a/strillonews/vendor/slim/slim/phpunit.xml.dist b/strillonews/vendor/slim/slim/phpunit.xml.dist
new file mode 100644
index 0000000..c4da172
--- /dev/null
+++ b/strillonews/vendor/slim/slim/phpunit.xml.dist
@@ -0,0 +1,25 @@
+
+
+
+
+
+ ./tests/
+
+
+
+
+
+ ./Slim/
+
+
+
diff --git a/strillonews/vendor/slim/slim/tests/EnvironmentTest.php b/strillonews/vendor/slim/slim/tests/EnvironmentTest.php
new file mode 100644
index 0000000..cb2b500
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/EnvironmentTest.php
@@ -0,0 +1,378 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class EnvironmentTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Default server settings assume the Slim app is installed
+ * in a subdirectory `foo/` directly beneath the public document
+ * root directory; URL rewrite is disabled; requested app
+ * resource is GET `/bar/xyz` with three query params.
+ *
+ * These only provide a common baseline for the following
+ * tests; tests are free to override these values.
+ */
+ public function setUp()
+ {
+ $_SERVER['DOCUMENT_ROOT'] = '/var/www';
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/foo/index.php';
+ $_SERVER['SERVER_NAME'] = 'slim';
+ $_SERVER['SERVER_PORT'] = '80';
+ $_SERVER['SCRIPT_NAME'] = '/foo/index.php';
+ $_SERVER['REQUEST_URI'] = '/foo/index.php/bar/xyz';
+ $_SERVER['PATH_INFO'] = '/bar/xyz';
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $_SERVER['QUERY_STRING'] = 'one=1&two=2&three=3';
+ $_SERVER['HTTPS'] = '';
+ $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
+ unset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH']);
+ }
+
+ /**
+ * Test mock environment
+ *
+ * This should return the custom values where specified
+ * and the default values otherwise.
+ */
+ public function testMockEnvironment()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT'
+ ));
+ $env2 = \Slim\Environment::getInstance();
+ $this->assertSame($env, $env2);
+ $this->assertInstanceOf('\Slim\Environment', $env);
+ $this->assertEquals('PUT', $env['REQUEST_METHOD']);
+ $this->assertEquals(80, $env['SERVER_PORT']);
+ $this->assertNull($env['foo']);
+ }
+
+ /**
+ * Test sets HTTP method
+ */
+ public function testSetsHttpMethod()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('GET', $env['REQUEST_METHOD']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite is disabled;
+ * App installed in subdirectory;
+ */
+ public function testParsesPathsWithoutUrlRewriteInSubdirectory()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/bar/xyz', $env['PATH_INFO']);
+ $this->assertEquals('/foo/index.php', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite is disabled;
+ * App installed in root directory;
+ */
+ public function testParsesPathsWithoutUrlRewriteInRootDirectory()
+ {
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
+ $_SERVER['REQUEST_URI'] = '/index.php/bar/xyz';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/bar/xyz', $env['PATH_INFO']);
+ $this->assertEquals('/index.php', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite disabled;
+ * App installed in root directory;
+ * Requested resource is "/";
+ */
+ public function testParsesPathsWithoutUrlRewriteInRootDirectoryForAppRootUri()
+ {
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
+ $_SERVER['REQUEST_URI'] = '/index.php';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ unset($_SERVER['PATH_INFO']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/', $env['PATH_INFO']);
+ $this->assertEquals('/index.php', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite enabled;
+ * App installed in subdirectory;
+ */
+ public function testParsesPathsWithUrlRewriteInSubdirectory()
+ {
+ $_SERVER['SCRIPT_NAME'] = '/foo/index.php';
+ $_SERVER['REQUEST_URI'] = '/foo/bar/xyz';
+ unset($_SERVER['PATH_INFO']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/bar/xyz', $env['PATH_INFO']);
+ $this->assertEquals('/foo', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite enabled;
+ * App installed in root directory;
+ */
+ public function testParsesPathsWithUrlRewriteInRootDirectory()
+ {
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ $_SERVER['REQUEST_URI'] = '/bar/xyz';
+ unset($_SERVER['PATH_INFO']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/bar/xyz', $env['PATH_INFO']);
+ $this->assertEquals('', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses script name and path info
+ *
+ * Pre-conditions:
+ * URL Rewrite enabled;
+ * App installed in root directory;
+ * Requested resource is "/"
+ */
+ public function testParsesPathsWithUrlRewriteInRootDirectoryForAppRootUri()
+ {
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
+ $_SERVER['REQUEST_URI'] = '/';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ unset($_SERVER['PATH_INFO']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/', $env['PATH_INFO']);
+ $this->assertEquals('', $env['SCRIPT_NAME']);
+ }
+
+ /**
+ * Test parses query string
+ *
+ * Pre-conditions:
+ * $_SERVER['QUERY_STRING'] exists and is not empty;
+ */
+ public function testParsesQueryString()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('one=1&two=2&three=3', $env['QUERY_STRING']);
+ }
+
+ /**
+ * Test removes query string from PATH_INFO when using URL Rewrite
+ *
+ * Pre-conditions:
+ * $_SERVER['QUERY_STRING'] exists and is not empty;
+ * URL Rewrite enabled;
+ */
+ public function testRemovesQueryStringFromPathInfo()
+ {
+ $_SERVER['SCRIPT_NAME'] = '/foo/index.php';
+ $_SERVER['REQUEST_URI'] = '/foo/bar/xyz?one=1&two=2&three=3';
+ unset($_SERVER['PATH_INFO']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/bar/xyz', $env['PATH_INFO']);
+ }
+
+ /**
+ * Test environment's PATH_INFO retains URL encoded characters (e.g. #)
+ *
+ * In earlier version, \Slim\Environment would use PATH_INFO instead
+ * of REQUEST_URI to determine the root URI and resource URI.
+ * Unfortunately, the server would URL decode the PATH_INFO string
+ * before it was handed to PHP. This prevented certain URL-encoded
+ * characters like the octothorpe from being delivered correctly to
+ * the Slim application environment. This test ensures the
+ * REQUEST_URI is used instead and parsed as expected.
+ */
+ public function testPathInfoRetainsUrlEncodedCharacters()
+ {
+ $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php';
+ $_SERVER['SCRIPT_NAME'] = '/index.php';
+ $_SERVER['REQUEST_URI'] = '/foo/%23bar'; //<-- URL-encoded "#bar"
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('/foo/%23bar', $env['PATH_INFO']);
+ }
+
+ /**
+ * Test parses query string
+ *
+ * Pre-conditions:
+ * $_SERVER['QUERY_STRING'] does not exist;
+ */
+ public function testParsesQueryStringThatDoesNotExist()
+ {
+ unset($_SERVER['QUERY_STRING']);
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('', $env['QUERY_STRING']);
+ }
+
+ /**
+ * Test SERVER_NAME is not empty
+ */
+ public function testServerNameIsNotEmpty()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertFalse(empty($env['SERVER_NAME']));
+ }
+
+ /**
+ * Test SERVER_PORT is not empty
+ */
+ public function testServerPortIsNotEmpty()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertFalse(empty($env['SERVER_PORT']));
+ }
+
+ /**
+ * Test unsets HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH
+ *
+ * Pre-conditions:
+ * HTTP_CONTENT_TYPE is sent with HTTP request;
+ * HTTP_CONTENT_LENGTH is sent with HTTP request;
+ */
+ public function testUnsetsContentTypeAndContentLength()
+ {
+ $_SERVER['HTTP_CONTENT_TYPE'] = 'text/csv';
+ $_SERVER['HTTP_CONTENT_LENGTH'] = 150;
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertFalse(isset($env['HTTP_CONTENT_TYPE']));
+ $this->assertFalse(isset($env['HTTP_CONTENT_LENGTH']));
+ }
+
+ /**
+ * Test sets special request headers if not empty
+ *
+ * Pre-conditions:
+ * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are sent in client HTTP request;
+ * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are not empty;
+ */
+ public function testSetsSpecialHeaders()
+ {
+ $_SERVER['CONTENT_TYPE'] = 'text/csv';
+ $_SERVER['CONTENT_LENGTH'] = '100';
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XmlHttpRequest';
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('text/csv', $env['CONTENT_TYPE']);
+ $this->assertEquals('100', $env['CONTENT_LENGTH']);
+ $this->assertEquals('XmlHttpRequest', $env['HTTP_X_REQUESTED_WITH']);
+ }
+
+ /**
+ * Tests X-HTTP-Method-Override is allowed through unmolested.
+ *
+ * Pre-conditions:
+ * X_HTTP_METHOD_OVERRIDE is sent in client HTTP request;
+ * X_HTTP_METHOD_OVERRIDE is not empty;
+ */
+ public function testSetsHttpMethodOverrideHeader() {
+ $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'DELETE';
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('DELETE', $env['HTTP_X_HTTP_METHOD_OVERRIDE']);
+ }
+
+ /**
+ * Test detects HTTPS
+ *
+ * Pre-conditions:
+ * $_SERVER['HTTPS'] is set to a non-empty value;
+ */
+ public function testHttps()
+ {
+ $_SERVER['HTTPS'] = 1;
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('https', $env['slim.url_scheme']);
+ }
+
+ /**
+ * Test detects not HTTPS
+ *
+ * Pre-conditions:
+ * $_SERVER['HTTPS'] is set to an empty value;
+ */
+ public function testNotHttps()
+ {
+ $_SERVER['HTTPS'] = '';
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('http', $env['slim.url_scheme']);
+ }
+
+ /**
+ * Test detects not HTTPS on IIS
+ *
+ * Pre-conditions:
+ * $_SERVER['HTTPS'] is set to "off";
+ */
+ public function testNotHttpsIIS()
+ {
+ $_SERVER['HTTPS'] = 'off';
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('http', $env['slim.url_scheme']);
+ }
+
+ /**
+ * Test input is an empty string (and not false)
+ *
+ * Pre-conditions:
+ * Input at php://input may only be read once; subsequent attempts
+ * will return `false`; in which case, use an empty string.
+ */
+ public function testInputIsEmptyString()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertEquals('', $env['slim.input']);
+ }
+
+ /**
+ * Test valid resource handle to php://stdErr
+ */
+ public function testErrorResource()
+ {
+ $env = \Slim\Environment::getInstance(true);
+ $this->assertTrue(is_resource($env['slim.errors']));
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Foo.php b/strillonews/vendor/slim/slim/tests/Foo.php
new file mode 100644
index 0000000..d772d02
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Foo.php
@@ -0,0 +1,7 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class SetTest extends PHPUnit_Framework_TestCase
+{
+ protected $bag;
+ protected $property;
+
+ public function setUp()
+ {
+ $this->bag = new \Slim\Helper\Set();
+ $this->property = new \ReflectionProperty($this->bag, 'data');
+ $this->property->setAccessible(true);
+ }
+
+ public function testSet()
+ {
+ $this->bag->set('foo', 'bar');
+ $this->assertArrayHasKey('foo', $this->property->getValue($this->bag));
+ $bag = $this->property->getValue($this->bag);
+ $this->assertEquals('bar', $bag['foo']);
+ }
+
+ public function testGet()
+ {
+ $this->property->setValue($this->bag, array('foo' => 'bar'));
+ $this->assertEquals('bar', $this->bag->get('foo'));
+ }
+
+ public function testGetNotExists()
+ {
+ $this->property->setValue($this->bag, array('foo' => 'bar'));
+ $this->assertEquals('default', $this->bag->get('abc', 'default'));
+ }
+
+ public function testAdd()
+ {
+ $this->bag->replace(array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ ));
+ $this->assertArrayHasKey('abc', $this->property->getValue($this->bag));
+ $this->assertArrayHasKey('foo', $this->property->getValue($this->bag));
+ $bag = $this->property->getValue($this->bag);
+ $this->assertEquals('123', $bag['abc']);
+ $this->assertEquals('bar', $bag['foo']);
+ }
+
+ public function testAll()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertEquals($data, $this->bag->all());
+ }
+
+ public function testKeys()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertEquals(array('abc', 'foo'), $this->bag->keys());
+ }
+
+ public function testRemove()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->bag->remove('foo');
+ $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag));
+ }
+
+ public function testClear()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->bag->clear();
+ $this->assertEquals(array(), $this->property->getValue($this->bag));
+ }
+
+ public function testArrayAccessGet()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertEquals('bar', $this->bag['foo']);
+ }
+
+ public function testArrayAccessSet()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->bag['foo'] = 'changed';
+ $bag = $this->property->getValue($this->bag);
+ $this->assertEquals('changed', $bag['foo']);
+ }
+
+ public function testArrayAccessExists()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertTrue(isset($this->bag['foo']));
+ $this->assertFalse(isset($this->bag['bar']));
+ }
+
+ public function testArrayAccessUnset()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ unset($this->bag['foo']);
+ $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag));
+ }
+
+ public function testCount()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertEquals(2, count($this->bag));
+ }
+
+ public function testGetIterator()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+ $this->assertInstanceOf('\ArrayIterator', $this->bag->getIterator());
+ }
+
+ public function testPropertyOverloadGet()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+
+ $this->assertEquals('123', $this->bag->abc);
+ $this->assertEquals('bar', $this->bag->foo);
+ }
+
+ public function testPropertyOverloadSet()
+ {
+ $this->bag->foo = 'bar';
+ $this->assertArrayHasKey('foo', $this->property->getValue($this->bag));
+ $this->assertEquals('bar', $this->bag->foo);
+ }
+
+ public function testPropertyOverloadingIsset()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+
+ $this->assertTrue(isset($this->bag->abc));
+ $this->assertTrue(isset($this->bag->foo));
+ $this->assertFalse(isset($this->bag->foobar));
+ }
+
+ public function testPropertyOverloadingUnset()
+ {
+ $data = array(
+ 'abc' => '123',
+ 'foo' => 'bar'
+ );
+ $this->property->setValue($this->bag, $data);
+
+ $this->assertTrue(isset($this->bag->abc));
+ unset($this->bag->abc);
+ $this->assertFalse(isset($this->bag->abc));
+ $this->assertArrayNotHasKey('abc', $this->property->getValue($this->bag));
+ $this->assertArrayHasKey('foo', $this->property->getValue($this->bag));
+ }
+
+ public function testProtect()
+ {
+ $callable = function () {
+ return 'foo';
+ };
+ $result = $this->bag->protect($callable);
+
+ $this->assertInstanceOf('\Closure', $result);
+ $this->assertSame($callable, $result());
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Http/CookiesTest.php b/strillonews/vendor/slim/slim/tests/Http/CookiesTest.php
new file mode 100644
index 0000000..e73d44f
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Http/CookiesTest.php
@@ -0,0 +1,92 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+class CookiesTest extends PHPUnit_Framework_TestCase
+{
+ public function testSetWithStringValue()
+ {
+ $c = new \Slim\Http\Cookies();
+ $c->set('foo', 'bar');
+ $this->assertAttributeEquals(
+ array(
+ 'foo' => array(
+ 'value' => 'bar',
+ 'expires' => null,
+ 'domain' => null,
+ 'path' => null,
+ 'secure' => false,
+ 'httponly' => false
+ )
+ ),
+ 'data',
+ $c
+ );
+ }
+
+ public function testSetWithArrayValue()
+ {
+ $now = time();
+ $c = new \Slim\Http\Cookies();
+ $c->set('foo', array(
+ 'value' => 'bar',
+ 'expires' => $now + 86400,
+ 'domain' => '.example.com',
+ 'path' => '/',
+ 'secure' => true,
+ 'httponly' => true
+ ));
+ $this->assertAttributeEquals(
+ array(
+ 'foo' => array(
+ 'value' => 'bar',
+ 'expires' => $now + 86400,
+ 'domain' => '.example.com',
+ 'path' => '/',
+ 'secure' => true,
+ 'httponly' => true
+ )
+ ),
+ 'data',
+ $c
+ );
+ }
+
+ public function testRemove()
+ {
+ $c = new \Slim\Http\Cookies();
+ $c->remove('foo');
+ $prop = new \ReflectionProperty($c, 'data');
+ $prop->setAccessible(true);
+ $cValue = $prop->getValue($c);
+ $this->assertEquals('', $cValue['foo']['value']);
+ $this->assertLessThan(time(), $cValue['foo']['expires']);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Http/HeadersTest.php b/strillonews/vendor/slim/slim/tests/Http/HeadersTest.php
new file mode 100644
index 0000000..4245806
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Http/HeadersTest.php
@@ -0,0 +1,59 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class HeadersTest extends PHPUnit_Framework_TestCase
+{
+ public function testNormalizesKey()
+ {
+ $h = new \Slim\Http\Headers();
+ $h->set('Http_Content_Type', 'text/html');
+ $prop = new \ReflectionProperty($h, 'data');
+ $prop->setAccessible(true);
+ $this->assertArrayHasKey('Content-Type', $prop->getValue($h));
+ }
+
+ public function testExtractHeaders()
+ {
+ $test = array(
+ 'HTTP_HOST' => 'foo.com',
+ 'SERVER_NAME' => 'foo',
+ 'CONTENT_TYPE' => 'text/html',
+ 'X_FORWARDED_FOR' => '127.0.0.1'
+ );
+ $results = \Slim\Http\Headers::extract($test);
+ $this->assertEquals(array(
+ 'HTTP_HOST' => 'foo.com',
+ 'CONTENT_TYPE' => 'text/html',
+ 'X_FORWARDED_FOR' => '127.0.0.1'
+ ), $results);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Http/RequestTest.php b/strillonews/vendor/slim/slim/tests/Http/RequestTest.php
new file mode 100644
index 0000000..9ffea71
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Http/RequestTest.php
@@ -0,0 +1,939 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class RequestTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test sets HTTP method
+ */
+ public function testGetMethod()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('GET', $req->getMethod());
+ }
+
+ /**
+ * Test HTTP GET method detection
+ */
+ public function testIsGet()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isGet());
+ }
+
+ /**
+ * Test HTTP POST method detection
+ */
+ public function testIsPost()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isPost());
+ }
+
+ /**
+ * Test HTTP PUT method detection
+ */
+ public function testIsPut()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isPut());
+ }
+
+ /**
+ * Test HTTP DELETE method detection
+ */
+ public function testIsDelete()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'DELETE',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isDelete());
+ }
+
+ /**
+ * Test HTTP OPTIONS method detection
+ */
+ public function testIsOptions()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'OPTIONS',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isOptions());
+ }
+
+ /**
+ * Test HTTP HEAD method detection
+ */
+ public function testIsHead()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'HEAD',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isHead());
+ }
+
+ /**
+ * Test HTTP PATCH method detection
+ */
+ public function testIsPatch()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isPatch());
+ }
+
+ /**
+ * Test AJAX method detection w/ header
+ */
+ public function testIsAjaxWithHeader()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'X_REQUESTED_WITH' => 'XMLHttpRequest'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isAjax());
+ $this->assertTrue($req->isXhr());
+ }
+
+ /**
+ * Test AJAX method detection w/ query parameter
+ */
+ public function testIsAjaxWithQueryParameter()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'QUERY_STRING' => 'isajax=1',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isAjax());
+ $this->assertTrue($req->isXhr());
+ }
+
+ /**
+ * Test AJAX method detection without header or query parameter
+ */
+ public function testIsAjaxWithoutHeaderOrQueryParameter()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $this->assertFalse($req->isAjax());
+ $this->assertFalse($req->isXhr());
+ }
+
+ /**
+ * Test AJAX method detection with misspelled header
+ */
+ public function testIsAjaxWithMisspelledHeader()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'X_REQUESTED_WITH' => 'foo'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertFalse($req->isAjax());
+ $this->assertFalse($req->isXhr());
+ }
+
+ /**
+ * Test params from query string
+ */
+ public function testParamsFromQueryString()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'QUERY_STRING' => 'one=1&two=2&three=3'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(3, count($req->params()));
+ $this->assertEquals('1', $req->params('one'));
+ $this->assertNull($req->params('foo'));
+ }
+
+ /**
+ * Test params from request body
+ */
+ public function testParamsFromRequestBody()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'QUERY_STRING' => 'one=1&two=2&three=3',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(5, count($req->params())); //Union of GET and POST
+ $this->assertEquals('bar', $req->params('foo'));
+ }
+
+ /**
+ * Test fetch GET params
+ */
+ public function testGet()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'QUERY_STRING' => 'one=1&two=2&three=3'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(3, count($req->get()));
+ $this->assertEquals('1', $req->get('one'));
+ $this->assertNull($req->get('foo'));
+ $this->assertFalse($req->get('foo', false));
+ }
+
+ /**
+ * Test fetch GET params without multibyte
+ */
+ public function testGetWithoutMultibyte()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'QUERY_STRING' => 'one=1&two=2&three=3',
+ 'slim.tests.ignore_multibyte' => true
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(3, count($req->get()));
+ $this->assertEquals('1', $req->get('one'));
+ $this->assertNull($req->get('foo'));
+ $this->assertFalse($req->get('foo', false));
+ }
+
+ /**
+ * Test fetch POST params
+ */
+ public function testPost()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->post()));
+ $this->assertEquals('bar', $req->post('foo'));
+ $this->assertNull($req->post('xyz'));
+ $this->assertFalse($req->post('xyz', false));
+ }
+
+ /**
+ * Test fetch POST params without multibyte
+ */
+ public function testPostWithoutMultibyte()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15,
+ 'slim.tests.ignore_multibyte' => true
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->post()));
+ $this->assertEquals('bar', $req->post('foo'));
+ $this->assertNull($req->post('xyz'));
+ $this->assertFalse($req->post('xyz', false));
+ }
+
+ /**
+ * Test fetch POST without slim.input
+ */
+ public function testPostWithoutInput()
+ {
+ $this->setExpectedException('RuntimeException');
+ $env = \Slim\Environment::mock();
+ unset($env['slim.input']);
+ $req = new \Slim\Http\Request($env);
+ $req->post('foo');
+ }
+
+ /**
+ * Test fetch POST params even if multipart/form-data request
+ */
+ public function testPostWithMultipartRequest()
+ {
+ $_POST = array('foo' => 'bar'); //<-- Set by PHP
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'slim.input' => '', //<-- "php://input" is empty for multipart/form-data requests
+ 'CONTENT_TYPE' => 'multipart/form-data',
+ 'CONTENT_LENGTH' => 0
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(1, count($req->post()));
+ $this->assertEquals('bar', $req->post('foo'));
+ $this->assertNull($req->post('xyz'));
+ }
+
+ /**
+ * Test fetch PUT params
+ */
+ public function testPut()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->put()));
+ $this->assertEquals('bar', $req->put('foo'));
+ $this->assertEquals('bar', $req->params('foo'));
+ $this->assertNull($req->put('xyz'));
+ $this->assertFalse($req->put('xyz', false));
+ }
+
+ /**
+ * Test fetch PATCH params
+ */
+ public function testPatch()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->patch()));
+ $this->assertEquals('bar', $req->patch('foo'));
+ $this->assertEquals('bar', $req->params('foo'));
+ $this->assertNull($req->patch('xyz'));
+ $this->assertFalse($req->patch('xyz', false));
+ }
+
+ /**
+ * Test fetch DELETE params
+ */
+ public function testDelete()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'DELETE',
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->delete()));
+ $this->assertEquals('bar', $req->delete('foo'));
+ $this->assertEquals('bar', $req->params('foo'));
+ $this->assertNull($req->delete('xyz'));
+ $this->assertFalse($req->delete('xyz', false));
+ }
+
+ /**
+ * Test fetch COOKIE params
+ */
+ public function testCookies()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_COOKIE' => 'foo=bar; abc=123'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(2, count($req->cookies()));
+ $this->assertEquals('bar', $req->cookies('foo'));
+ $this->assertNull($req->cookies('xyz'));
+ }
+
+ /**
+ * Test is form data
+ */
+ public function testIsFormDataContentFormUrlencoded()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isFormData());
+ }
+
+ /**
+ * Test is form data
+ */
+ public function testIsFormDataPostContentUnknown()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'slim.input' => '',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isFormData());
+ }
+
+ /**
+ * Test is form data
+ */
+ public function testIsFormDataPostContentUnknownWithMethodOverride()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT',
+ ));
+ $env['slim.method_override.original_method'] = 'POST';
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue($req->isPut());
+ $this->assertTrue($req->isFormData());
+ }
+
+ /**
+ * Test is not form data
+ */
+ public function testIsNotFormData()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/json'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertFalse($req->isFormData());
+ }
+
+ /**
+ * Test headers
+ */
+ public function testHeaders()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_ACCEPT_ENCODING' => 'gzip'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $headers = $req->headers();
+ $this->assertInstanceOf('\Slim\Http\Headers', $headers);
+ $this->assertEquals('gzip', $req->headers('HTTP_ACCEPT_ENCODING'));
+ $this->assertEquals('gzip', $req->headers('HTTP-ACCEPT-ENCODING'));
+ $this->assertEquals('gzip', $req->headers('http_accept_encoding'));
+ $this->assertEquals('gzip', $req->headers('http-accept-encoding'));
+ $this->assertEquals('gzip', $req->headers('ACCEPT_ENCODING'));
+ $this->assertEquals('gzip', $req->headers('ACCEPT-ENCODING'));
+ $this->assertEquals('gzip', $req->headers('accept_encoding'));
+ $this->assertEquals('gzip', $req->headers('accept-encoding'));
+ $this->assertNull($req->headers('foo'));
+ }
+
+ /**
+ * Test accurately removes HTTP_ prefix from input header name
+ */
+ public function testHeaderRemovesHttpPrefix()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'X_HTTP_METHOD_OVERRIDE' => 'PUT',
+ 'CONTENT_TYPE' => 'application/json'
+ ));
+ //fwrite(fopen('php://stdout', 'w'), print_r($env, true));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('PUT', $req->headers('X_HTTP_METHOD_OVERRIDE'));
+ $this->assertNull($req->headers('X_METHOD_OVERRIDE')); //<-- Ensures `HTTP_` is not removed if not prefix
+ $this->assertEquals('application/json', $req->headers('HTTP_CONTENT_TYPE')); //<-- Ensures `HTTP_` is removed if prefix
+ }
+
+ /**
+ * Test get body
+ */
+ public function testGetBodyWhenExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('foo=bar&abc=123', $req->getBody());
+ }
+
+ /**
+ * Test get body
+ */
+ public function testGetBodyWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('', $req->getBody());
+ }
+
+ /**
+ * Test get content type
+ */
+ public function testGetContentTypeWhenExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType());
+ }
+
+ /**
+ * Test get content type
+ */
+ public function testGetContentTypeWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $this->assertNull($req->getContentType());
+ }
+
+ /**
+ * Test get media type
+ */
+ public function testGetMediaTypeWhenExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'CONTENT_TYPE' => 'application/json;charset=utf-8'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('application/json', $req->getMediaType());
+ }
+
+ /**
+ * Test get media type
+ */
+ public function testGetMediaTypeWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $this->assertNull($req->getMediaType());
+ }
+
+ /**
+ * Test get media type
+ */
+ public function testGetMediaTypeWhenNoParamsExist()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/json'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('application/json', $req->getMediaType());
+ }
+
+ /**
+ * Test get media type params
+ */
+ public function testGetMediaTypeParams()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $params = $req->getMediaTypeParams();
+ $this->assertEquals(1, count($params));
+ $this->assertArrayHasKey('charset', $params);
+ $this->assertEquals('ISO-8859-4', $params['charset']);
+ }
+
+ /**
+ * Test get media type params
+ */
+ public function testGetMediaTypeParamsWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $params = $req->getMediaTypeParams();
+ $this->assertTrue(is_array($params));
+ $this->assertEquals(0, count($params));
+ }
+
+ /**
+ * Test get content charset
+ */
+ public function testGetContentCharset()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('ISO-8859-4', $req->getContentCharset());
+ }
+
+ /**
+ * Test get content charset
+ */
+ public function testGetContentCharsetWhenNotExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ 'CONTENT_TYPE' => 'application/json'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertNull($req->getContentCharset());
+ }
+
+ /**
+ * Test get content length
+ */
+ public function testGetContentLength()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => 'foo=bar&abc=123',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 15
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(15, $req->getContentLength());
+ }
+
+ /**
+ * Test get content length
+ */
+ public function testGetContentLengthWhenNotExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.input' => '',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals(0, $req->getContentLength());
+ }
+
+ /**
+ * Test get host
+ */
+ public function testGetHost()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SERVER_NAME' => 'slim',
+ 'HTTP_HOST' => 'slimframework.com'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available
+ }
+
+ /**
+ * Test get host when it has a port number
+ */
+ public function testGetHostAndStripPort()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SERVER_NAME' => 'slim',
+ 'HTTP_HOST' => 'slimframework.com:80'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available
+ }
+
+ /**
+ * Test get host
+ */
+ public function testGetHostWhenNotExists()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SERVER_NAME' => 'slim',
+ 'HTTP_HOST' => 'slimframework.com'
+ ));
+ unset($env['HTTP_HOST']);
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('slim', $req->getHost()); //Uses SERVER_NAME as backup
+ }
+
+ /**
+ * Test get host with port
+ */
+ public function testGetHostWithPort()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_HOST' => 'slimframework.com',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 80,
+ 'slim.url_scheme' => 'http'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('slimframework.com:80', $req->getHostWithPort());
+ }
+
+ /**
+ * Test get host with port doesn't duplicate port numbers
+ */
+ public function testGetHostDoesntDuplicatePort()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_HOST' => 'slimframework.com:80',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 80,
+ 'slim.url_scheme' => 'http'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('slimframework.com:80', $req->getHostWithPort());
+ }
+
+ /**
+ * Test get port
+ */
+ public function testGetPort()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SERVER_PORT' => 80
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertTrue(is_integer($req->getPort()));
+ $this->assertEquals(80, $req->getPort());
+ }
+
+ /**
+ * Test get scheme
+ */
+ public function testGetSchemeIfHttp()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.url_scheme' => 'http'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('http', $req->getScheme());
+ }
+
+ /**
+ * Test get scheme
+ */
+ public function testGetSchemeIfHttps()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'slim.url_scheme' => 'https',
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('https', $req->getScheme());
+ }
+
+ /**
+ * Test get [script name, root uri, path, path info, resource uri] in subdirectory without htaccess
+ */
+ public function testAppPathsInSubdirectoryWithoutHtaccess()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical
+ 'PATH_INFO' => '/bar/xyz', //<-- Virtual
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('/foo/index.php', $req->getScriptName());
+ $this->assertEquals('/foo/index.php', $req->getRootUri());
+ $this->assertEquals('/foo/index.php/bar/xyz', $req->getPath());
+ $this->assertEquals('/bar/xyz', $req->getPathInfo());
+ $this->assertEquals('/bar/xyz', $req->getResourceUri());
+ }
+
+ /**
+ * Test get [script name, root uri, path, path info, resource uri] in subdirectory with htaccess
+ */
+ public function testAppPathsInSubdirectoryWithHtaccess()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar/xyz', //<-- Virtual
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('/foo', $req->getScriptName());
+ $this->assertEquals('/foo', $req->getRootUri());
+ $this->assertEquals('/foo/bar/xyz', $req->getPath());
+ $this->assertEquals('/bar/xyz', $req->getPathInfo());
+ $this->assertEquals('/bar/xyz', $req->getResourceUri());
+ }
+
+ /**
+ * Test get [script name, root uri, path, path info, resource uri] in root directory without htaccess
+ */
+ public function testAppPathsInRootDirectoryWithoutHtaccess()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php', //<-- Physical
+ 'PATH_INFO' => '/bar/xyz', //<-- Virtual
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('/index.php', $req->getScriptName());
+ $this->assertEquals('/index.php', $req->getRootUri());
+ $this->assertEquals('/index.php/bar/xyz', $req->getPath());
+ $this->assertEquals('/bar/xyz', $req->getPathInfo());
+ $this->assertEquals('/bar/xyz', $req->getResourceUri());
+ }
+
+ /**
+ * Test get [script name, root uri, path, path info, resource uri] in root directory with htaccess
+ */
+ public function testAppPathsInRootDirectoryWithHtaccess()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '', //<-- Physical
+ 'PATH_INFO' => '/bar/xyz', //<-- Virtual
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('', $req->getScriptName());
+ $this->assertEquals('', $req->getRootUri());
+ $this->assertEquals('/bar/xyz', $req->getPath());
+ $this->assertEquals('/bar/xyz', $req->getPathInfo());
+ $this->assertEquals('/bar/xyz', $req->getResourceUri());
+ }
+
+ /**
+ * Test get URL
+ */
+ public function testGetUrl()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_HOST' => 'slimframework.com',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 80,
+ 'slim.url_scheme' => 'http'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('http://slimframework.com', $req->getUrl());
+ }
+
+ /**
+ * Test get URL
+ */
+ public function testGetUrlWithCustomPort()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_HOST' => 'slimframework.com',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 8080,
+ 'slim.url_scheme' => 'http'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('http://slimframework.com:8080', $req->getUrl());
+ }
+
+ /**
+ * Test get URL
+ */
+ public function testGetUrlWithHttps()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_HOST' => 'slimframework.com',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 443,
+ 'slim.url_scheme' => 'https'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('https://slimframework.com', $req->getUrl());
+ }
+
+ /**
+ * Test get IP
+ */
+ public function testGetIp()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REMOTE_ADDR' => '127.0.0.1'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('127.0.0.1', $req->getIp());
+ }
+
+ /**
+ * Test get IP with proxy server and Client-Ip header
+ */
+ public function testGetIpWithClientIp()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'CLIENT_IP' => '127.0.0.2'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('127.0.0.2', $req->getIp());
+ }
+
+ /**
+ * Test get IP with proxy server and X-Forwarded-For header
+ */
+ public function testGetIpWithForwardedFor()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'CLIENT_IP' => '127.0.0.2',
+ 'X_FORWARDED_FOR' => '127.0.0.3'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('127.0.0.3', $req->getIp());
+ }
+
+ /**
+ * Test get referer
+ */
+ public function testGetReferrer()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_REFERER' => 'http://foo.com'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('http://foo.com', $req->getReferrer());
+ $this->assertEquals('http://foo.com', $req->getReferer());
+ }
+
+ /**
+ * Test get referer
+ */
+ public function testGetReferrerWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ $req = new \Slim\Http\Request($env);
+ $this->assertNull($req->getReferrer());
+ $this->assertNull($req->getReferer());
+ }
+
+ /**
+ * Test get user agent string
+ */
+ public function testGetUserAgent()
+ {
+ $env = \Slim\Environment::mock(array(
+ 'HTTP_USER_AGENT' => 'user-agent-string'
+ ));
+ $req = new \Slim\Http\Request($env);
+ $this->assertEquals('user-agent-string', $req->getUserAgent());
+ }
+
+ /**
+ * Test get user agent string when not set
+ */
+ public function testGetUserAgentWhenNotExists()
+ {
+ $env = \Slim\Environment::mock();
+ unset($env['HTTP_USER_AGENT']);
+ $req = new \Slim\Http\Request($env);
+ $this->assertNull($req->getUserAgent());
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Http/ResponseTest.php b/strillonews/vendor/slim/slim/tests/Http/ResponseTest.php
new file mode 100644
index 0000000..0b80445
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Http/ResponseTest.php
@@ -0,0 +1,271 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class ResponseTest extends PHPUnit_Framework_TestCase
+{
+ public function testConstructWithoutArgs()
+ {
+ $res = new \Slim\Http\Response();
+
+ $this->assertAttributeEquals(200, 'status', $res);
+ $this->assertAttributeEquals('', 'body', $res);
+ }
+
+ public function testConstructWithArgs()
+ {
+ $res = new \Slim\Http\Response('Foo', 201);
+
+ $this->assertAttributeEquals(201, 'status', $res);
+ $this->assertAttributeEquals('Foo', 'body', $res);
+ }
+
+ public function testGetStatus()
+ {
+ $res = new \Slim\Http\Response();
+
+ $this->assertEquals(200, $res->getStatus());
+ }
+
+ public function testSetStatus()
+ {
+ $res = new \Slim\Http\Response();
+ $res->setStatus(301);
+
+ $this->assertAttributeEquals(301, 'status', $res);
+ }
+
+ /**
+ * DEPRECATION WARNING!
+ */
+ public function testStatusGetOld()
+ {
+ $res = new \Slim\Http\Response('', 201);
+ $this->assertEquals(201, $res->status());
+ }
+
+ /**
+ * DEPRECATION WARNING!
+ */
+ public function testStatusSetOld()
+ {
+ $res = new \Slim\Http\Response();
+ $prop = new \ReflectionProperty($res, 'status');
+ $prop->setAccessible(true);
+ $res->status(301);
+
+ $this->assertEquals(301, $prop->getValue($res));
+ }
+
+ public function testGetBody()
+ {
+ $res = new \Slim\Http\Response();
+ $property = new \ReflectionProperty($res, 'body');
+ $property->setAccessible(true);
+ $property->setValue($res, 'foo');
+
+ $this->assertEquals('foo', $res->getBody());
+ }
+
+ public function testSetBody()
+ {
+ $res = new \Slim\Http\Response('bar');
+ $res->setBody('foo'); // <-- Should replace body
+
+ $this->assertAttributeEquals('foo', 'body', $res);
+ }
+
+ public function testWrite()
+ {
+ $res = new \Slim\Http\Response();
+ $property = new \ReflectionProperty($res, 'body');
+ $property->setAccessible(true);
+ $property->setValue($res, 'foo');
+ $res->write('bar'); // <-- Should append to body
+
+ $this->assertAttributeEquals('foobar', 'body', $res);
+ }
+
+ public function testLength()
+ {
+ $res = new \Slim\Http\Response('foo'); // <-- Sets body and length
+
+ $this->assertEquals(3, $res->getLength());
+ }
+
+ public function testFinalize()
+ {
+ $res = new \Slim\Http\Response();
+ $resFinal = $res->finalize();
+
+ $this->assertTrue(is_array($resFinal));
+ $this->assertEquals(3, count($resFinal));
+ $this->assertEquals(200, $resFinal[0]);
+ $this->assertInstanceOf('\Slim\Http\Headers', $resFinal[1]);
+ $this->assertEquals('', $resFinal[2]);
+ }
+
+ public function testFinalizeWithEmptyBody()
+ {
+ $res = new \Slim\Http\Response('Foo', 304);
+ $resFinal = $res->finalize();
+
+ $this->assertEquals('', $resFinal[2]);
+ }
+
+ public function testRedirect()
+ {
+ $res = new \Slim\Http\Response();
+ $res->redirect('/foo');
+
+ $pStatus = new \ReflectionProperty($res, 'status');
+ $pStatus->setAccessible(true);
+
+ $this->assertEquals(302, $pStatus->getValue($res));
+ $this->assertEquals('/foo', $res->headers['Location']);
+ }
+
+ public function testIsEmpty()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(404);
+ $r2->setStatus(201);
+ $this->assertFalse($r1->isEmpty());
+ $this->assertTrue($r2->isEmpty());
+ }
+
+ public function testIsClientError()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(404);
+ $r2->setStatus(500);
+ $this->assertTrue($r1->isClientError());
+ $this->assertFalse($r2->isClientError());
+ }
+
+ public function testIsForbidden()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(403);
+ $r2->setStatus(500);
+ $this->assertTrue($r1->isForbidden());
+ $this->assertFalse($r2->isForbidden());
+ }
+
+ public function testIsInformational()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(100);
+ $r2->setStatus(200);
+ $this->assertTrue($r1->isInformational());
+ $this->assertFalse($r2->isInformational());
+ }
+
+ public function testIsNotFound()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(404);
+ $r2->setStatus(200);
+ $this->assertTrue($r1->isNotFound());
+ $this->assertFalse($r2->isNotFound());
+ }
+
+ public function testIsOk()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(200);
+ $r2->setStatus(201);
+ $this->assertTrue($r1->isOk());
+ $this->assertFalse($r2->isOk());
+ }
+
+ public function testIsSuccessful()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r3 = new \Slim\Http\Response();
+ $r1->setStatus(200);
+ $r2->setStatus(201);
+ $r3->setStatus(302);
+ $this->assertTrue($r1->isSuccessful());
+ $this->assertTrue($r2->isSuccessful());
+ $this->assertFalse($r3->isSuccessful());
+ }
+
+ public function testIsRedirect()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(307);
+ $r2->setStatus(304);
+ $this->assertTrue($r1->isRedirect());
+ $this->assertFalse($r2->isRedirect());
+ }
+
+ public function testIsRedirection()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r3 = new \Slim\Http\Response();
+ $r1->setStatus(307);
+ $r2->setStatus(304);
+ $r3->setStatus(200);
+ $this->assertTrue($r1->isRedirection());
+ $this->assertTrue($r2->isRedirection());
+ $this->assertFalse($r3->isRedirection());
+ }
+
+ public function testIsServerError()
+ {
+ $r1 = new \Slim\Http\Response();
+ $r2 = new \Slim\Http\Response();
+ $r1->setStatus(500);
+ $r2->setStatus(400);
+ $this->assertTrue($r1->isServerError());
+ $this->assertFalse($r2->isServerError());
+ }
+
+ public function testMessageForCode()
+ {
+ $this->assertEquals('200 OK', \Slim\Http\Response::getMessageForCode(200));
+ }
+
+ public function testMessageForCodeWithInvalidCode()
+ {
+ $this->assertNull(\Slim\Http\Response::getMessageForCode(600));
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Http/UtilTest.php b/strillonews/vendor/slim/slim/tests/Http/UtilTest.php
new file mode 100644
index 0000000..544a664
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Http/UtilTest.php
@@ -0,0 +1,432 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class SlimHttpUtilTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test strip slashes when magic quotes disabled
+ */
+ public function testStripSlashesWithoutMagicQuotes()
+ {
+ $data = "This should have \"quotes\" in it";
+ $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false);
+ $this->assertEquals($data, $stripped);
+ }
+
+ /**
+ * Test strip slashes from array when magic quotes disabled
+ */
+ public function testStripSlashesFromArrayWithoutMagicQuotes()
+ {
+ $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes");
+ $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false);
+ $this->assertEquals($data, $stripped);
+ }
+
+ /**
+ * Test strip slashes when magic quotes enabled
+ */
+ public function testStripSlashesWithMagicQuotes()
+ {
+ $data = "This should have \"quotes\" in it";
+ $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true);
+ $this->assertEquals('This should have "quotes" in it', $stripped);
+ }
+
+ /**
+ * Test strip slashes from array when magic quotes enabled
+ */
+ public function testStripSlashesFromArrayWithMagicQuotes()
+ {
+ $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes");
+ $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true);
+ $this->assertEquals($data = array('This should have "quotes" in it', 'And this "too" has quotes'), $stripped);
+ }
+
+ /**
+ * Test encrypt and decrypt with valid data
+ */
+ public function testEncryptAndDecryptWithValidData()
+ {
+ $data = 'foo';
+ $key = 'secret';
+ $iv = md5('initializationVector');
+ $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv);
+ $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv);
+ $this->assertEquals($data, $decrypted);
+ $this->assertTrue($data !== $encrypted);
+ }
+
+ /**
+ * Test encrypt when data is empty string
+ */
+ public function testEncryptWhenDataIsEmptyString()
+ {
+ $data = '';
+ $key = 'secret';
+ $iv = md5('initializationVector');
+ $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv);
+ $this->assertEquals('', $encrypted);
+ }
+
+ /**
+ * Test decrypt when data is empty string
+ */
+ public function testDecryptWhenDataIsEmptyString()
+ {
+ $data = '';
+ $key = 'secret';
+ $iv = md5('initializationVector');
+ $decrypted = \Slim\Http\Util::decrypt($data, $key, $iv);
+ $this->assertEquals('', $decrypted);
+ }
+
+ /**
+ * Test encrypt when IV and key sizes are too long
+ */
+ public function testEncryptAndDecryptWhenKeyAndIvAreTooLong()
+ {
+ $data = 'foo';
+ $key = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
+ $iv = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz';
+ $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv);
+ $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv);
+ $this->assertEquals($data, $decrypted);
+ $this->assertTrue($data !== $encrypted);
+ }
+
+ public function testEncodeAndDecodeSecureCookieWithValidData()
+ {
+ //Prepare cookie value
+ $value = 'foo';
+ $expires = time() + 86400;
+ $secret = 'password';
+ $algorithm = MCRYPT_RIJNDAEL_256;
+ $mode = MCRYPT_MODE_CBC;
+ $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode);
+ $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode);
+
+ //Test secure cookie value
+ $parts = explode('|', $encodedValue);
+ $this->assertEquals(3, count($parts));
+ $this->assertEquals($expires, $parts[0]);
+ $this->assertEquals($value, $decodedValue);
+ }
+
+ /**
+ * Test encode/decode secure cookie with old expiration
+ *
+ * In this test, the expiration date is purposefully set to a time before now.
+ * When decoding the encoded cookie value, FALSE is returned since the cookie
+ * will have expired before it is decoded.
+ */
+ public function testEncodeAndDecodeSecureCookieWithOldExpiration()
+ {
+ $value = 'foo';
+ $expires = time() - 100;
+ $secret = 'password';
+ $algorithm = MCRYPT_RIJNDAEL_256;
+ $mode = MCRYPT_MODE_CBC;
+ $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode);
+ $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode);
+ $this->assertFalse($decodedValue);
+ }
+
+ /**
+ * Test encode/decode secure cookie with tampered data
+ *
+ * In this test, the encoded data is purposefully changed to simulate someone
+ * tampering with the client-side cookie data. When decoding the encoded cookie value,
+ * FALSE is returned since the verification key will not match.
+ */
+ public function testEncodeAndDecodeSecureCookieWithTamperedData()
+ {
+ $value = 'foo';
+ $expires = time() + 86400;
+ $secret = 'password';
+ $algorithm = MCRYPT_RIJNDAEL_256;
+ $mode = MCRYPT_MODE_CBC;
+ $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode);
+ $encodedValueParts = explode('|', $encodedValue);
+ $encodedValueParts[1] = $encodedValueParts[1] . 'changed';
+ $encodedValue = implode('|', $encodedValueParts);
+ $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode);
+ $this->assertFalse($decodedValue);
+ }
+
+ public function testSetCookieHeaderWithNameAndValue()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, $value);
+ $this->assertEquals('foo=bar', $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueWhenCookieAlreadySet()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $header = array('Set-Cookie' => 'one=two');
+ \Slim\Http\Util::setCookieHeader($header, $name, $value);
+ $this->assertEquals("one=two\nfoo=bar", $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomain()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com', $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPath()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => $path
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsString()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $expires = '2 days';
+ $expiresFormat = gmdate('D, d-M-Y H:i:s e', strtotime($expires));
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => '/foo',
+ 'expires' => $expires
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsInteger()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $expires = strtotime('2 days');
+ $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires);
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => '/foo',
+ 'expires' => $expires
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsZero()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $expires = 0;
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => '/foo',
+ 'expires' => $expires
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecure()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $expires = strtotime('2 days');
+ $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires);
+ $secure = true;
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => '/foo',
+ 'expires' => $expires,
+ 'secure' => $secure
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure', $header['Set-Cookie']);
+ }
+
+ public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecureAndHttpOnly()
+ {
+ $name = 'foo';
+ $value = 'bar';
+ $domain = 'foo.com';
+ $path = '/foo';
+ $expires = strtotime('2 days');
+ $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires);
+ $secure = true;
+ $httpOnly = true;
+ $header = array();
+ \Slim\Http\Util::setCookieHeader($header, $name, array(
+ 'value' => $value,
+ 'domain' => $domain,
+ 'path' => '/foo',
+ 'expires' => $expires,
+ 'secure' => $secure,
+ 'httponly' => $httpOnly
+ ));
+ $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure; HttpOnly', $header['Set-Cookie']);
+ }
+
+ /**
+ * Test serializeCookies and decrypt with string expires
+ *
+ * In this test a cookie with a string typed value for 'expires' is set,
+ * which should be parsed by `strtotime` to a timestamp when it's added to
+ * the headers; this timestamp should then be correctly parsed, and the
+ * value correctly decrypted, by `decodeSecureCookie`.
+ */
+ public function testSerializeCookiesAndDecryptWithStringExpires()
+ {
+ $value = 'bar';
+
+ $headers = new \Slim\Http\Headers();
+
+ $settings = array(
+ 'cookies.encrypt' => true,
+ 'cookies.secret_key' => 'secret',
+ 'cookies.cipher' => MCRYPT_RIJNDAEL_256,
+ 'cookies.cipher_mode' => MCRYPT_MODE_CBC
+ );
+
+ $cookies = new \Slim\Http\Cookies();
+ $cookies->set('foo', array(
+ 'value' => $value,
+ 'expires' => '1 hour'
+ ));
+
+ \Slim\Http\Util::serializeCookies($headers, $cookies, $settings);
+
+ $encrypted = $headers->get('Set-Cookie');
+ $encrypted = strstr($encrypted, ';', true);
+ $encrypted = urldecode(substr(strstr($encrypted, '='), 1));
+
+ $decrypted = \Slim\Http\Util::decodeSecureCookie(
+ $encrypted,
+ $settings['cookies.secret_key'],
+ $settings['cookies.cipher'],
+ $settings['cookies.cipher_mode']
+ );
+
+ $this->assertEquals($value, $decrypted);
+ $this->assertTrue($value !== $encrypted);
+ }
+
+ public function testDeleteCookieHeaderWithSurvivingCookie()
+ {
+ $header = array('Set-Cookie' => "foo=bar\none=two");
+ \Slim\Http\Util::deleteCookieHeader($header, 'foo');
+ $this->assertEquals(1, preg_match("@^one=two\nfoo=; expires=@", $header['Set-Cookie']));
+ }
+
+ public function testDeleteCookieHeaderWithoutSurvivingCookie()
+ {
+ $header = array('Set-Cookie' => "foo=bar");
+ \Slim\Http\Util::deleteCookieHeader($header, 'foo');
+ $this->assertEquals(1, preg_match("@foo=; expires=@", $header['Set-Cookie']));
+ }
+
+ public function testDeleteCookieHeaderWithMatchingDomain()
+ {
+ $header = array('Set-Cookie' => "foo=bar; domain=foo.com");
+ \Slim\Http\Util::deleteCookieHeader($header, 'foo', array(
+ 'domain' => 'foo.com'
+ ));
+ $this->assertEquals(1, preg_match("@foo=; domain=foo.com; expires=@", $header['Set-Cookie']));
+ }
+
+ public function testDeleteCookieHeaderWithoutMatchingDomain()
+ {
+ $header = array('Set-Cookie' => "foo=bar; domain=foo.com");
+ \Slim\Http\Util::deleteCookieHeader($header, 'foo', array(
+ 'domain' => 'bar.com'
+ ));
+ $this->assertEquals(1, preg_match("@foo=bar; domain=foo\.com\nfoo=; domain=bar\.com@", $header['Set-Cookie']));
+ }
+
+ /**
+ * Test parses Cookie: HTTP header
+ */
+ public function testParsesCookieHeader()
+ {
+ $header = 'foo=bar; one=two; colors=blue';
+ $result = \Slim\Http\Util::parseCookieHeader($header);
+ $this->assertEquals(3, count($result));
+ $this->assertEquals('bar', $result['foo']);
+ $this->assertEquals('two', $result['one']);
+ $this->assertEquals('blue', $result['colors']);
+ }
+
+ public function testParsesCookieHeaderWithCommaSeparator()
+ {
+ $header = 'foo=bar, one=two, colors=blue';
+ $result = \Slim\Http\Util::parseCookieHeader($header);
+ $this->assertEquals(3, count($result));
+ $this->assertEquals('bar', $result['foo']);
+ $this->assertEquals('two', $result['one']);
+ $this->assertEquals('blue', $result['colors']);
+ }
+
+ public function testPrefersLeftmostCookieWhenManyCookiesWithSameName()
+ {
+ $header = 'foo=bar; foo=beer';
+ $result = \Slim\Http\Util::parseCookieHeader($header);
+ $this->assertEquals('bar', $result['foo']);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/LogTest.php b/strillonews/vendor/slim/slim/tests/LogTest.php
new file mode 100644
index 0000000..04954c5
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/LogTest.php
@@ -0,0 +1,208 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class MyWriter
+{
+ public function write( $object, $level )
+ {
+ echo (string) $object;
+
+ return true;
+ }
+}
+
+class LogTest extends PHPUnit_Framework_TestCase
+{
+ public function testEnabled()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $this->assertTrue($log->isEnabled()); //<-- Default case
+ $log->setEnabled(true);
+ $this->assertTrue($log->isEnabled());
+ $log->setEnabled(false);
+ $this->assertFalse($log->isEnabled());
+ }
+
+ public function testGetLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $this->assertEquals(\Slim\Log::DEBUG, $log->getLevel());
+ }
+
+ public function testSetLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::WARN);
+ $this->assertEquals(\Slim\Log::WARN, $log->getLevel());
+ }
+
+ public function testSetInvalidLevel()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::DEBUG + 1);
+ }
+
+ public function testLogDebug()
+ {
+ $this->expectOutputString('Debug');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->debug('Debug');
+ $this->assertTrue($result);
+ }
+
+ public function testLogDebugExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::INFO);
+ $this->assertFalse($log->debug('Debug'));
+ }
+
+ public function testLogInfo()
+ {
+ $this->expectOutputString('Info');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->info('Info');
+ $this->assertTrue($result);
+ }
+
+ public function testLogInfoExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::NOTICE);
+ $this->assertFalse($log->info('Info'));
+ }
+
+ public function testLogNotice()
+ {
+ $this->expectOutputString('Notice');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->notice('Notice');
+ $this->assertTrue($result);
+ }
+
+ public function testLogNoticeExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::WARN);
+ $this->assertFalse($log->info('Info'));
+ }
+
+ public function testLogWarn()
+ {
+ $this->expectOutputString('Warn');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->warning('Warn');
+ $this->assertTrue($result);
+ }
+
+ public function testLogWarnExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::ERROR);
+ $this->assertFalse($log->warning('Warn'));
+ }
+
+ public function testLogError()
+ {
+ $this->expectOutputString('Error');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->error('Error');
+ $this->assertTrue($result);
+ }
+
+ public function testLogErrorExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::CRITICAL);
+ $this->assertFalse($log->error('Error'));
+ }
+
+ public function testLogCritical()
+ {
+ $this->expectOutputString('Critical');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->critical('Critical');
+ $this->assertTrue($result);
+ }
+
+ public function testLogCriticalExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::ALERT);
+ $this->assertFalse($log->critical('Critical'));
+ }
+
+ public function testLogAlert()
+ {
+ $this->expectOutputString('Alert');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->alert('Alert');
+ $this->assertTrue($result);
+ }
+
+ public function testLogAlertExcludedByLevel()
+ {
+ $log = new \Slim\Log(new MyWriter());
+ $log->setLevel(\Slim\Log::EMERGENCY);
+ $this->assertFalse($log->alert('Alert'));
+ }
+
+ public function testLogEmergency()
+ {
+ $this->expectOutputString('Emergency');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->emergency('Emergency');
+ $this->assertTrue($result);
+ }
+
+ public function testInterpolateMessage()
+ {
+ $this->expectOutputString('Hello Slim !');
+ $log = new \Slim\Log(new MyWriter());
+ $result = $log->debug(
+ 'Hello {framework} !',
+ array('framework' => "Slim")
+ );
+ $this->assertTrue($result);
+ }
+
+ public function testGetAndSetWriter()
+ {
+ $writer1 = new MyWriter();
+ $writer2 = new MyWriter();
+ $log = new \Slim\Log($writer1);
+ $this->assertSame($writer1, $log->getWriter());
+ $log->setWriter($writer2);
+ $this->assertSame($writer2, $log->getWriter());
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/LogWriterTest.php b/strillonews/vendor/slim/slim/tests/LogWriterTest.php
new file mode 100644
index 0000000..e116f37
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/LogWriterTest.php
@@ -0,0 +1,48 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class LogWriterTest extends PHPUnit_Framework_TestCase
+{
+ public function testInstantiation()
+ {
+ $this->expectOutputString('Hello!' . PHP_EOL);
+ $handle = fopen('php://output', 'w');
+ $fw = new \Slim\LogWriter($handle);
+ $this->assertTrue($fw->write('Hello!') > 0); //<-- Returns number of bytes written if successful
+ }
+
+ public function testInstantiationWithNonResource()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+ $fw = new \Slim\LogWriter(@fopen('/foo/bar.txt', 'w'));
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Middleware/ContentTypesTest.php b/strillonews/vendor/slim/slim/tests/Middleware/ContentTypesTest.php
new file mode 100644
index 0000000..3fdfad1
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Middleware/ContentTypesTest.php
@@ -0,0 +1,162 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class ContentTypesTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ ob_start();
+ }
+
+ public function tearDown()
+ {
+ ob_end_clean();
+ }
+
+ /**
+ * Test parses JSON
+ */
+ public function testParsesJson()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/json',
+ 'CONENT_LENGTH' => 13,
+ 'slim.input' => '{"foo":"bar"}'
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertTrue(is_array($body));
+ $this->assertEquals('bar', $body['foo']);
+ }
+
+ /**
+ * Test ignores JSON with errors
+ */
+ public function testParsesJsonWithError()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/json',
+ 'CONENT_LENGTH' => 12,
+ 'slim.input' => '{"foo":"bar"' //<-- This should be incorrect!
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertTrue(is_string($body));
+ $this->assertEquals('{"foo":"bar"', $body);
+ }
+
+ /**
+ * Test parses XML
+ */
+ public function testParsesXml()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/xml',
+ 'CONENT_LENGTH' => 68,
+ 'slim.input' => '1Clive Cussler'
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertInstanceOf('SimpleXMLElement', $body);
+ $this->assertEquals('Clive Cussler', (string) $body->book->author);
+ }
+
+ /**
+ * Test ignores XML with errors
+ */
+ public function testParsesXmlWithError()
+ {
+ libxml_use_internal_errors(true);
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/xml',
+ 'CONTENT_LENGTH' => 68,
+ 'slim.input' => '1Clive Cussler' //<-- This should be incorrect!
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertTrue(is_string($body));
+ $this->assertEquals('1Clive Cussler', $body);
+ }
+
+ /**
+ * Test parses CSV
+ */
+ public function testParsesCsv()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'text/csv',
+ 'CONTENT_LENGTH' => 44,
+ 'slim.input' => "John,Doe,000-111-2222\nJane,Doe,111-222-3333"
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertTrue(is_array($body));
+ $this->assertEquals(2, count($body));
+ $this->assertEquals('000-111-2222', $body[0][2]);
+ $this->assertEquals('Doe', $body[1][1]);
+ }
+
+ /**
+ * Test parses request body based on media-type only, disregarding
+ * any extra content-type header parameters
+ */
+ public function testParsesRequestBodyWithMediaType()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4',
+ 'CONTENT_LENGTH' => 13,
+ 'slim.input' => '{"foo":"bar"}'
+ ));
+ $s = new \Slim\Slim();
+ $s->add(new \Slim\Middleware\ContentTypes());
+ $s->run();
+ $body = $s->request()->getBody();
+ $this->assertTrue(is_array($body));
+ $this->assertEquals('bar', $body['foo']);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Middleware/FlashTest.php b/strillonews/vendor/slim/slim/tests/Middleware/FlashTest.php
new file mode 100644
index 0000000..24238e1
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Middleware/FlashTest.php
@@ -0,0 +1,141 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class SlimFlashTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Setup
+ */
+ public function setUp()
+ {
+ $_SESSION = array();
+ }
+
+ /**
+ * Test set flash message for next request
+ */
+ public function testSetFlashForNextRequest()
+ {
+ $f = new \Slim\Middleware\Flash();
+ $f->set('foo', 'bar');
+ $f->save();
+ $this->assertEquals('bar', $_SESSION['slim.flash']['foo']);
+ }
+
+ /**
+ * Test set flash message for current request
+ */
+ public function testSetFlashForCurrentRequest()
+ {
+ $f = new \Slim\Middleware\Flash();
+ $f->now('foo', 'bar');
+ $this->assertEquals('bar', $f['foo']);
+ }
+
+ /**
+ * Test loads flash from previous request
+ */
+ public function testLoadsFlashFromPreviousRequest()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo');
+ $f = new \Slim\Middleware\Flash();
+ $f->loadMessages();
+ $this->assertEquals('foo', $f['info']);
+ }
+
+ /**
+ * Test keep flash message for next request
+ */
+ public function testKeepFlashFromPreviousRequest()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo');
+ $f = new \Slim\Middleware\Flash();
+ $f->loadMessages();
+ $f->keep();
+ $f->save();
+ $this->assertEquals('foo', $_SESSION['slim.flash']['info']);
+ }
+
+ /**
+ * Test flash messages from previous request do not persist to next request
+ */
+ public function testFlashMessagesFromPreviousRequestDoNotPersist()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo');
+ $f = new \Slim\Middleware\Flash();
+ $f->save();
+ $this->assertEmpty($_SESSION['slim.flash']);
+ }
+
+ /**
+ * Test set Flash using array access
+ */
+ public function testFlashArrayAccess()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo');
+ $f = new \Slim\Middleware\Flash();
+ $f['info'] = 'bar';
+ $f->save();
+ $this->assertTrue(isset($f['info']));
+ $this->assertEquals('bar', $f['info']);
+ unset($f['info']);
+ $this->assertFalse(isset($f['info']));
+ }
+
+ /**
+ * Test iteration
+ */
+ public function testIteration()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar');
+ $f = new \Slim\Middleware\Flash();
+ $f->loadMessages();
+ $output = '';
+ foreach ($f as $key => $value) {
+ $output .= $key . $value;
+ }
+ $this->assertEquals('infofooerrorbar', $output);
+ }
+
+ /**
+ * Test countable
+ */
+ public function testCountable()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar');
+ $f = new \Slim\MiddleWare\Flash();
+ $f->loadMessages();
+ $this->assertEquals(2, count($f));
+ }
+
+
+}
diff --git a/strillonews/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php b/strillonews/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php
new file mode 100644
index 0000000..1427d13
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php
@@ -0,0 +1,149 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+/**
+ * We use a mock application, instead of a Slim application.
+ * so that we may easily test the Method Override middleware
+ * in isolation.
+ */
+class CustomAppMethod
+{
+ protected $environment;
+
+ public function __construct()
+ {
+ $this->environment = \Slim\Environment::getInstance();
+ }
+
+ public function &environment() {
+ return $this->environment;
+ }
+
+ public function call()
+ {
+ //Do nothing
+ }
+}
+
+class MethodOverrideTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test overrides method as POST
+ */
+ public function testOverrideMethodAsPost()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
+ 'CONTENT_LENGTH' => 11,
+ 'slim.input' => '_METHOD=PUT'
+ ));
+ $app = new CustomAppMethod();
+ $mw = new \Slim\Middleware\MethodOverride();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $env =& $app->environment();
+ $this->assertEquals('PUT', $env['REQUEST_METHOD']);
+ $this->assertTrue(isset($env['slim.method_override.original_method']));
+ $this->assertEquals('POST', $env['slim.method_override.original_method']);
+ }
+
+ /**
+ * Test does not override method if not POST
+ */
+ public function testDoesNotOverrideMethodIfNotPost()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'slim.input' => ''
+ ));
+ $app = new CustomAppMethod();
+ $mw = new \Slim\Middleware\MethodOverride();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $env =& $app->environment();
+ $this->assertEquals('GET', $env['REQUEST_METHOD']);
+ $this->assertFalse(isset($env['slim.method_override.original_method']));
+ }
+
+ /**
+ * Test does not override method if no method override parameter
+ */
+ public function testDoesNotOverrideMethodAsPostWithoutParameter()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'QUERY_STRING' => 'foo=bar',
+ 'SERVER_NAME' => 'slim',
+ 'SERVER_PORT' => 80,
+ 'slim.url_scheme' => 'http',
+ 'slim.input' => '',
+ 'slim.errors' => fopen('php://stderr', 'w')
+ ));
+ $app = new CustomAppMethod();
+ $mw = new \Slim\Middleware\MethodOverride();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $env =& $app->environment();
+ $this->assertEquals('POST', $env['REQUEST_METHOD']);
+ $this->assertFalse(isset($env['slim.method_override.original_method']));
+ }
+
+ /**
+ * Test overrides method with X-Http-Method-Override header
+ */
+ public function testOverrideMethodAsHeader()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'CONTENT_TYPE' => 'application/json',
+ 'CONTENT_LENGTH' => 0,
+ 'slim.input' => '',
+ 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'DELETE'
+ ));
+ $app = new CustomAppMethod();
+ $mw = new \Slim\Middleware\MethodOverride();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $env =& $app->environment();
+ $this->assertEquals('DELETE', $env['REQUEST_METHOD']);
+ $this->assertTrue(isset($env['slim.method_override.original_method']));
+ $this->assertEquals('POST', $env['slim.method_override.original_method']);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php b/strillonews/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php
new file mode 100644
index 0000000..97c6956
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php
@@ -0,0 +1,153 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class PrettyExceptionsTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Test middleware returns successful response unchanged
+ */
+ public function testReturnsUnchangedSuccessResponse()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim();
+ $app->get('/foo', function () {
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\PrettyExceptions();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(200, $app->response()->status());
+ $this->assertEquals('Success', $app->response()->body());
+ }
+
+ /**
+ * Test middleware returns diagnostic screen for error response
+ */
+ public function testReturnsDiagnosticsForErrorResponse()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim(array(
+ 'log.enabled' => false
+ ));
+ $app->get('/foo', function () {
+ throw new \Exception('Test Message', 100);
+ });
+ $mw = new \Slim\Middleware\PrettyExceptions();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(1, preg_match('@Slim Application Error@', $app->response()->body()));
+ $this->assertEquals(500, $app->response()->status());
+ }
+
+ /**
+ * Test middleware overrides response content type to html
+ */
+ public function testResponseContentTypeIsOverriddenToHtml()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim(array(
+ 'log.enabled' => false
+ ));
+ $app->get('/foo', function () use ($app) {
+ $app->contentType('application/json;charset=utf-8'); //<-- set content type to something else
+ throw new \Exception('Test Message', 100);
+ });
+ $mw = new \Slim\Middleware\PrettyExceptions();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $response = $app->response();
+ $this->assertEquals('text/html', $response['Content-Type']);
+ }
+
+ /**
+ * Test exception type is in response body
+ */
+ public function testExceptionTypeIsInResponseBody()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim(array(
+ 'log.enabled' => false
+ ));
+ $app->get('/foo', function () use ($app) {
+ throw new \LogicException('Test Message', 100);
+ });
+ $mw = new \Slim\Middleware\PrettyExceptions();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+
+ $this->assertContains('LogicException', $app->response()->body());
+ }
+
+ /**
+ * Test with custom log
+ */
+ public function testWithCustomLogWriter()
+ {
+ $this->setExpectedException('\LogicException');
+
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim(array(
+ 'log.enabled' => false
+ ));
+ $app->container->singleton('log', function () use ($app) {
+ return new \Slim\Log(new \Slim\LogWriter('php://temp'));
+ });
+ $app->get('/foo', function () use ($app) {
+ throw new \LogicException('Test Message', 100);
+ });
+ $mw = new \Slim\Middleware\PrettyExceptions();
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+
+ $this->assertContains('LogicException', $app->response()->body());
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/Middleware/SessionCookieTest.php b/strillonews/vendor/slim/slim/tests/Middleware/SessionCookieTest.php
new file mode 100644
index 0000000..e281f4f
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/Middleware/SessionCookieTest.php
@@ -0,0 +1,469 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class SessionCookieTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $_SESSION = array();
+ }
+
+ /**
+ * Test session cookie is set and constructed correctly
+ *
+ * We test for two things:
+ *
+ * 1) That the HTTP cookie exists with the correct name;
+ * 2) That the HTTP cookie's value is the expected value;
+ */
+ public function testSessionCookieIsCreated()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim();
+ $app->get('/foo', function () {
+ $_SESSION['foo'] = 'bar';
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ list($status, $header, $body) = $app->response()->finalize();
+ $this->assertTrue($app->response->cookies->has('slim_session'));
+ $cookie = $app->response->cookies->get('slim_session');
+ $this->assertEquals(serialize(array('foo' => 'bar')), $cookie['value']);
+ }
+
+ /**
+ * Test $_SESSION is populated from an encrypted HTTP cookie
+ *
+ * The encrypted cookie contains the serialized array ['foo' => 'bar']. The
+ * global secret, cipher, and cipher mode are assumed to be the default
+ * values.
+ */
+ public function testSessionIsPopulatedFromEncryptedCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo',
+ 'HTTP_COOKIE' => 'slim_session=1644004961%7CLKkYPwqKIMvBK7MWl6D%2BxeuhLuMaW4quN%2F512ZAaVIY%3D%7Ce0f007fa852c7101e8224bb529e26be4d0dfbd63',
+ ));
+ $app = new \Slim\Slim();
+ // The cookie value in the test is encrypted, so cookies.encrypt must
+ // be set to true
+ $app->config('cookies.encrypt', true);
+ $app->get('/foo', function () {
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(array('foo' => 'bar'), $_SESSION);
+ }
+
+ /**
+ * Test $_SESSION is populated from an unencrypted HTTP cookie
+ *
+ * The unencrypted cookie contains the serialized array ['foo' => 'bar'].
+ * The global cookies.encrypt setting is set to false
+ */
+ public function testSessionIsPopulatedFromUnencryptedCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo',
+ 'HTTP_COOKIE' => 'slim_session=a%3A1%3A%7Bs%3A3%3A%22foo%22%3Bs%3A3%3A%22bar%22%3B%7D',
+ ));
+ $app = new \Slim\Slim();
+ // The cookie value in the test is unencrypted, so cookies.encrypt must
+ // be set to false
+ $app->config('cookies.encrypt', false);
+ $app->get('/foo', function () {
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(array('foo' => 'bar'), $_SESSION);
+ }
+
+ public function testUnserializeErrorsAreCaughtAndLogged()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo',
+ 'HTTP_COOKIE' => 'slim_session=1644004961%7CLKkYPwqKIMvBK7MWl6D%2BxeuhLuMaW4quN%2F512ZAaVIY%3D%7Ce0f007fa852c7101e8224bb529e26be4d0dfbd63',
+ ));
+
+ $logWriter = $this->getMockBuilder('Slim\LogWriter')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $logWriter->expects($this->once())
+ ->method('write');
+ $oldLevel = error_reporting(E_ALL);
+
+ $app = new \Slim\Slim(array(
+ 'log.writer' => $logWriter
+ ));
+ // Unserializing an encrypted value fails if cookie not decrpyted
+ $app->config('cookies.encrypt', false);
+ $app->get('/foo', function () {
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(array(), $_SESSION);
+
+ error_reporting($oldLevel);
+ }
+
+ /**
+ * Test $_SESSION is populated as empty array if no HTTP cookie
+ */
+ public function testSessionIsPopulatedAsEmptyIfNoCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+ $app = new \Slim\Slim();
+ $app->get('/foo', function () {
+ echo "Success";
+ });
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ $this->assertEquals(array(), $_SESSION);
+ }
+
+ public function testSerializingTooLongValueWritesLogAndDoesntCreateCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/index.php',
+ 'PATH_INFO' => '/foo'
+ ));
+
+ $logWriter = $this->getMockBuilder('Slim\LogWriter')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $logWriter->expects($this->once())
+ ->method('write')
+ ->with('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.', \Slim\Log::ERROR);
+
+ $app = new \Slim\Slim(array(
+ 'log.writer' => $logWriter
+ ));
+
+ $tooLongValue = $this->getTooLongValue();
+
+ $app->get('/foo', function () use ($tooLongValue) {
+ $_SESSION['test'] = $tooLongValue;
+ echo "Success";
+ });
+
+ $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years'));
+ $mw->setApplication($app);
+ $mw->setNextMiddleware($app);
+ $mw->call();
+ list($status, $header, $body) = $app->response()->finalize();
+ $this->assertFalse($app->response->cookies->has('slim_session'));
+ }
+
+ /**
+ * Generated by http://www.random.org/strings/
+ */
+ protected function getTooLongValue()
+ {
+ return <<
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class MyMiddleware extends \Slim\Middleware
+{
+ public function call() {}
+}
+
+class MiddlewareTest extends PHPUnit_Framework_TestCase
+{
+ public function testSetApplication()
+ {
+ $app = new stdClass();
+ $mw = new MyMiddleware();
+ $mw->setApplication($app);
+
+ $this->assertAttributeSame($app, 'app', $mw);
+ }
+
+ public function testGetApplication()
+ {
+ $app = new stdClass();
+ $mw = new MyMiddleware();
+ $property = new \ReflectionProperty($mw, 'app');
+ $property->setAccessible(true);
+ $property->setValue($mw, $app);
+
+ $this->assertSame($app, $mw->getApplication());
+ }
+
+ public function testSetNextMiddleware()
+ {
+ $mw1 = new MyMiddleware();
+ $mw2 = new MyMiddleware();
+ $mw1->setNextMiddleware($mw2);
+
+ $this->assertAttributeSame($mw2, 'next', $mw1);
+ }
+
+ public function testGetNextMiddleware()
+ {
+ $mw1 = new MyMiddleware();
+ $mw2 = new MyMiddleware();
+ $property = new \ReflectionProperty($mw1, 'next');
+ $property->setAccessible(true);
+ $property->setValue($mw1, $mw2);
+
+ $this->assertSame($mw2, $mw1->getNextMiddleware());
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/README b/strillonews/vendor/slim/slim/tests/README
new file mode 100644
index 0000000..7bc611c
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/README
@@ -0,0 +1,18 @@
+Slim Framework Unit Tests
+
+Follow the directions below to run the Slim Framework unit tests. You'll need the latest version of PHPUnit. To save development time, these unit tests require PHP >= 5.3. However, the Slim Framework itself requires only PHP >= 5.2.
+
+1. Install the latest version of PHPUnit
+Visit http://www.phpunit.de/ for installation instructions.
+
+2. Run PHPUnit
+From the filesystem directory that contains the `tests` directory, you may run all unit tests or specific unit tests. Here are several examples. The '$>' in the examples below is your command prompt.
+
+To run all tests:
+$> phpunit tests
+
+To run all HTTP-related tests:
+$> phpunit tests/Http
+
+To run only the HTTP Request tests:
+$> phpunit tests/Http/RequestTest
\ No newline at end of file
diff --git a/strillonews/vendor/slim/slim/tests/RouteTest.php b/strillonews/vendor/slim/slim/tests/RouteTest.php
new file mode 100644
index 0000000..5d0ee7a
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/RouteTest.php
@@ -0,0 +1,535 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+class RouteTest extends PHPUnit_Framework_TestCase
+{
+ public function testGetPattern()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $this->assertEquals('/foo', $route->getPattern());
+ }
+
+ public function testGetName()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'name');
+ $property->setAccessible(true);
+ $property->setValue($route, 'foo');
+
+ $this->assertEquals('foo', $route->getName());
+ }
+
+ public function testSetName()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $route->name('foo'); // <-- Alias for `setName()`
+
+ $this->assertAttributeEquals('foo', 'name', $route);
+ }
+
+ public function testGetCallable()
+ {
+ $callable = function () {
+ echo 'Foo';
+ };
+ $route = new \Slim\Route('/foo', $callable);
+
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ public function testGetCallableAsClass()
+ {
+ $route = new \Slim\Route('/foo', '\Slim\Router:getCurrentRoute');
+
+ $callable = $route->getCallable();
+ $this->assertInstanceOf('\Slim\Router', $callable[0]);
+ $this->assertEquals('getCurrentRoute', $callable[1]);
+ }
+
+ public function testGetCallableAsStaticMethod()
+ {
+ $route = new \Slim\Route('/bar', '\Slim\Slim::getInstance');
+
+ $callable = $route->getCallable();
+ $this->assertEquals('\Slim\Slim::getInstance', $callable);
+ }
+
+ public function testSetCallable()
+ {
+ $callable = function () {
+ echo 'Foo';
+ };
+ $route = new \Slim\Route('/foo', $callable); // <-- Called inside __construct()
+
+ $this->assertAttributeSame($callable, 'callable', $route);
+ }
+
+ public function testSetCallableWithInvalidArgument()
+ {
+ $this->setExpectedException('\InvalidArgumentException');
+ $route = new \Slim\Route('/foo', 'doesNotExist'); // <-- Called inside __construct()
+ }
+
+ public function testGetParams()
+ {
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+ $route->matches('/hello/mr/anderson'); // <-- Parses params from argument
+
+ $this->assertEquals(array(
+ 'first' => 'mr',
+ 'last' => 'anderson'
+ ), $route->getParams());
+ }
+
+ public function testSetParams()
+ {
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+ $route->matches('/hello/mr/anderson'); // <-- Parses params from argument
+ $route->setParams(array(
+ 'first' => 'agent',
+ 'last' => 'smith'
+ ));
+
+ $this->assertAttributeEquals(array(
+ 'first' => 'agent',
+ 'last' => 'smith'
+ ), 'params', $route);
+ }
+
+ public function testGetParam()
+ {
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+
+ $property = new \ReflectionProperty($route, 'params');
+ $property->setAccessible(true);
+ $property->setValue($route, array(
+ 'first' => 'foo',
+ 'last' => 'bar'
+ ));
+
+ $this->assertEquals('foo', $route->getParam('first'));
+ }
+
+ public function testGetParamThatDoesNotExist()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+
+ $property = new \ReflectionProperty($route, 'params');
+ $property->setAccessible(true);
+ $property->setValue($route, array(
+ 'first' => 'foo',
+ 'last' => 'bar'
+ ));
+
+ $route->getParam('middle');
+ }
+
+ public function testSetParam()
+ {
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+ $route->matches('/hello/mr/anderson'); // <-- Parses params from argument
+ $route->setParam('last', 'smith');
+
+ $this->assertAttributeEquals(array(
+ 'first' => 'mr',
+ 'last' => 'smith'
+ ), 'params', $route);
+ }
+
+ public function testSetParamThatDoesNotExist()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $route = new \Slim\Route('/hello/:first/:last', function () {});
+ $route->matches('/hello/mr/anderson'); // <-- Parses params from argument
+ $route->setParam('middle', 'smith'); // <-- Should trigger InvalidArgumentException
+ }
+
+ public function testMatches()
+ {
+ $route = new \Slim\Route('/hello/:name', function () {});
+
+ $this->assertTrue($route->matches('/hello/josh'));
+ }
+
+ public function testMatchesIsFalse()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $this->assertFalse($route->matches('/bar'));
+ }
+
+ public function testMatchesPatternWithTrailingSlash()
+ {
+ $route = new \Slim\Route('/foo/', function () {});
+
+ $this->assertTrue($route->matches('/foo/'));
+ $this->assertTrue($route->matches('/foo'));
+ }
+
+ public function testMatchesPatternWithoutTrailingSlash()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $this->assertFalse($route->matches('/foo/'));
+ $this->assertTrue($route->matches('/foo'));
+ }
+
+ public function testMatchesWithConditions()
+ {
+ $route = new \Slim\Route('/hello/:first/and/:second', function () {});
+ $route->conditions(array(
+ 'first' => '[a-zA-Z]{3,}'
+ ));
+
+ $this->assertTrue($route->matches('/hello/Josh/and/John'));
+ }
+
+ public function testMatchesWithConditionsIsFalse()
+ {
+ $route = new \Slim\Route('/hello/:first/and/:second', function () {});
+ $route->conditions(array(
+ 'first' => '[a-z]{3,}'
+ ));
+
+ $this->assertFalse($route->matches('/hello/Josh/and/John'));
+ }
+
+ /*
+ * Route should match URI with valid path component according to rfc2396
+ *
+ * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt
+ *
+ * Excludes "+" which is valid but decodes into a space character
+ */
+ public function testMatchesWithValidRfc2396PathComponent()
+ {
+ $symbols = ':@&=$,';
+ $route = new \Slim\Route('/rfc2386/:symbols', function () {});
+
+ $this->assertTrue($route->matches('/rfc2386/' . $symbols));
+ }
+
+ /*
+ * Route should match URI including unreserved punctuation marks from rfc2396
+ *
+ * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt
+ */
+ public function testMatchesWithUnreservedMarks()
+ {
+ $marks = "-_.!~*'()";
+ $route = new \Slim\Route('/marks/:marks', function () {});
+
+ $this->assertTrue($route->matches('/marks/' . $marks));
+ }
+
+ public function testMatchesOptionalParameters()
+ {
+ $pattern = '/archive/:year(/:month(/:day))';
+
+ $route1 = new \Slim\Route($pattern, function () {});
+ $this->assertTrue($route1->matches('/archive/2010'));
+ $this->assertEquals(array('year' => '2010'), $route1->getParams());
+
+ $route2 = new \Slim\Route($pattern, function () {});
+ $this->assertTrue($route2->matches('/archive/2010/05'));
+ $this->assertEquals(array('year' => '2010', 'month' => '05'), $route2->getParams());
+
+ $route3 = new \Slim\Route($pattern, function () {});
+ $this->assertTrue($route3->matches('/archive/2010/05/13'));
+ $this->assertEquals(array('year' => '2010', 'month' => '05', 'day' => '13'), $route3->getParams());
+ }
+
+ public function testGetConditions()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'conditions');
+ $property->setAccessible(true);
+ $property->setValue($route, array('foo' => '\d{3}'));
+
+ $this->assertEquals(array('foo' => '\d{3}'), $route->getConditions());
+ }
+
+ public function testSetDefaultConditions()
+ {
+ \Slim\Route::setDefaultConditions(array(
+ 'id' => '\d+'
+ ));
+
+ $property = new \ReflectionProperty('\Slim\Route', 'defaultConditions');
+ $property->setAccessible(true);
+
+ $this->assertEquals(array(
+ 'id' => '\d+'
+ ), $property->getValue());
+ }
+
+ public function testGetDefaultConditions()
+ {
+ $property = new \ReflectionProperty('\Slim\Route', 'defaultConditions');
+ $property->setAccessible(true);
+ $property->setValue(array(
+ 'id' => '\d+'
+ ));
+
+ $this->assertEquals(array(
+ 'id' => '\d+'
+ ), \Slim\Route::getDefaultConditions());
+ }
+
+ public function testDefaultConditionsAssignedToInstance()
+ {
+ $staticProperty = new \ReflectionProperty('\Slim\Route', 'defaultConditions');
+ $staticProperty->setAccessible(true);
+ $staticProperty->setValue(array(
+ 'id' => '\d+'
+ ));
+ $route = new \Slim\Route('/foo', function () {});
+
+ $this->assertAttributeEquals(array(
+ 'id' => '\d+'
+ ), 'conditions', $route);
+ }
+
+ public function testMatchesWildcard()
+ {
+ $route = new \Slim\Route('/hello/:path+/world', function () {});
+
+ $this->assertTrue($route->matches('/hello/foo/bar/world'));
+ $this->assertAttributeEquals(array(
+ 'path' => array('foo', 'bar')
+ ), 'params', $route);
+ }
+
+ public function testMatchesMultipleWildcards()
+ {
+ $route = new \Slim\Route('/hello/:path+/world/:date+', function () {});
+
+ $this->assertTrue($route->matches('/hello/foo/bar/world/2012/03/10'));
+ $this->assertAttributeEquals(array(
+ 'path' => array('foo', 'bar'),
+ 'date' => array('2012', '03', '10')
+ ), 'params', $route);
+ }
+
+ public function testMatchesParamsAndWildcards()
+ {
+ $route = new \Slim\Route('/hello/:path+/world/:year/:month/:day/:path2+', function () {});
+
+ $this->assertTrue($route->matches('/hello/foo/bar/world/2012/03/10/first/second'));
+ $this->assertAttributeEquals(array(
+ 'path' => array('foo', 'bar'),
+ 'year' => '2012',
+ 'month' => '03',
+ 'day' => '10',
+ 'path2' => array('first', 'second')
+ ), 'params', $route);
+ }
+
+ public function testMatchesParamsWithOptionalWildcard()
+ {
+ $route = new \Slim\Route('/hello(/:foo(/:bar+))', function () {});
+
+ $this->assertTrue($route->matches('/hello'));
+ $this->assertTrue($route->matches('/hello/world'));
+ $this->assertTrue($route->matches('/hello/world/foo'));
+ $this->assertTrue($route->matches('/hello/world/foo/bar'));
+ }
+
+ public function testSetMiddleware()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $mw = function () {
+ echo 'Foo';
+ };
+ $route->setMiddleware($mw);
+
+ $this->assertAttributeContains($mw, 'middleware', $route);
+ }
+
+ public function testSetMiddlewareMultipleTimes()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $mw1 = function () {
+ echo 'Foo';
+ };
+ $mw2 = function () {
+ echo 'Bar';
+ };
+ $route->setMiddleware($mw1);
+ $route->setMiddleware($mw2);
+
+ $this->assertAttributeContains($mw1, 'middleware', $route);
+ $this->assertAttributeContains($mw2, 'middleware', $route);
+ }
+
+ public function testSetMiddlewareWithArray()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $mw1 = function () {
+ echo 'Foo';
+ };
+ $mw2 = function () {
+ echo 'Bar';
+ };
+ $route->setMiddleware(array($mw1, $mw2));
+
+ $this->assertAttributeContains($mw1, 'middleware', $route);
+ $this->assertAttributeContains($mw2, 'middleware', $route);
+ }
+
+ public function testSetMiddlewareWithInvalidArgument()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $route = new \Slim\Route('/foo', function () {});
+ $route->setMiddleware('doesNotExist'); // <-- Should throw InvalidArgumentException
+ }
+
+ public function testSetMiddlewareWithArrayWithInvalidArgument()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $route = new \Slim\Route('/foo', function () {});
+ $route->setMiddleware(array('doesNotExist'));
+ }
+
+ public function testGetMiddleware()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'middleware');
+ $property->setAccessible(true);
+ $property->setValue($route, array('foo' => 'bar'));
+
+ $this->assertEquals(array('foo' => 'bar'), $route->getMiddleware());
+ }
+
+ public function testSetHttpMethods()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $route->setHttpMethods('GET', 'POST');
+
+ $this->assertAttributeEquals(array('GET', 'POST'), 'methods', $route);
+ }
+
+ public function testGetHttpMethods()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'methods');
+ $property->setAccessible(true);
+ $property->setValue($route, array('GET', 'POST'));
+
+ $this->assertEquals(array('GET', 'POST'), $route->getHttpMethods());
+ }
+
+ public function testAppendHttpMethods()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'methods');
+ $property->setAccessible(true);
+ $property->setValue($route, array('GET', 'POST'));
+
+ $route->appendHttpMethods('PUT');
+
+ $this->assertAttributeEquals(array('GET', 'POST', 'PUT'), 'methods', $route);
+ }
+
+ public function testAppendHttpMethodsWithVia()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+ $route->via('PUT');
+
+ $this->assertAttributeContains('PUT', 'methods', $route);
+ }
+
+ public function testSupportsHttpMethod()
+ {
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($route, 'methods');
+ $property->setAccessible(true);
+ $property->setValue($route, array('POST'));
+
+ $this->assertTrue($route->supportsHttpMethod('POST'));
+ $this->assertFalse($route->supportsHttpMethod('PUT'));
+ }
+
+ /**
+ * Test dispatch with params
+ */
+ public function testDispatch()
+ {
+ $this->expectOutputString('Hello josh');
+ $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; });
+ $route->matches('/hello/josh'); //<-- Extracts params from resource URI
+ $route->dispatch();
+ }
+
+ /**
+ * Test dispatch with middleware
+ */
+ public function testDispatchWithMiddleware()
+ {
+ $this->expectOutputString('First! Second! Hello josh');
+ $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; });
+ $route->setMiddleware(function () {
+ echo "First! ";
+ });
+ $route->setMiddleware(function () {
+ echo "Second! ";
+ });
+ $route->matches('/hello/josh'); //<-- Extracts params from resource URI
+ $route->dispatch();
+ }
+
+ /**
+ * Test middleware with arguments
+ */
+ public function testRouteMiddlwareArguments()
+ {
+ $this->expectOutputString('foobar');
+ $route = new \Slim\Route('/foo', function () { echo "bar"; });
+ $route->setName('foo');
+ $route->setMiddleware(function ($route) {
+ echo $route->getName();
+ });
+ $route->matches('/foo'); //<-- Extracts params from resource URI
+ $route->dispatch();
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/RouterTest.php b/strillonews/vendor/slim/slim/tests/RouterTest.php
new file mode 100644
index 0000000..a128b23
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/RouterTest.php
@@ -0,0 +1,250 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class RouterTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Constructor should initialize routes as empty array
+ */
+ public function testConstruct()
+ {
+ $router = new \Slim\Router();
+
+ $this->assertAttributeEquals(array(), 'routes', $router);
+ }
+
+ /**
+ * Map should set and return instance of \Slim\Route
+ */
+ public function testMap()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function() {});
+ $router->map($route);
+
+ $this->assertAttributeContains($route, 'routes', $router);
+ }
+
+ /**
+ * Named route should be added and indexed by name
+ */
+ public function testAddNamedRoute()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+ $router->addNamedRoute('foo', $route);
+
+ $property = new \ReflectionProperty($router, 'namedRoutes');
+ $property->setAccessible(true);
+
+ $rV = $property->getValue($router);
+ $this->assertSame($route, $rV['foo']);
+ }
+
+ /**
+ * Named route should have unique name
+ */
+ public function testAddNamedRouteWithDuplicateKey()
+ {
+ $this->setExpectedException('RuntimeException');
+
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+ $router->addNamedRoute('foo', $route);
+ $router->addNamedRoute('foo', $route);
+ }
+
+ /**
+ * Router should return named route by name, or null if not found
+ */
+ public function testGetNamedRoute()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($router, 'namedRoutes');
+ $property->setAccessible(true);
+ $property->setValue($router, array('foo' => $route));
+
+ $this->assertSame($route, $router->getNamedRoute('foo'));
+ $this->assertNull($router->getNamedRoute('bar'));
+ }
+
+ /**
+ * Router should determine named routes and cache results
+ */
+ public function testGetNamedRoutes()
+ {
+ $router = new \Slim\Router();
+ $route1 = new \Slim\Route('/foo', function () {});
+ $route2 = new \Slim\Route('/bar', function () {});
+
+ // Init router routes to array
+ $propertyRouterRoutes = new \ReflectionProperty($router, 'routes');
+ $propertyRouterRoutes->setAccessible(true);
+ $propertyRouterRoutes->setValue($router, array($route1, $route2));
+
+ // Init router named routes to null
+ $propertyRouterNamedRoutes = new \ReflectionProperty($router, 'namedRoutes');
+ $propertyRouterNamedRoutes->setAccessible(true);
+ $propertyRouterNamedRoutes->setValue($router, null);
+
+ // Init route name
+ $propertyRouteName = new \ReflectionProperty($route2, 'name');
+ $propertyRouteName->setAccessible(true);
+ $propertyRouteName->setValue($route2, 'bar');
+
+ $namedRoutes = $router->getNamedRoutes();
+ $this->assertCount(1, $namedRoutes);
+ $this->assertSame($route2, $namedRoutes['bar']);
+ }
+
+ /**
+ * Router should detect presence of a named route by name
+ */
+ public function testHasNamedRoute()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($router, 'namedRoutes');
+ $property->setAccessible(true);
+ $property->setValue($router, array('foo' => $route));
+
+ $this->assertTrue($router->hasNamedRoute('foo'));
+ $this->assertFalse($router->hasNamedRoute('bar'));
+ }
+
+ /**
+ * Router should return current route if set during iteration
+ */
+ public function testGetCurrentRoute()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+
+ $property = new \ReflectionProperty($router, 'currentRoute');
+ $property->setAccessible(true);
+ $property->setValue($router, $route);
+
+ $this->assertSame($route, $router->getCurrentRoute());
+ }
+
+ /**
+ * Router should return first matching route if current route not set yet by iteration
+ */
+ public function testGetCurrentRouteIfMatchedRoutes()
+ {
+ $router = new \Slim\Router();
+ $route = new \Slim\Route('/foo', function () {});
+
+ $propertyMatchedRoutes = new \ReflectionProperty($router, 'matchedRoutes');
+ $propertyMatchedRoutes->setAccessible(true);
+ $propertyMatchedRoutes->setValue($router, array($route));
+
+ $propertyCurrentRoute = new \ReflectionProperty($router, 'currentRoute');
+ $propertyCurrentRoute->setAccessible(true);
+ $propertyCurrentRoute->setValue($router, null);
+
+ $this->assertSame($route, $router->getCurrentRoute());
+ }
+
+ /**
+ * Router should return `null` if current route not set yet and there are no matching routes
+ */
+ public function testGetCurrentRouteIfNoMatchedRoutes()
+ {
+ $router = new \Slim\Router();
+
+ $propertyMatchedRoutes = new \ReflectionProperty($router, 'matchedRoutes');
+ $propertyMatchedRoutes->setAccessible(true);
+ $propertyMatchedRoutes->setValue($router, array());
+
+ $propertyCurrentRoute = new \ReflectionProperty($router, 'currentRoute');
+ $propertyCurrentRoute->setAccessible(true);
+ $propertyCurrentRoute->setValue($router, null);
+
+ $this->assertNull($router->getCurrentRoute());
+ }
+
+ public function testGetMatchedRoutes()
+ {
+ $router = new \Slim\Router();
+
+ $route1 = new \Slim\Route('/foo', function () {});
+ $route1 = $route1->via('GET');
+
+ $route2 = new \Slim\Route('/foo', function () {});
+ $route2 = $route2->via('POST');
+
+ $route3 = new \Slim\Route('/bar', function () {});
+ $route3 = $route3->via('PUT');
+
+ $routes = new \ReflectionProperty($router, 'routes');
+ $routes->setAccessible(true);
+ $routes->setValue($router, array($route1, $route2, $route3));
+
+ $matchedRoutes = $router->getMatchedRoutes('GET', '/foo');
+ $this->assertSame($route1, $matchedRoutes[0]);
+ }
+
+ // Test url for named route
+
+ public function testUrlFor()
+ {
+ $router = new \Slim\Router();
+
+ $route1 = new \Slim\Route('/hello/:first/:last', function () {});
+ $route1 = $route1->via('GET')->name('hello');
+
+ $route2 = new \Slim\Route('/path/(:foo\.:bar)', function () {});
+ $route2 = $route2->via('GET')->name('regexRoute');
+
+ $routes = new \ReflectionProperty($router, 'namedRoutes');
+ $routes->setAccessible(true);
+ $routes->setValue($router, array(
+ 'hello' => $route1,
+ 'regexRoute' => $route2
+ ));
+
+ $this->assertEquals('/hello/Josh/Lockhart', $router->urlFor('hello', array('first' => 'Josh', 'last' => 'Lockhart')));
+ $this->assertEquals('/path/Hello.Josh', $router->urlFor('regexRoute', array('foo' => 'Hello', 'bar' => 'Josh')));
+ }
+
+ public function testUrlForIfNoSuchRoute()
+ {
+ $this->setExpectedException('RuntimeException');
+
+ $router = new \Slim\Router();
+ $router->urlFor('foo', array('abc' => '123'));
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/SlimTest.php b/strillonews/vendor/slim/slim/tests/SlimTest.php
new file mode 100644
index 0000000..3a0deb1
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/SlimTest.php
@@ -0,0 +1,1538 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+//Mock custom view
+class CustomView extends \Slim\View
+{
+ public function render($template, $data = null) { echo "Custom view"; }
+}
+
+//Echo Logger
+class EchoErrorLogger
+{
+ public function error($object) { echo get_class($object) .':'.$object->getMessage(); }
+}
+
+//Mock extending class
+class Derived extends \Slim\Slim
+{
+ public static function getDefaultSettings()
+ {
+ return array_merge(
+ array("late-static-binding" => true)
+ , parent::getDefaultSettings());
+ }
+}
+
+//Mock middleware
+class CustomMiddleware extends \Slim\Middleware
+{
+ public function call()
+ {
+ $env = $this->app->environment();
+ $res = $this->app->response();
+ $env['slim.test'] = 'Hello';
+ $this->next->call();
+ $res->header('X-Slim-Test', 'Hello');
+ $res->write('Hello');
+ }
+}
+
+class SlimTest extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ //Remove environment mode if set
+ unset($_ENV['SLIM_MODE']);
+
+ //Reset session
+ $_SESSION = array();
+
+ //Prepare default environment variables
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'QUERY_STRING' => 'one=foo&two=bar',
+ 'SERVER_NAME' => 'slimframework.com',
+ ));
+ }
+
+ /************************************************
+ * INSTANTIATION
+ ************************************************/
+
+ /**
+ * Test version constant is string
+ */
+ public function testHasVersionConstant()
+ {
+ $this->assertTrue(is_string(\Slim\Slim::VERSION));
+ }
+
+ /**
+ * Test default instance properties
+ */
+ public function testDefaultInstanceProperties()
+ {
+ $s = new \Slim\Slim();
+ $this->assertInstanceOf('\Slim\Http\Request', $s->request());
+ $this->assertInstanceOf('\Slim\Http\Response', $s->response());
+ $this->assertInstanceOf('\Slim\Router', $s->router());
+ $this->assertInstanceOf('\Slim\View', $s->view());
+ $this->assertInstanceOf('\Slim\Log', $s->getLog());
+ $this->assertEquals(\Slim\Log::DEBUG, $s->getLog()->getLevel());
+ $this->assertTrue($s->getLog()->getEnabled());
+ $this->assertInstanceOf('\Slim\Environment', $s->environment());
+ }
+
+ /**
+ * Test get default instance
+ */
+ public function testGetDefaultInstance()
+ {
+ $s = new \Slim\Slim();
+ $s->setName('default'); //We must do this manually since a default app is already set in prev tests
+ $this->assertEquals('default', $s->getName());
+ $this->assertInstanceOf('\Slim\Slim', \Slim\Slim::getInstance());
+ $this->assertSame($s, \Slim\Slim::getInstance());
+ }
+
+ /**
+ * Test get named instance
+ */
+ public function testGetNamedInstance()
+ {
+ $s = new \Slim\Slim();
+ $s->setName('foo');
+ $this->assertSame($s, \Slim\Slim::getInstance('foo'));
+ }
+
+ /**
+ * Test Slim autoloader ignores non-Slim classes
+ *
+ * Pre-conditions:
+ * Instantiate a non-Slim class;
+ *
+ * Post-conditions:
+ * Slim autoloader returns without requiring a class file;
+ */
+ public function testSlimAutoloaderIgnoresNonSlimClass()
+ {
+ $foo = new Foo();
+ }
+
+ /************************************************
+ * SETTINGS
+ ************************************************/
+
+ /**
+ * Test get setting that exists
+ */
+ public function testGetSettingThatExists()
+ {
+ $s = new \Slim\Slim();
+ $this->assertEquals('./templates', $s->config('templates.path'));
+ }
+
+ /**
+ * Test get setting that does not exist
+ */
+ public function testGetSettingThatDoesNotExist()
+ {
+ $s = new \Slim\Slim();
+ $this->assertNull($s->config('foo'));
+ }
+
+ /**
+ * Test set setting
+ */
+ public function testSetSetting()
+ {
+ $s = new \Slim\Slim();
+ $this->assertEquals('./templates', $s->config('templates.path'));
+ $s->config('templates.path', './tmpl');
+ $this->assertEquals('./tmpl', $s->config('templates.path'));
+ }
+
+ /**
+ * Test batch set settings
+ */
+ public function testBatchSetSettings()
+ {
+ $s = new \Slim\Slim();
+ $this->assertEquals('./templates', $s->config('templates.path'));
+ $this->assertTrue($s->config('debug'));
+ $s->config(array(
+ 'templates.path' => './tmpl',
+ 'debug' => false
+ ));
+ $this->assertEquals('./tmpl', $s->config('templates.path'));
+ $this->assertFalse($s->config('debug'));
+ }
+
+ /************************************************
+ * MODES
+ ************************************************/
+
+ /**
+ * Test default mode
+ */
+ public function testGetDefaultMode()
+ {
+ $s = new \Slim\Slim();
+ $this->assertEquals('development', $s->getMode());
+ }
+
+ /**
+ * Test custom mode from environment
+ */
+ public function testGetModeFromEnvironment()
+ {
+ $_ENV['SLIM_MODE'] = 'production';
+ $s = new \Slim\Slim();
+ $this->assertEquals('production', $s->getMode());
+ }
+
+ /**
+ * Test custom mode from app settings
+ */
+ public function testGetModeFromSettings()
+ {
+ $s = new \Slim\Slim(array(
+ 'mode' => 'test'
+ ));
+ $this->assertEquals('test', $s->getMode());
+ }
+
+ /**
+ * Test mode configuration
+ */
+ public function testModeConfiguration()
+ {
+ $flag = 0;
+ $configureTest = function () use (&$flag) {
+ $flag = 'test';
+ };
+ $configureProduction = function () use (&$flag) {
+ $flag = 'production';
+ };
+ $s = new \Slim\Slim(array('mode' => 'test'));
+ $s->configureMode('test', $configureTest);
+ $s->configureMode('production', $configureProduction);
+ $this->assertEquals('test', $flag);
+ }
+
+ /**
+ * Test mode configuration when mode does not match
+ */
+ public function testModeConfigurationWhenModeDoesNotMatch()
+ {
+ $flag = 0;
+ $configureTest = function () use (&$flag) {
+ $flag = 'test';
+ };
+ $s = new \Slim\Slim(array('mode' => 'production'));
+ $s->configureMode('test', $configureTest);
+ $this->assertEquals(0, $flag);
+ }
+
+ /**
+ * Test mode configuration when not callable
+ */
+ public function testModeConfigurationWhenNotCallable()
+ {
+ $flag = 0;
+ $s = new \Slim\Slim(array('mode' => 'production'));
+ $s->configureMode('production', 'foo');
+ $this->assertEquals(0, $flag);
+ }
+
+ /**
+ * Test custom mode from getenv()
+ */
+ public function testGetModeFromGetEnv()
+ {
+ putenv('SLIM_MODE=production');
+ $s = new \Slim\Slim();
+ $this->assertEquals('production', $s->getMode());
+ }
+
+ /************************************************
+ * ROUTING
+ ************************************************/
+
+ /**
+ * Test GENERIC route
+ */
+ public function testGenericRoute()
+ {
+ $s = new \Slim\Slim();
+ $callable = function () { echo "foo"; };
+ $route = $s->map('/bar', $callable);
+ $this->assertInstanceOf('\Slim\Route', $route);
+ $this->assertEmpty($route->getHttpMethods());
+ }
+
+ /**
+ * Test GET routes also get mapped as a HEAD route
+ */
+ public function testGetRouteIsAlsoMappedAsHead()
+ {
+ $s = new \Slim\Slim();
+ $route = $s->get('/foo', function () {});
+ $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_GET));
+ $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_HEAD));
+ }
+
+ /**
+ * Test GET route
+ */
+ public function testGetRoute()
+ {
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->get('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test POST route
+ */
+ public function testPostRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'POST',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->post('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test PUT route
+ */
+ public function testPutRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PUT',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->put('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test PATCH route
+ */
+ public function testPatchRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'PATCH',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->patch('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test DELETE route
+ */
+ public function testDeleteRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'DELETE',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->delete('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test OPTIONS route
+ */
+ public function testOptionsRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'OPTIONS',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $route = $s->options('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+
+ /**
+ * Test route groups
+ */
+ public function testRouteGroups()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar/baz', //<-- Virtual'
+ ));
+ $s = new \Slim\Slim();
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $s->group('/bar', $mw1, function () use ($s, $mw2, $callable) {
+ $s->get('/baz', $mw2, $callable);
+ });
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ }
+
+ /*
+ * Test ANY route
+ */
+ public function testAnyRoute()
+ {
+ $mw1 = function () { echo "foo"; };
+ $mw2 = function () { echo "bar"; };
+ $callable = function () { echo "xyz"; };
+ $methods = array('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS');
+ foreach ($methods as $i => $method) {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => $method,
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $route = $s->any('/bar', $mw1, $mw2, $callable);
+ $s->call();
+ $this->assertEquals('foobarxyz', $s->response()->body());
+ $this->assertEquals('/bar', $route->getPattern());
+ $this->assertSame($callable, $route->getCallable());
+ }
+ }
+
+ /**
+ * Test if route does NOT expect trailing slash and URL has one
+ */
+ public function testRouteWithoutSlashAndUrlWithOne()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar/', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () { echo "xyz"; });
+ $s->call();
+ $this->assertEquals(404, $s->response()->status());
+ }
+
+ /**
+ * Test if route contains URL encoded characters
+ */
+ public function testRouteWithUrlEncodedCharacters()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar/jo%20hn/smi%20th', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar/:one/:two', function ($one, $two) { echo $one . $two; });
+ $s->call();
+ $this->assertEquals('jo hnsmi th', $s->response()->body());
+ }
+
+ /************************************************
+ * VIEW
+ ************************************************/
+
+ /**
+ * Test set view with string class name
+ */
+ public function testSetSlimViewFromString()
+ {
+ $s = new \Slim\Slim();
+ $this->assertInstanceOf('\Slim\View', $s->view());
+ $s->view('CustomView');
+ $this->assertInstanceOf('CustomView', $s->view());
+ }
+
+ /**
+ * Test set view with object instance
+ */
+ public function testSetSlimViewFromInstance()
+ {
+ $s = new \Slim\Slim();
+ $this->assertInstanceOf('\Slim\View', $s->view());
+ $s->view(new CustomView());
+ $this->assertInstanceOf('CustomView', $s->view());
+ }
+
+ /**
+ * Test view data is transferred to newer view
+ */
+ public function testViewDataTransfer()
+ {
+ $data = array('foo' => 'bar');
+ $s = new \Slim\Slim();
+ $s->view()->setData($data);
+ $s->view('CustomView');
+ $this->assertSame($data, $s->view()->getData());
+ }
+
+ /************************************************
+ * RENDERING
+ ************************************************/
+
+ /**
+ * Test template path is passed to view
+ */
+ public function testViewGetsTemplatesPath()
+ {
+ $path = dirname(__FILE__) . '/templates';
+ $s = new \Slim\Slim(array('templates.path' => $path));
+ $this->assertEquals($s->view->getTemplatesDirectory(), $path);
+ }
+
+ /**
+ * Test render with template and data
+ */
+ public function testRenderTemplateWithData()
+ {
+ $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates'));
+ $s->get('/bar', function () use ($s) {
+ $s->render('test.php', array('foo' => 'bar'));
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(200, $status);
+ $this->assertEquals('test output bar', $body);
+ }
+
+ /**
+ * Test render with template and data and status
+ */
+ public function testRenderTemplateWithDataAndStatus()
+ {
+ $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates'));
+ $s->get('/bar', function () use ($s) {
+ $s->render('test.php', array('foo' => 'bar'), 500);
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(500, $status);
+ $this->assertEquals('test output bar', $body);
+ }
+
+ /************************************************
+ * LOG
+ ************************************************/
+
+ /**
+ * Test get log
+ *
+ * This asserts that a Slim app has a default Log
+ * upon instantiation. The Log itself is tested
+ * separately in another file.
+ */
+ public function testGetLog()
+ {
+ $s = new \Slim\Slim();
+ $this->assertInstanceOf('\Slim\Log', $s->getLog());
+ }
+
+ /************************************************
+ * HTTP CACHING
+ ************************************************/
+
+ /**
+ * Test Last-Modified match
+ */
+ public function testLastModifiedMatch()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 21:00:52 GMT',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->lastModified(1286139652);
+ });
+ $s->call();
+ $this->assertEquals(304, $s->response()->status());
+ }
+
+ /**
+ * Test Last-Modified match
+ */
+ public function testLastModifiedDoesNotMatch()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 21:00:52 GMT',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->lastModified(1286139250);
+ });
+ $s->call();
+ $this->assertEquals(200, $s->response()->status());
+ }
+
+ public function testLastModifiedOnlyAcceptsIntegers()
+ {
+ $this->setExpectedException('\InvalidArgumentException');
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->lastModified('Test');
+ });
+ $s->call();
+ }
+
+ /**
+ * Test Last Modified header format
+ */
+ public function testLastModifiedHeaderFormat()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->lastModified(1286139652);
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertTrue(isset($header['Last-Modified']));
+ $this->assertEquals('Sun, 03 Oct 2010 21:00:52 GMT', $header['Last-Modified']);
+ }
+
+ /**
+ * Test ETag matches
+ */
+ public function testEtagMatches()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'HTTP_IF_NONE_MATCH' => '"abc123"',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->etag('abc123');
+ });
+ $s->call();
+ $this->assertEquals(304, $s->response()->status());
+ }
+
+ /**
+ * Test ETag does not match
+ */
+ public function testEtagDoesNotMatch()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'IF_NONE_MATCH' => '"abc1234"',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->etag('abc123');
+ });
+ $s->call();
+ $this->assertEquals(200, $s->response()->status());
+ }
+
+ /**
+ * Test ETag with invalid type
+ */
+ public function testETagWithInvalidType()
+ {
+ $this->setExpectedException('\InvalidArgumentException');
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'IF_NONE_MATCH' => '"abc1234"',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->etag('123','foo');
+ });
+ $s->call();
+ }
+
+ /**
+ * Test Expires
+ */
+ public function testExpiresAsString()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $expectedDate = gmdate('D, d M Y H:i:s T', strtotime('5 days'));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->expires('5 days');
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertTrue(isset($header['Expires']));
+ $this->assertEquals($header['Expires'], $expectedDate);
+ }
+
+ /**
+ * Test Expires
+ */
+ public function testExpiresAsInteger()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $fiveDaysFromNow = time() + (60 * 60 * 24 * 5);
+ $expectedDate = gmdate('D, d M Y H:i:s T', $fiveDaysFromNow);
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s, $fiveDaysFromNow) {
+ $s->expires($fiveDaysFromNow);
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertTrue(isset($header['Expires']));
+ $this->assertEquals($header['Expires'], $expectedDate);
+ }
+
+ /************************************************
+ * COOKIES
+ ************************************************/
+
+ /**
+ * Set cookie
+ *
+ * This tests that the Slim application instance sets
+ * a cookie in the HTTP response header. This does NOT
+ * test the implementation of setting the cookie; that is
+ * tested in a separate file.
+ */
+ public function testSetCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->setCookie('foo', 'bar', '2 days');
+ $s->setCookie('foo1', 'bar1', '2 days');
+ });
+ $s->call();
+ $cookie1 = $s->response->cookies->get('foo');
+ $cookie2 = $s->response->cookies->get('foo1');
+ $this->assertEquals(2, count($s->response->cookies));
+ $this->assertEquals('bar', $cookie1['value']);
+ $this->assertEquals('bar1', $cookie2['value']);
+ }
+
+ /**
+ * Test get cookie
+ *
+ * This method ensures that the `Cookie:` HTTP request
+ * header is parsed if present, and made accessible via the
+ * Request object.
+ */
+ public function testGetCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'REQUEST_METHOD' => 'GET',
+ 'REMOTE_ADDR' => '127.0.0.1',
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'QUERY_STRING' => 'one=foo&two=bar',
+ 'SERVER_NAME' => 'slimframework.com',
+ 'SERVER_PORT' => 80,
+ 'HTTP_COOKIE' => 'foo=bar; foo2=bar2',
+ 'slim.url_scheme' => 'http',
+ 'slim.input' => '',
+ 'slim.errors' => @fopen('php://stderr', 'w')
+ ));
+ $s = new \Slim\Slim();
+ $this->assertEquals('bar', $s->getCookie('foo'));
+ $this->assertEquals('bar2', $s->getCookie('foo2'));
+ }
+
+ /**
+ * Test get cookie when cookie does not exist
+ */
+ public function testGetCookieThatDoesNotExist()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $this->assertNull($s->getCookie('foo'));
+ }
+
+ /**
+ * Test delete cookie
+ *
+ * This method ensures that the `Set-Cookie:` HTTP response
+ * header is set. The implementation of setting the response
+ * cookie is tested separately in another file.
+ */
+ public function testDeleteCookie()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/bar', //<-- Virtual
+ 'COOKIE' => 'foo=bar; foo2=bar2',
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->setCookie('foo', 'bar');
+ $s->deleteCookie('foo');
+ });
+ $s->call();
+ $cookie = $s->response->cookies->get('foo');
+ $this->assertEquals(1, count($s->response->cookies));
+ $this->assertEquals('', $cookie['value']);
+ $this->assertLessThan(time(), $cookie['expires']);
+ }
+
+ /************************************************
+ * HELPERS
+ ************************************************/
+
+ /**
+ * Test get filesystem path to Slim app root directory
+ */
+ public function testGetRoot()
+ {
+ $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__); //<-- No trailing slash
+ $s = new \Slim\Slim();
+ $this->assertEquals($_SERVER['DOCUMENT_ROOT'] . '/foo/', $s->root()); //<-- Appends physical app path with trailing slash
+ }
+
+ /**
+ * Test stop
+ */
+ public function testStop()
+ {
+ $this->setExpectedException('\Slim\Exception\Stop');
+ $s = new \Slim\Slim();
+ $s->stop();
+ }
+
+ /**
+ * Test stop with subsequent output
+ */
+ public function testStopWithSubsequentOutput()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo"; //<-- Should be in response body!
+ $s->stop();
+ echo "Bar"; //<-- Should not be in response body!
+ });
+ $s->call();
+ $this->assertEquals('Foo', $s->response()->body());
+ }
+
+ /**
+ * Test stop with output buffer on and pre content
+ */
+ public function testStopOutputWithOutputBufferingOnAndPreContent()
+ {
+ $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here
+ echo "1.";
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo";
+ $s->stop();
+ });
+ echo "2.";
+ $s->run(); //<-- Needs to be run to actually echo body
+ echo ".3";
+ }
+
+ /**
+ * Test stop does not leave output buffers open
+ */
+ public function testStopDoesNotLeaveOutputBuffersOpen()
+ {
+ $level_start = ob_get_level();
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->stop();
+ });
+ $s->run();
+ $this->assertEquals($level_start, ob_get_level());
+ }
+
+ /**
+ * Test halt
+ */
+ public function testHalt()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo!"; //<-- Should not be in response body!
+ $s->halt(500, 'Something broke');
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(500, $status);
+ $this->assertEquals('Something broke', $body);
+ }
+
+ /**
+ * Test halt with output buffering and pre content
+ */
+ public function testHaltOutputWithOutputBufferingOnAndPreContent()
+ {
+ $this->expectOutputString('1.2.Something broke.3'); //<-- PHP unit uses OB here
+ echo "1.";
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo!"; //<-- Should not be in response body!
+ $s->halt(500, 'Something broke');
+ });
+ echo "2.";
+ $s->run();
+ echo ".3";
+ }
+
+ /**
+ * Test halt does not leave output buffers open
+ */
+ public function testHaltDoesNotLeaveOutputBuffersOpen()
+ {
+ $level_start = ob_get_level();
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->halt(500, '');
+ });
+ $s->run();
+ $this->assertEquals($level_start, ob_get_level());
+ }
+
+ /**
+ * Test pass cleans buffer and throws exception
+ */
+ public function testPass()
+ {
+ ob_start();
+ $s = new \Slim\Slim();
+ echo "Foo";
+ try {
+ $s->pass();
+ $this->fail('Did not catch Slim_Exception_Pass');
+ } catch ( \Slim\Exception\Pass $e ) {}
+ $output = ob_get_clean();
+ $this->assertEquals('', $output);
+ }
+
+ /**
+ * Test pass when there is a subsequent fallback route
+ */
+ public function testPassWithSubsequentRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/name/Frank', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/name/Frank', function () use ($s) {
+ echo "Fail"; //<-- Should not be in response body!
+ $s->pass();
+ });
+ $s->get('/name/:name', function ($name) {
+ echo $name; //<-- Should be in response body!
+ });
+ $s->call();
+ $this->assertEquals('Frank', $s->response()->body());
+ }
+
+ /**
+ * Test pass when there is not a subsequent fallback route
+ */
+ public function testPassWithoutSubsequentRoute()
+ {
+ \Slim\Environment::mock(array(
+ 'SCRIPT_NAME' => '/foo', //<-- Physical
+ 'PATH_INFO' => '/name/Frank', //<-- Virtual
+ ));
+ $s = new \Slim\Slim();
+ $s->get('/name/Frank', function () use ($s) {
+ echo "Fail"; //<-- Should not be in response body!
+ $s->pass();
+ });
+ $s->call();
+ $this->assertEquals(404, $s->response()->status());
+ }
+
+ /**
+ * Test content type
+ */
+ public function testContentType()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->contentType('application/json');
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals('application/json', $header['Content-Type']);
+ }
+
+ /**
+ * Test status
+ */
+ public function testStatus()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->status(403);
+ });
+ $s->call();
+ $this->assertEquals(403, $s->response()->status());
+ }
+
+ /**
+ * Test URL for
+ */
+ public function testSlimUrlFor()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/hello/:name', function () {})->name('hello');
+ $this->assertEquals('/foo/hello/Josh', $s->urlFor('hello', array('name' => 'Josh'))); //<-- Prepends physical path!
+ }
+
+ /**
+ * Test redirect sets status and header
+ */
+ public function testRedirect()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo"; //<-- Should not be in response body!
+ $s->redirect('/somewhere/else', 303);
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(303, $status);
+ $this->assertEquals('/somewhere/else', $header['Location']);
+ $this->assertEquals('', $body);
+ }
+
+ /************************************************
+ * RUNNER
+ ************************************************/
+
+ /**
+ * Test that runner sends headers and body
+ */
+ public function testRun()
+ {
+ $this->expectOutputString('Foo');
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ echo "Foo";
+ });
+ $s->run();
+ }
+
+ /**
+ * Test runner output with output buffering on and pre content
+ */
+ public function testRunOutputWithOutputBufferingOnAndPreContent()
+ {
+ $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here
+ $s = new \Slim\Slim();
+ echo "1.";
+ $s->get('/bar', function () use ($s) {
+ echo "Foo";
+ });
+ echo "2.";
+ $s->run();
+ echo ".3";
+ }
+
+ /**
+ * Test that runner does not leave output buffers open
+ */
+ public function testRunDoesNotLeaveAnyOutputBuffersOpen()
+ {
+ $level_start = ob_get_level();
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {});
+ $s->run();
+ $this->assertEquals($level_start, ob_get_level());
+ }
+
+ /************************************************
+ * MIDDLEWARE
+ ************************************************/
+
+ /**
+ * Test add middleware
+ *
+ * This asserts that middleware are queued and called
+ * in sequence. This also asserts that the environment
+ * variables are passed by reference.
+ */
+ public function testAddMiddleware()
+ {
+ $this->expectOutputString('FooHello');
+ $s = new \Slim\Slim();
+ $s->add(new CustomMiddleware()); //<-- See top of this file for class definition
+ $s->get('/bar', function () {
+ echo 'Foo';
+ });
+ $s->run();
+ $this->assertEquals('Hello', $s->response()->header('X-Slim-Test'));
+ }
+
+ /************************************************
+ * FLASH MESSAGING
+ ************************************************/
+
+ public function testSetFlashForNextRequest()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->flash('info', 'bar');
+ });
+ $this->assertFalse(isset($_SESSION['slim.flash']));
+ $s->run();
+ $this->assertEquals('bar', $_SESSION['slim.flash']['info']);
+ }
+
+ public function testSetFlashForCurrentRequest()
+ {
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->flashNow('info', 'bar');
+ });
+ $s->run();
+ $env = $s->environment();
+ $this->assertEquals('bar', $env['slim.flash']['info']);
+ }
+
+ public function testKeepFlashForNextRequest()
+ {
+ $_SESSION['slim.flash'] = array('info' => 'Foo');
+ $s = new \Slim\Slim();
+ $s->get('/bar', function () use ($s) {
+ $s->flashKeep();
+ });
+ $s->run();
+ $this->assertEquals('Foo', $_SESSION['slim.flash']['info']);
+ }
+
+ /************************************************
+ * NOT FOUND HANDLING
+ ************************************************/
+
+ /**
+ * Test custom Not Found handler
+ */
+ public function testNotFound()
+ {
+ $s = new \Slim\Slim();
+ $s->notFound(function () {
+ echo "Not Found";
+ });
+ $s->get('/foo', function () {});
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(404, $status);
+ $this->assertEquals('Not Found', $body);
+ }
+
+ /************************************************
+ * ERROR HANDLING
+ ************************************************/
+
+ /**
+ * Test default and custom error handlers
+ *
+ * Pre-conditions:
+ * Invoked app route calls default error handler;
+ *
+ * Post-conditions:
+ * Response status code is 500;
+ */
+ public function testSlimError()
+ {
+ $s = new \Slim\Slim(array(
+ "log.enabled" => false
+ ));
+ $s->get('/bar', function () use ($s) {
+ $s->error();
+ });
+ $s->call();
+ $this->assertEquals(500, $s->response()->status());
+ }
+
+ /**
+ * Test default error handler logs the error when debug is false.
+ *
+ * Pre-conditions:
+ * Invoked app route calls default error handler;
+ *
+ * Post-conditions:
+ * Error log is called
+ */
+ public function testDefaultHandlerLogsTheErrorWhenDebugIsFalse()
+ {
+ $s = new \Slim\Slim(array('debug' => false));
+ $s->container->singleton('log', function ($c) {
+ return new EchoErrorLogger();
+ });
+ $s->get('/bar', function () use ($s) {
+ throw new \InvalidArgumentException('my specific error message');
+ });
+
+ ob_start();
+ $s->run();
+ $output = ob_get_clean();
+ $this->assertTrue(strpos($output, 'InvalidArgumentException:my specific error message') !== false);
+ }
+
+ /**
+ * Test triggered errors are converted to ErrorExceptions
+ *
+ * Pre-conditions:
+ * Custom error handler defined;
+ * Invoked app route triggers error;
+ *
+ * Post-conditions:
+ * Response status is 500;
+ * Response body is equal to triggered error message;
+ * Error handler's argument is ErrorException instance;
+ */
+ public function DISABLEDtestTriggeredErrorsAreConvertedToErrorExceptions()
+ {
+ $s = new \Slim\Slim(array(
+ 'debug' => false
+ ));
+ $s->error(function ( $e ) {
+ if ($e instanceof \ErrorException) {
+ echo $e->getMessage();
+ }
+ });
+ $s->get('/bar', function () {
+ trigger_error('Foo I say!');
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(500, $status);
+ $this->assertEquals('Foo I say!', $body);
+ }
+
+ /**
+ * Test error triggered with multiple applications
+ *
+ * Pre-conditions:
+ * Multiple Slim apps are instantiated;
+ * Both apps are run;
+ * One app returns 200 OK;
+ * One app triggers an error;
+ *
+ * Post-conditions:
+ * One app returns 200 OK with no Exceptions;
+ * One app returns 500 Error;
+ * Error triggered does not affect other app;
+ */
+ public function testErrorWithMultipleApps()
+ {
+ $s1 = new \Slim\Slim(array(
+ 'debug' => false,
+ 'log.enabled' => false
+ ));
+ $s2 = new \Slim\Slim();
+ $s1->get('/bar', function () use ($s1) {
+ $s1->error();
+ });
+ $s2->get('/bar', function () {
+ echo 'success';
+ });
+ $s1->call();
+ $s2->call();
+ $this->assertEquals(500, $s1->response()->status());
+ $this->assertEquals(200, $s2->response()->status());
+ }
+
+ /**
+ * Test custom error handler uses existing Response object
+ */
+ public function testErrorHandlerUsesCurrentResponseObject()
+ {
+ $s = new \Slim\Slim(array(
+ 'debug' => false
+ ));
+ $s->error(function ( \Exception $e ) use ($s) {
+ $r = $s->response();
+ $r->status(503);
+ $r->write('Foo');
+ $r['X-Powered-By'] = 'Slim';
+ echo 'Bar';
+ });
+ $s->get('/bar', function () {
+ throw new \Exception('Foo');
+ });
+ $s->call();
+ list($status, $header, $body) = $s->response()->finalize();
+ $this->assertEquals(503, $status);
+ $this->assertEquals('FooBar', $body);
+ $this->assertEquals('Slim', $header['X-Powered-By']);
+ }
+
+ /**
+ * Test custom global error handler
+ */
+ public function testHandleErrors()
+ {
+ $defaultErrorReporting = error_reporting();
+
+ // Test 1
+ error_reporting(E_ALL ^ E_NOTICE); // <-- Report all errors EXCEPT notices
+ try {
+ \Slim\Slim::handleErrors(E_NOTICE, 'test error', 'Slim.php', 119);
+ } catch (\ErrorException $e) {
+ $this->fail('Slim::handleErrors reported a disabled error level.');
+ }
+
+ // Test 2
+ error_reporting(E_ALL | E_STRICT); // <-- Report all errors, including E_STRICT
+ try {
+ \Slim\Slim::handleErrors(E_STRICT, 'test error', 'Slim.php', 119);
+ $this->fail('Slim::handleErrors didn\'t report a enabled error level');
+ } catch (\ErrorException $e) {}
+
+ error_reporting($defaultErrorReporting);
+ }
+
+ /**
+ * Slim should keep reference to a callable error callback
+ */
+ public function testErrorHandler() {
+ $s = new \Slim\Slim();
+ $errCallback = function () { echo "404"; };
+ $s->error($errCallback);
+ $this->assertSame($errCallback, PHPUnit_Framework_Assert::readAttribute($s, 'error'));
+ }
+
+ /**
+ * Slim should throw a Slim_Exception_Stop if error callback is not callable
+ */
+ public function testErrorHandlerIfNotCallable() {
+ $this->setExpectedException('\Slim\Exception\Stop');
+ $s = new \Slim\Slim(array("log.enabled" => false));
+ $errCallback = 'foo';
+ $s->error($errCallback);
+ }
+
+ /**
+ * Slim should keep reference to a callable NotFound callback
+ */
+ public function testNotFoundHandler() {
+ $s = new \Slim\Slim();
+ $notFoundCallback = function () { echo "404"; };
+ $s->notFound($notFoundCallback);
+ $this->assertSame($notFoundCallback, PHPUnit_Framework_Assert::readAttribute($s, 'notFound'));
+ }
+
+ /**
+ * Slim should throw a Slim_Exception_Stop if NotFound callback is not callable
+ */
+ public function testNotFoundHandlerIfNotCallable() {
+ $this->setExpectedException('\Slim\Exception\Stop');
+ $s = new \Slim\Slim();
+ $notFoundCallback = 'foo';
+ $s->notFound($notFoundCallback);
+ }
+
+ /************************************************
+ * HOOKS
+ ************************************************/
+
+ /**
+ * Test hook listener
+ *
+ * Pre-conditions:
+ * Slim app instantiated;
+ * Hook name does not exist;
+ * Listeners are callable objects;
+ *
+ * Post-conditions:
+ * Callables are invoked in expected order;
+ */
+ public function testRegistersAndCallsHooksByPriority()
+ {
+ $this->expectOutputString('barfoo');
+ $app = new \Slim\Slim();
+ $callable1 = function () { echo "foo"; };
+ $callable2 = function () { echo "bar"; };
+ $app->hook('test.hook.one', $callable1); //default is 10
+ $app->hook('test.hook.one', $callable2, 8);
+ $hooks = $app->getHooks();
+ $this->assertEquals(7, count($hooks)); //6 default, 1 custom
+ $app->applyHook('test.hook.one');
+ }
+
+ /**
+ * Test hook listener if listener is not callable
+ *
+ * Pre-conditions:
+ * Slim app instantiated;
+ * Hook name does not exist;
+ * Listener is NOT a callable object;
+ *
+ * Post-conditions:
+ * Hook is created;
+ * Callable is NOT assigned to hook;
+ */
+ public function testHookInvalidCallable()
+ {
+ $app = new \Slim\Slim();
+ $callable = 'test'; //NOT callable
+ $app->hook('test.hook.one', $callable);
+ $this->assertEquals(array(array()), $app->getHooks('test.hook.one'));
+ }
+
+ /**
+ * Test hook invocation if hook does not exist
+ *
+ * Pre-conditions:
+ * Slim app instantiated;
+ * Hook name does not exist;
+ *
+ * Post-conditions:
+ * Hook is created;
+ * Hook initialized with empty array;
+ */
+ public function testHookInvocationIfNotExists()
+ {
+ $app = new \Slim\Slim();
+ $app->applyHook('test.hook.one');
+ $this->assertEquals(array(array()), $app->getHooks('test.hook.one'));
+ }
+
+ /**
+ * Test clear hooks
+ *
+ * Pre-conditions:
+ * Slim app instantiated;
+ * Two hooks exist, each with one listener;
+ *
+ * Post-conditions:
+ * Case A: Listeners for 'test.hook.one' are cleared;
+ * Case B: Listeners for all hooks are cleared;
+ */
+ public function testHookClear()
+ {
+ $app = new \Slim\Slim();
+ $app->hook('test.hook.one', function () {});
+ $app->hook('test.hook.two', function () {});
+ $app->clearHooks('test.hook.two');
+ $this->assertEquals(array(array()), $app->getHooks('test.hook.two'));
+ $hookOne = $app->getHooks('test.hook.one');
+ $this->assertTrue(count($hookOne[10]) === 1);
+ $app->clearHooks();
+ $this->assertEquals(array(array()), $app->getHooks('test.hook.one'));
+ }
+
+ /**
+ * Test late static binding
+ *
+ * Pre-conditions:
+ * Slim app is extended by Derived class and instantiated;
+ * Derived class overrides the 'getDefaultSettings' function and adds an extra default config value
+ * Test that the new config value exists
+ *
+ * Post-conditions:
+ * Config value exists and is equal to expected value
+ */
+ public function testDerivedClassCanOverrideStaticFunction()
+ {
+ $app = new Derived();
+ $this->assertEquals($app->config("late-static-binding"), true);
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/ViewTest.php b/strillonews/vendor/slim/slim/tests/ViewTest.php
new file mode 100644
index 0000000..e0f681d
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/ViewTest.php
@@ -0,0 +1,198 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.4.0
+ *
+ * MIT LICENSE
+ *
+ * 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.
+ */
+
+class ViewTest extends PHPUnit_Framework_TestCase
+{
+ public function testGetDataAll()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+
+ $this->assertSame(array('foo' => 'bar'), $view->getData());
+ }
+
+ public function testGetDataKeyExists()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+
+ $this->assertEquals('bar', $view->getData('foo'));
+ }
+
+ public function testGetDataKeyNotExists()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+
+ $this->assertNull($view->getData('abc'));
+ }
+
+ public function testSetDataKeyValue()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $view->setData('foo', 'bar');
+
+ $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all());
+ }
+
+ public function testSetDataKeyValueAsClosure()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+
+ $view->setData('fooClosure', function () {
+ return 'foo';
+ });
+
+ $value = $prop->getValue($view)->get('fooClosure');
+ $this->assertInstanceOf('Closure', $value);
+ $this->assertEquals('foo', $value());
+ }
+
+ public function testSetDataArray()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $view->setData(array('foo' => 'bar'));
+
+ $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all());
+ }
+
+ public function testSetDataInvalidArgument()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $view = new \Slim\View();
+ $view->setData('foo');
+ }
+
+ public function testAppendData()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $view->appendData(array('foo' => 'bar'));
+
+ $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all());
+ }
+
+ public function testLocalData()
+ {
+ $view = new \Slim\View();
+ $prop1 = new \ReflectionProperty($view, 'data');
+ $prop1->setAccessible(true);
+ $prop1->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+
+ $prop2 = new \ReflectionProperty($view, 'templatesDirectory');
+ $prop2->setAccessible(true);
+ $prop2->setValue($view, dirname(__FILE__) . '/templates');
+
+ $output = $view->fetch('test.php', array('foo' => 'baz'));
+ $this->assertEquals('test output baz', $output);
+ }
+
+ public function testAppendDataOverwrite()
+ {
+ $view = new \Slim\View();
+ $prop = new \ReflectionProperty($view, 'data');
+ $prop->setAccessible(true);
+ $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+ $view->appendData(array('foo' => '123'));
+
+ $this->assertEquals(array('foo' => '123'), $prop->getValue($view)->all());
+ }
+
+ public function testAppendDataInvalidArgument()
+ {
+ $this->setExpectedException('InvalidArgumentException');
+
+ $view = new \Slim\View();
+ $view->appendData('foo');
+ }
+
+ public function testGetTemplatesDirectory()
+ {
+ $view = new \Slim\View();
+ $property = new \ReflectionProperty($view, 'templatesDirectory');
+ $property->setAccessible(true);
+ $property->setValue($view, 'templates');
+
+ $this->assertEquals('templates', $view->getTemplatesDirectory());
+ }
+
+ public function testSetTemplatesDirectory()
+ {
+ $view = new \Slim\View();
+ $view->setTemplatesDirectory('templates/'); // <-- Should strip trailing slash
+
+ $this->assertAttributeEquals('templates', 'templatesDirectory', $view);
+ }
+
+ public function testDisplay()
+ {
+ $this->expectOutputString('test output bar');
+
+ $view = new \Slim\View();
+ $prop1 = new \ReflectionProperty($view, 'data');
+ $prop1->setAccessible(true);
+ $prop1->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar')));
+
+ $prop2 = new \ReflectionProperty($view, 'templatesDirectory');
+ $prop2->setAccessible(true);
+ $prop2->setValue($view, dirname(__FILE__) . '/templates');
+
+ $view->display('test.php');
+ }
+
+ public function testDisplayTemplateThatDoesNotExist()
+ {
+ $this->setExpectedException('\RuntimeException');
+
+ $view = new \Slim\View();
+
+ $prop2 = new \ReflectionProperty($view, 'templatesDirectory');
+ $prop2->setAccessible(true);
+ $prop2->setValue($view, dirname(__FILE__) . '/templates');
+
+ $view->display('foo.php');
+ }
+}
diff --git a/strillonews/vendor/slim/slim/tests/bootstrap.php b/strillonews/vendor/slim/slim/tests/bootstrap.php
new file mode 100644
index 0000000..0705e54
--- /dev/null
+++ b/strillonews/vendor/slim/slim/tests/bootstrap.php
@@ -0,0 +1,19 @@
+