1
0
mirror of https://github.com/cydrobolt/polr.git synced 2024-10-07 15:47:10 +02:00

Attempt to fix tests css-selector

This commit is contained in:
Chaoyi Zha 2016-02-13 22:53:46 -05:00
parent 95d26c0834
commit 72f14b944d
668 changed files with 11396 additions and 12204 deletions

View File

@ -1,6 +1,5 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
@ -10,3 +9,5 @@ before_script:
- mv tests/test_env .env
- mysql -e 'CREATE DATABASE polrci;'
- composer install
notifications:
email: false

View File

@ -10,8 +10,9 @@
"vlucas/phpdotenv": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"fzaninotto/faker": "~1.0"
"fzaninotto/faker": "~1.0",
"phpunit/phpunit": "^5.2",
"symfony/css-selector": "^3.0"
},
"autoload": {
"psr-4": {

777
composer.lock generated

File diff suppressed because it is too large Load Diff

18
tests/AuthTest.php Normal file
View File

@ -0,0 +1,18 @@
<?php
class AuthTest extends TestCase
{
/**
* Test Authentication (sign up and sign in)
*
* @return void
*/
public function testLogin() {
// $this->visit('/')
// ->type('polrci', 'username')
// ->type('polrci', 'password ')
// ->press('Sign In')
// ->dontSee('name="login" value="Sign In" />')
// ->see('>Dashboard</a>');
}
}

View File

@ -1,15 +0,0 @@
<?php
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicExample()
{
$this->visit('/')
->see('Lumen.');
}
}

17
tests/IndexTest.php Normal file
View File

@ -0,0 +1,17 @@
<?php
class IndexTest extends TestCase
{
/**
* Test Index
*
* @return void
*/
public function testIndex() {
$this->visit('/')
->see('<h1 class=\'title\'>'. env('APP_NAME') .'</h1>') // Ensure page loads correctly
->see('<meta name="csrf-token"') // Ensure CSRF protection is enabled
->see('>Sign In</a>') // Ensure log in buttons are shown when user is logged out
->dontSee('SQLSTATE'); // Ensure database connection is correct
}
}

View File

@ -7,7 +7,7 @@ APP_DEBUG=false
APP_KEY=a5bd6a61b1327670bedd712a358d9c2b
# Your app's name (shown on interface)
APP_NAME=Polr
APP_NAME=Polr CI
# Protocol to access your app. e.g https://
APP_PROTOCOL=http://

View File

@ -13,9 +13,7 @@
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0 class loader
*
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
@ -39,6 +37,8 @@ namespace Composer\Autoload;
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
@ -147,7 +147,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-0 base directories
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException

View File

@ -6,11 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'AddVotesToUsersTable' => $baseDir . '/database/migrations/2015_11_04_015656_add_votes_to_users_table.php',
'AuthTest' => $baseDir . '/tests/AuthTest.php',
'CreateLinkTable' => $baseDir . '/database/migrations/2015_11_04_015813_create_link_table.php',
'CreateUsersTable' => $baseDir . '/database/migrations/2015_11_04_015823_create_users_table.php',
'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php',
'ExampleTest' => $baseDir . '/tests/ExampleTest.php',
'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php',
'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php',
'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php',
@ -20,6 +19,7 @@ return array(
'Illuminate\\Foundation\\Testing\\DatabaseMigrations' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseMigrations.php',
'Illuminate\\Foundation\\Testing\\DatabaseTransactions' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/DatabaseTransactions.php',
'Illuminate\\Foundation\\Testing\\WithoutMiddleware' => $vendorDir . '/laravel/lumen-framework/src/Foundation/Testing/WithoutMiddleware.php',
'IndexTest' => $baseDir . '/tests/IndexTest.php',
'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php',
'PHPUnit_Extensions_GroupTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php',
'PHPUnit_Extensions_PhptTestCase' => $vendorDir . '/phpunit/phpunit/src/Extensions/PhptTestCase.php',
@ -51,9 +51,12 @@ return array(
'PHPUnit_Framework_Constraint_IsEmpty' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEmpty.php',
'PHPUnit_Framework_Constraint_IsEqual' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsEqual.php',
'PHPUnit_Framework_Constraint_IsFalse' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFalse.php',
'PHPUnit_Framework_Constraint_IsFinite' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsFinite.php',
'PHPUnit_Framework_Constraint_IsIdentical' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsIdentical.php',
'PHPUnit_Framework_Constraint_IsInfinite' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInfinite.php',
'PHPUnit_Framework_Constraint_IsInstanceOf' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsInstanceOf.php',
'PHPUnit_Framework_Constraint_IsJson' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsJson.php',
'PHPUnit_Framework_Constraint_IsNan' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNan.php',
'PHPUnit_Framework_Constraint_IsNull' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsNull.php',
'PHPUnit_Framework_Constraint_IsTrue' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsTrue.php',
'PHPUnit_Framework_Constraint_IsType' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/IsType.php',
@ -72,6 +75,7 @@ return array(
'PHPUnit_Framework_Constraint_TraversableContains' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContains.php',
'PHPUnit_Framework_Constraint_TraversableContainsOnly' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/TraversableContainsOnly.php',
'PHPUnit_Framework_Constraint_Xor' => $vendorDir . '/phpunit/phpunit/src/Framework/Constraint/Xor.php',
'PHPUnit_Framework_CoveredCodeNotExecutedException' => $vendorDir . '/phpunit/phpunit/src/Framework/PHPUnit_Framework_CoveredCodeNotExecutedException.php',
'PHPUnit_Framework_Error' => $vendorDir . '/phpunit/phpunit/src/Framework/Error.php',
'PHPUnit_Framework_Error_Deprecated' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Deprecated.php',
'PHPUnit_Framework_Error_Notice' => $vendorDir . '/phpunit/phpunit/src/Framework/Error/Notice.php',
@ -144,6 +148,7 @@ return array(
'PHPUnit_Framework_TestSuite_DataProvider' => $vendorDir . '/phpunit/phpunit/src/Framework/TestSuite/DataProvider.php',
'PHPUnit_Framework_UnintentionallyCoveredCodeError' => $vendorDir . '/phpunit/phpunit/src/Framework/UnintentionallyCoveredCodeError.php',
'PHPUnit_Framework_Warning' => $vendorDir . '/phpunit/phpunit/src/Framework/Warning.php',
'PHPUnit_Framework_WarningTestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/WarningTestCase.php',
'PHPUnit_Runner_BaseTestRunner' => $vendorDir . '/phpunit/phpunit/src/Runner/BaseTestRunner.php',
'PHPUnit_Runner_Exception' => $vendorDir . '/phpunit/phpunit/src/Runner/Exception.php',
'PHPUnit_Runner_Filter_Factory' => $vendorDir . '/phpunit/phpunit/src/Runner/Filter/Factory.php',
@ -169,6 +174,7 @@ return array(
'PHPUnit_Util_Log_JSON' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JSON.php',
'PHPUnit_Util_Log_JUnit' => $vendorDir . '/phpunit/phpunit/src/Util/Log/JUnit.php',
'PHPUnit_Util_Log_TAP' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TAP.php',
'PHPUnit_Util_Log_TeamCity' => $vendorDir . '/phpunit/phpunit/src/Util/Log/TeamCity.php',
'PHPUnit_Util_PHP' => $vendorDir . '/phpunit/phpunit/src/Util/PHP.php',
'PHPUnit_Util_PHP_Default' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Default.php',
'PHPUnit_Util_PHP_Windows' => $vendorDir . '/phpunit/phpunit/src/Util/PHP/Windows.php',
@ -184,13 +190,15 @@ return array(
'PHPUnit_Util_Type' => $vendorDir . '/phpunit/phpunit/src/Util/Type.php',
'PHPUnit_Util_XML' => $vendorDir . '/phpunit/phpunit/src/Util/XML.php',
'PHP_CodeCoverage' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage.php',
'PHP_CodeCoverage_CoveredCodeNotExecutedException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/CoveredCodeNotExecutedException.php',
'PHP_CodeCoverage_Driver' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver.php',
'PHP_CodeCoverage_Driver_HHVM' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/HHVM.php',
'PHP_CodeCoverage_Driver_PHPDBG' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/PHPDBG.php',
'PHP_CodeCoverage_Driver_Xdebug' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Driver/Xdebug.php',
'PHP_CodeCoverage_Exception' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception.php',
'PHP_CodeCoverage_Exception_UnintentionallyCoveredCode' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/UnintentionallyCoveredCode.php',
'PHP_CodeCoverage_Exception' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/Exception.php',
'PHP_CodeCoverage_Filter' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Filter.php',
'PHP_CodeCoverage_InvalidArgumentException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/InvalidArgumentException.php',
'PHP_CodeCoverage_MissingCoversAnnotationException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/MissingCoversAnnotationException.php',
'PHP_CodeCoverage_Report_Clover' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Clover.php',
'PHP_CodeCoverage_Report_Crap4j' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Crap4j.php',
'PHP_CodeCoverage_Report_Factory' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/Factory.php',
@ -216,8 +224,9 @@ return array(
'PHP_CodeCoverage_Report_XML_Project' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Project.php',
'PHP_CodeCoverage_Report_XML_Tests' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Tests.php',
'PHP_CodeCoverage_Report_XML_Totals' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Report/XML/Totals.php',
'PHP_CodeCoverage_RuntimeException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/RuntimeException.php',
'PHP_CodeCoverage_UnintentionallyCoveredCodeException' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Exception/UnintentionallyCoveredCodeException.php',
'PHP_CodeCoverage_Util' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util.php',
'PHP_CodeCoverage_Util_InvalidArgumentHelper' => $vendorDir . '/phpunit/php-code-coverage/src/CodeCoverage/Util/InvalidArgumentHelper.php',
'PHP_Timer' => $vendorDir . '/phpunit/php-timer/src/Timer.php',
'PHP_Token' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_TokenWithScope' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
@ -415,6 +424,7 @@ return array(
'PHP_Token_XOR_EQUAL' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'PHP_Token_YIELD_FROM' => $vendorDir . '/phpunit/php-token-stream/src/Token.php',
'SebastianBergmann\\CodeUnitReverseLookup\\Wizard' => $vendorDir . '/sebastian/code-unit-reverse-lookup/src/Wizard.php',
'SebastianBergmann\\Comparator\\ArrayComparator' => $vendorDir . '/sebastian/comparator/src/ArrayComparator.php',
'SebastianBergmann\\Comparator\\Comparator' => $vendorDir . '/sebastian/comparator/src/Comparator.php',
'SebastianBergmann\\Comparator\\ComparisonFailure' => $vendorDir . '/sebastian/comparator/src/ComparisonFailure.php',
@ -450,6 +460,7 @@ return array(
'SebastianBergmann\\RecursionContext\\Context' => $vendorDir . '/sebastian/recursion-context/src/Context.php',
'SebastianBergmann\\RecursionContext\\Exception' => $vendorDir . '/sebastian/recursion-context/src/Exception.php',
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\ResourceOperations\\ResourceOperations' => $vendorDir . '/sebastian/resource-operations/src/ResourceOperations.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php',
'SessionHandlerInterface' => $vendorDir . '/symfony/http-foundation/Resources/stubs/SessionHandlerInterface.php',
'TestCase' => $baseDir . '/tests/TestCase.php',

View File

@ -6,10 +6,10 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/danielstjules/stringy/src/Create.php',
$vendorDir . '/illuminate/support/helpers.php',
$vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
$vendorDir . '/paragonie/random_compat/lib/random.php',
$vendorDir . '/nikic/fast-route/src/functions.php',
$vendorDir . '/laravel/lumen-framework/src/helpers.php',
'65fec9ebcfbb3cbb4fd0d519687aea01' => $vendorDir . '/danielstjules/stringy/src/Create.php',
'72579e7bd17821bb1321b87411366eae' => $vendorDir . '/illuminate/support/helpers.php',
'667aeda72477189d0494fecd327c3641' => $vendorDir . '/symfony/var-dumper/Resources/functions/dump.php',
'5255c38a0faeba867671b61dfda6d864' => $vendorDir . '/paragonie/random_compat/lib/random.php',
'253c157292f75eb38082b5acb06f3f01' => $vendorDir . '/nikic/fast-route/src/functions.php',
'bee9632da3ca00a99623b9c35d0c4f8b' => $vendorDir . '/laravel/lumen-framework/src/helpers.php',
);

View File

@ -12,5 +12,4 @@ return array(
'Dotenv' => array($vendorDir . '/vlucas/phpdotenv/src'),
'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
'Cron' => array($vendorDir . '/mtdowling/cron-expression/src'),
'Carbon' => array($vendorDir . '/nesbot/carbon/src'),
);

View File

@ -17,6 +17,7 @@ return array(
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'Symfony\\Component\\DomCrawler\\' => array($vendorDir . '/symfony/dom-crawler'),
'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
'Stringy\\' => array($vendorDir . '/danielstjules/stringy/src'),
'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
@ -47,5 +48,7 @@ return array(
'FastRoute\\' => array($vendorDir . '/nikic/fast-route/src'),
'Faker\\' => array($vendorDir . '/fzaninotto/faker/src/Faker'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Carbon\\' => array($vendorDir . '/nesbot/carbon/src/Carbon'),
'App\\' => array($baseDir . '/app'),
);

View File

@ -41,15 +41,19 @@ class ComposerAutoloaderInit1022d009db9f708df68c1991f93b734b
$loader->register(true);
$includeFiles = require __DIR__ . '/autoload_files.php';
foreach ($includeFiles as $file) {
composerRequire1022d009db9f708df68c1991f93b734b($file);
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire1022d009db9f708df68c1991f93b734b($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire1022d009db9f708df68c1991f93b734b($file)
function composerRequire1022d009db9f708df68c1991f93b734b($fileIdentifier, $file)
{
require $file;
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,21 @@
language: php
sudo: false
cache:
directory:
- $HOME/.composer/cache
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
install:
- composer --prefer-source install
- composer install -n
script:
- phpunit

View File

@ -1,4 +1,4 @@
Copyright (c) 2006-2013 Doctrine Project
Copyright (c) 2006-2015 Doctrine Project
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

View File

@ -23,7 +23,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.1.x-dev"
}
}
}

View File

@ -56,11 +56,12 @@ class Inflector
'/(p)erson$/i' => '\1eople',
'/(m)an$/i' => '\1en',
'/(c)hild$/i' => '\1hildren',
'/(buffal|tomat)o$/i' => '\1\2oes',
'/(f)oot$/i' => '\1eet',
'/(buffal|her|potat|tomat|volcan)o$/i' => '\1\2oes',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i' => '\1i',
'/us$/i' => 'uses',
'/(alias)$/i' => '\1es',
'/(ax|cris|test)is$/i' => '\1es',
'/(analys|ax|cris|test|thes)is$/i' => '\1es',
'/s$/' => 's',
'/^$/' => '',
'/$/' => 's',
@ -70,27 +71,42 @@ class Inflector
),
'irregular' => array(
'atlas' => 'atlases',
'axe' => 'axes',
'beef' => 'beefs',
'brother' => 'brothers',
'cafe' => 'cafes',
'chateau' => 'chateaux',
'child' => 'children',
'cookie' => 'cookies',
'corpus' => 'corpuses',
'cow' => 'cows',
'criteria' => 'criterion',
'criterion' => 'criteria',
'curriculum' => 'curricula',
'demo' => 'demos',
'domino' => 'dominoes',
'echo' => 'echoes',
'foot' => 'feet',
'fungus' => 'fungi',
'ganglion' => 'ganglions',
'genie' => 'genies',
'genus' => 'genera',
'graffito' => 'graffiti',
'hippopotamus' => 'hippopotami',
'hoof' => 'hoofs',
'human' => 'humans',
'iris' => 'irises',
'leaf' => 'leaves',
'loaf' => 'loaves',
'man' => 'men',
'medium' => 'media',
'memorandum' => 'memoranda',
'money' => 'monies',
'mongoose' => 'mongooses',
'motto' => 'mottoes',
'move' => 'moves',
'mythos' => 'mythoi',
'niche' => 'niches',
'nucleus' => 'nuclei',
'numen' => 'numina',
'occiput' => 'occiputs',
'octopus' => 'octopuses',
@ -98,11 +114,19 @@ class Inflector
'ox' => 'oxen',
'penis' => 'penises',
'person' => 'people',
'plateau' => 'plateaux',
'runner-up' => 'runners-up',
'sex' => 'sexes',
'soliloquy' => 'soliloquies',
'son-in-law' => 'sons-in-law',
'syllabus' => 'syllabi',
'testis' => 'testes',
'thief' => 'thieves',
'tooth' => 'teeth',
'tornado' => 'tornadoes',
'trilby' => 'trilbys',
'turf' => 'turfs',
'volcano' => 'volcanoes',
)
);
@ -120,9 +144,10 @@ class Inflector
'/(vert|ind)ices$/i' => '\1ex',
'/^(ox)en/i' => '\1',
'/(alias)(es)*$/i' => '\1',
'/(buffal|her|potat|tomat|volcan)oes$/i' => '\1o',
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
'/([ftw]ax)es/i' => '\1',
'/(cris|ax|test)es$/i' => '\1is',
'/(analys|ax|cris|test|thes)es$/i' => '\1is',
'/(shoe|slave)s$/i' => '\1',
'/(o)es$/i' => '\1',
'/ouses$/' => 'ouse',
@ -143,6 +168,7 @@ class Inflector
'/(p)eople$/i' => '\1\2erson',
'/(m)en$/i' => '\1an',
'/(c)hildren$/i' => '\1\2hild',
'/(f)eet$/i' => '\1oot',
'/(n)ews$/i' => '\1\2ews',
'/eaus$/' => 'eau',
'/^(.*us)$/' => '\\1',
@ -159,10 +185,15 @@ class Inflector
'.*ss',
),
'irregular' => array(
'criterion' => 'criteria',
'curves' => 'curve',
'foes' => 'foe',
'waves' => 'wave',
'criteria' => 'criterion',
'curves' => 'curve',
'emphases' => 'emphasis',
'foes' => 'foe',
'hoaxes' => 'hoax',
'media' => 'medium',
'neuroses' => 'neurosis',
'waves' => 'wave',
'oases' => 'oasis',
)
);
@ -236,6 +267,42 @@ class Inflector
return lcfirst(self::classify($word));
}
/**
* Uppercases words with configurable delimeters between words.
*
* Takes a string and capitalizes all of the words, like PHP's built-in
* ucwords function. This extends that behavior, however, by allowing the
* word delimeters to be configured, rather than only separating on
* whitespace.
*
* Here is an example:
* <code>
* <?php
* $string = 'top-o-the-morning to all_of_you!';
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string);
* // Top-O-The-Morning To All_of_you!
*
* echo \Doctrine\Common\Inflector\Inflector::ucwords($string, '-_ ');
* // Top-O-The-Morning To All_Of_You!
* ?>
* </code>
*
* @param string $string The string to operate on.
* @param string $delimiters A list of word separators.
*
* @return string The string with all delimeter-separated words capitalized.
*/
public static function ucwords($string, $delimiters = " \n\t\r\0\x0B-")
{
return preg_replace_callback(
'/[^' . preg_quote($delimiters, '/') . ']+/',
function($matches) {
return ucfirst($matches[0]);
},
$string
);
}
/**
* Clears Inflectors inflected value caches, and resets the inflection
* rules to the initial values.

View File

@ -16,52 +16,131 @@ class InflectorTest extends DoctrineTestCase
{
Inflector::reset();
// in the format array('singular', 'plural')
// In the format array('singular', 'plural')
return array(
array('categoria', 'categorias'),
array('house', 'houses'),
array('powerhouse', 'powerhouses'),
array('Bus', 'Buses'),
array('bus', 'buses'),
array('menu', 'menus'),
array('news', 'news'),
array('food_menu', 'food_menus'),
array('Menu', 'Menus'),
array('FoodMenu', 'FoodMenus'),
array('quiz', 'quizzes'),
array('matrix_row', 'matrix_rows'),
array('matrix', 'matrices'),
array('vertex', 'vertices'),
array('index', 'indices'),
array('Alias', 'Aliases'),
array('Media', 'Media'),
array('NodeMedia', 'NodeMedia'),
array('alumnus', 'alumni'),
array('bacillus', 'bacilli'),
array('cactus', 'cacti'),
array('focus', 'foci'),
array('fungus', 'fungi'),
array('nucleus', 'nuclei'),
array('octopus', 'octopuses'),
array('radius', 'radii'),
array('stimulus', 'stimuli'),
array('syllabus', 'syllabi'),
array('terminus', 'termini'),
array('virus', 'viri'),
array('person', 'people'),
array('glove', 'gloves'),
array('crisis', 'crises'),
array('tax', 'taxes'),
array('wave', 'waves'),
array('bureau', 'bureaus'),
array('cafe', 'cafes'),
array('roof', 'roofs'),
array('foe', 'foes'),
array('cookie', 'cookies'),
array('identity', 'identities'),
array('criteria', 'criterion'),
array('curve', 'curves'),
array('', ''),
array('Alias', 'Aliases'),
array('alumnus', 'alumni'),
array('analysis', 'analyses'),
array('aquarium', 'aquaria'),
array('arch', 'arches'),
array('atlas', 'atlases'),
array('axe', 'axes'),
array('baby', 'babies'),
array('bacillus', 'bacilli'),
array('bacterium', 'bacteria'),
array('bureau', 'bureaus'),
array('bus', 'buses'),
array('Bus', 'Buses'),
array('cactus', 'cacti'),
array('cafe', 'cafes'),
array('calf', 'calves'),
array('categoria', 'categorias'),
array('chateau', 'chateaux'),
array('cherry', 'cherries'),
array('child', 'children'),
array('church', 'churches'),
array('circus', 'circuses'),
array('city', 'cities'),
array('cod', 'cod'),
array('cookie', 'cookies'),
array('copy', 'copies'),
array('crisis', 'crises'),
array('criterion', 'criteria'),
array('curriculum', 'curricula'),
array('curve', 'curves'),
array('deer', 'deer'),
array('demo', 'demos'),
array('dictionary', 'dictionaries'),
array('domino', 'dominoes'),
array('dwarf', 'dwarves'),
array('echo', 'echoes'),
array('elf', 'elves'),
array('emphasis', 'emphases'),
array('family', 'families'),
array('fax', 'faxes'),
array('fish', 'fish'),
array('flush', 'flushes'),
array('fly', 'flies'),
array('focus', 'foci'),
array('foe', 'foes'),
array('food_menu', 'food_menus'),
array('FoodMenu', 'FoodMenus'),
array('foot', 'feet'),
array('fungus', 'fungi'),
array('glove', 'gloves'),
array('half', 'halves'),
array('hero', 'heroes'),
array('hippopotamus', 'hippopotami'),
array('hoax', 'hoaxes'),
array('house', 'houses'),
array('human', 'humans'),
array('identity', 'identities'),
array('index', 'indices'),
array('iris', 'irises'),
array('kiss', 'kisses'),
array('knife', 'knives'),
array('leaf', 'leaves'),
array('life', 'lives'),
array('loaf', 'loaves'),
array('man', 'men'),
array('matrix', 'matrices'),
array('matrix_row', 'matrix_rows'),
array('medium', 'media'),
array('memorandum', 'memoranda'),
array('menu', 'menus'),
array('Menu', 'Menus'),
array('mess', 'messes'),
array('moose', 'moose'),
array('motto', 'mottoes'),
array('mouse', 'mice'),
array('neurosis', 'neuroses'),
array('news', 'news'),
array('NodeMedia', 'NodeMedia'),
array('nucleus', 'nuclei'),
array('oasis', 'oases'),
array('octopus', 'octopuses'),
array('pass', 'passes'),
array('person', 'people'),
array('plateau', 'plateaux'),
array('potato', 'potatoes'),
array('powerhouse', 'powerhouses'),
array('quiz', 'quizzes'),
array('radius', 'radii'),
array('reflex', 'reflexes'),
array('roof', 'roofs'),
array('runner-up', 'runners-up'),
array('scarf', 'scarves'),
array('scratch', 'scratches'),
array('series', 'series'),
array('sheep', 'sheep'),
array('shelf', 'shelves'),
array('shoe', 'shoes'),
array('son-in-law', 'sons-in-law'),
array('species', 'species'),
array('splash', 'splashes'),
array('spy', 'spies'),
array('stimulus', 'stimuli'),
array('stitch', 'stitches'),
array('story', 'stories'),
array('syllabus', 'syllabi'),
array('tax', 'taxes'),
array('terminus', 'termini'),
array('thesis', 'theses'),
array('thief', 'thieves'),
array('tomato', 'tomatoes'),
array('tooth', 'teeth'),
array('tornado', 'tornadoes'),
array('try', 'tries'),
array('vertex', 'vertices'),
array('virus', 'viri'),
array('volcano', 'volcanoes'),
array('wash', 'washes'),
array('watch', 'watches'),
array('wave', 'waves'),
array('wharf', 'wharves'),
array('wife', 'wives'),
array('woman', 'women'),
);
}
@ -206,5 +285,25 @@ class InflectorTest extends DoctrineTestCase
$this->assertEquals(Inflector::singularize('Alcoois'), 'Alcool');
$this->assertEquals(Inflector::singularize('Atlas'), 'Atlas');
}
/**
* Test basic ucwords functionality.
*
* @return void
*/
public function testUcwords()
{
$this->assertSame('Top-O-The-Morning To All_of_you!', Inflector::ucwords( 'top-o-the-morning to all_of_you!'));
}
/**
* Test ucwords functionality with custom delimeters.
*
* @return void
*/
public function testUcwordsWithCustomDelimeters()
{
$this->assertSame('Top-O-The-Morning To All_Of_You!', Inflector::ucwords( 'top-o-the-morning to all_of_you!', '-_ '));
}
}

View File

@ -321,7 +321,9 @@ class Gate implements GateContract
} elseif (isset($this->abilities[$ability])) {
return $this->abilities[$ability];
} else {
return function () { return false; };
return function () {
return false;
};
}
}
@ -429,8 +431,12 @@ class Gate implements GateContract
*/
public function forUser($user)
{
$callback = function () use ($user) {
return $user;
};
return new static(
$this->container, function () use ($user) { return $user; }, $this->abilities,
$this->container, $callback, $this->abilities,
$this->policies, $this->beforeCallbacks, $this->afterCallbacks
);
}

View File

@ -5,6 +5,7 @@ namespace Illuminate\Auth;
use Illuminate\Auth\Access\Gate;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
class AuthServiceProvider extends ServiceProvider
{
@ -52,7 +53,7 @@ class AuthServiceProvider extends ServiceProvider
*/
protected function registerUserResolver()
{
$this->app->bind('Illuminate\Contracts\Auth\Authenticatable', function ($app) {
$this->app->bind(AuthenticatableContract::class, function ($app) {
return $app['auth']->user();
});
}
@ -65,7 +66,9 @@ class AuthServiceProvider extends ServiceProvider
protected function registerAccessGate()
{
$this->app->singleton(GateContract::class, function ($app) {
return new Gate($app, function () use ($app) { return $app['auth']->user(); });
return new Gate($app, function () use ($app) {
return $app['auth']->user();
});
});
}

View File

@ -571,9 +571,11 @@ class Guard implements GuardContract
{
$this->session->remove($this->getName());
$recaller = $this->getRecallerName();
if (! is_null($this->getRecaller())) {
$recaller = $this->getRecallerName();
$this->getCookieJar()->queue($this->getCookieJar()->forget($recaller));
$this->getCookieJar()->queue($this->getCookieJar()->forget($recaller));
}
}
/**

View File

@ -3,6 +3,7 @@
namespace Illuminate\Auth\Passwords;
use Closure;
use Illuminate\Support\Arr;
use UnexpectedValueException;
use Illuminate\Contracts\Auth\UserProvider;
use Illuminate\Contracts\Mail\Mailer as MailerContract;
@ -229,7 +230,7 @@ class PasswordBroker implements PasswordBrokerContract
*/
public function getUser(array $credentials)
{
$credentials = array_except($credentials, ['token']);
$credentials = Arr::except($credentials, ['token']);
$user = $this->users->retrieveByCredentials($credentials);

View File

@ -85,6 +85,8 @@ class BroadcastManager implements FactoryContract
*
* @param string $name
* @return \Illuminate\Contracts\Broadcasting\Broadcaster
*
* @throws \InvalidArgumentException
*/
protected function resolve($name)
{
@ -97,7 +99,13 @@ class BroadcastManager implements FactoryContract
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
} else {
return $this->{'create'.ucfirst($config['driver']).'Driver'}($config);
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Driver [{$config['driver']}] not supported.");
}
}
}
@ -121,7 +129,7 @@ class BroadcastManager implements FactoryContract
protected function createPusherDriver(array $config)
{
return new PusherBroadcaster(
new Pusher($config['key'], $config['secret'], $config['app_id'], array_get($config, 'options', []))
new Pusher($config['key'], $config['secret'], $config['app_id'], Arr::get($config, 'options', []))
);
}

View File

@ -32,4 +32,14 @@ class PusherBroadcaster implements Broadcaster
{
$this->pusher->trigger($channels, $event, $payload);
}
/**
* Get the Pusher SDK instance.
*
* @return \Pusher
*/
public function getPusher()
{
return $this->pusher;
}
}

View File

@ -137,7 +137,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
}
/**
* Get a parameter value for a marshaled command.
* Get a parameter value for a marshalled command.
*
* @param string $command
* @param \ArrayAccess $source
@ -145,8 +145,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
* @param array $extras
* @return mixed
*/
protected function getParameterValueForCommand($command, ArrayAccess $source,
ReflectionParameter $parameter, array $extras = [])
protected function getParameterValueForCommand($command, ArrayAccess $source, ReflectionParameter $parameter, array $extras = [])
{
if (array_key_exists($parameter->name, $extras)) {
return $extras[$parameter->name];
@ -254,7 +253,7 @@ class Dispatcher implements DispatcherContract, QueueingDispatcher, HandlerResol
*/
protected function pushCommandToQueue($queue, $command)
{
if (isset($command->queue) && isset($command->delay)) {
if (isset($command->queue, $command->delay)) {
return $queue->laterOn($command->queue, $command->delay, $command);
}

View File

@ -82,6 +82,8 @@ class CacheManager implements FactoryContract
*
* @param string $name
* @return \Illuminate\Contracts\Cache\Repository
*
* @throws \InvalidArgumentException
*/
protected function resolve($name)
{
@ -94,7 +96,13 @@ class CacheManager implements FactoryContract
if (isset($this->customCreators[$config['driver']])) {
return $this->callCustomCreator($config);
} else {
return $this->{'create'.ucfirst($config['driver']).'Driver'}($config);
$driverMethod = 'create'.ucfirst($config['driver']).'Driver';
if (method_exists($this, $driverMethod)) {
return $this->{$driverMethod}($config);
} else {
throw new InvalidArgumentException("Driver [{$config['driver']}] not supported.");
}
}
}
@ -200,7 +208,7 @@ class CacheManager implements FactoryContract
{
$redis = $this->app['redis'];
$connection = Arr::get($config, 'connection', 'default') ?: 'default';
$connection = Arr::get($config, 'connection', 'default');
return $this->repository(new RedisStore($redis, $this->getPrefix($config), $connection));
}

View File

@ -116,14 +116,12 @@ class DatabaseStore implements Store
*
* @param string $key
* @param mixed $value
* @return void
* @return int|bool
*/
public function increment($key, $value = 1)
{
$this->connection->transaction(function () use ($key, $value) {
return $this->incrementOrDecrement($key, $value, function ($current) use ($value) {
return $current + $value;
});
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $current + $value;
});
}
@ -132,14 +130,12 @@ class DatabaseStore implements Store
*
* @param string $key
* @param mixed $value
* @return void
* @return int|bool
*/
public function decrement($key, $value = 1)
{
$this->connection->transaction(function () use ($key, $value) {
return $this->incrementOrDecrement($key, $value, function ($current) use ($value) {
return $current - $value;
});
return $this->incrementOrDecrement($key, $value, function ($current, $value) {
return $current - $value;
});
}
@ -149,23 +145,32 @@ class DatabaseStore implements Store
* @param string $key
* @param mixed $value
* @param \Closure $callback
* @return void
* @return int|bool
*/
protected function incrementOrDecrement($key, $value, Closure $callback)
{
$prefixed = $this->prefix.$key;
return $this->connection->transaction(function () use ($key, $value, $callback) {
$prefixed = $this->prefix.$key;
$cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
$cache = $this->table()->where('key', $prefixed)->lockForUpdate()->first();
if (! is_null($cache)) {
$current = $this->encrypter->decrypt($cache->value);
if (is_numeric($current)) {
$this->table()->where('key', $prefixed)->update([
'value' => $this->encrypter->encrypt($callback($current)),
]);
if (is_null($cache)) {
return false;
}
}
$current = $this->encrypter->decrypt($cache->value);
$new = $callback($current, $value);
if (! is_numeric($current)) {
return false;
}
$this->table()->where('key', $prefixed)->update([
'value' => $this->encrypter->encrypt($new),
]);
return $new;
});
}
/**

View File

@ -209,11 +209,13 @@ class FileStore implements Store
*/
protected function expiration($minutes)
{
if ($minutes === 0) {
$time = time() + ($minutes * 60);
if ($minutes === 0 || $time > 9999999999) {
return 9999999999;
}
return time() + ($minutes * 60);
return $time;
}
/**

View File

@ -13,9 +13,9 @@ class RedisTaggedCache extends TaggedCache
*/
public function forever($key, $value)
{
$this->pushForeverKeys($namespace = $this->tags->getNamespace(), $key);
$this->pushForeverKeys($this->tags->getNamespace(), $key);
$this->store->forever(sha1($namespace).':'.$key, $value);
parent::forever($key, $value);
}
/**

View File

@ -6,6 +6,7 @@ use Closure;
use DateTime;
use ArrayAccess;
use Carbon\Carbon;
use BadMethodCallException;
use Illuminate\Contracts\Cache\Store;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Events\Dispatcher;
@ -94,7 +95,7 @@ class Repository implements CacheContract, ArrayAccess
*/
public function get($key, $default = null)
{
$value = $this->store->get($key);
$value = $this->store->get($this->itemKey($key));
if (is_null($value)) {
$this->fireCacheEvent('missed', [$key]);
@ -136,7 +137,7 @@ class Repository implements CacheContract, ArrayAccess
$minutes = $this->getMinutes($minutes);
if (! is_null($minutes)) {
$this->store->put($key, $value, $minutes);
$this->store->put($this->itemKey($key), $value, $minutes);
$this->fireCacheEvent('write', [$key, $value, $minutes]);
}
@ -159,7 +160,7 @@ class Repository implements CacheContract, ArrayAccess
}
if (method_exists($this->store, 'add')) {
return $this->store->add($key, $value, $minutes);
return $this->store->add($this->itemKey($key), $value, $minutes);
}
if (is_null($this->get($key))) {
@ -180,7 +181,7 @@ class Repository implements CacheContract, ArrayAccess
*/
public function forever($key, $value)
{
$this->store->forever($key, $value);
$this->store->forever($this->itemKey($key), $value);
$this->fireCacheEvent('write', [$key, $value, 0]);
}
@ -248,13 +249,62 @@ class Repository implements CacheContract, ArrayAccess
*/
public function forget($key)
{
$success = $this->store->forget($key);
$success = $this->store->forget($this->itemKey($key));
$this->fireCacheEvent('delete', [$key]);
return $success;
}
/**
* Begin executing a new tags operation if the store supports it.
*
* @param string $name
* @return \Illuminate\Cache\TaggedCache
*
* @deprecated since version 5.1. Use tags instead.
*/
public function section($name)
{
return $this->tags($name);
}
/**
* Begin executing a new tags operation if the store supports it.
*
* @param array|mixed $names
* @return \Illuminate\Cache\TaggedCache
*
* @throws \BadMethodCallException
*/
public function tags($names)
{
if (method_exists($this->store, 'tags')) {
$taggedCache = $this->store->tags($names);
if (! is_null($this->events)) {
$taggedCache->setEventDispatcher($this->events);
}
$taggedCache->setDefaultCacheTime($this->default);
return $taggedCache;
}
throw new BadMethodCallException('This cache store does not support tagging.');
}
/**
* Format the key for a cache item.
*
* @param string $key
* @return string
*/
protected function itemKey($key)
{
return $key;
}
/**
* Get the default cache time.
*

View File

@ -97,4 +97,14 @@ class TagSet
{
return 'tag:'.$name.':key';
}
/**
* Get all of the tag names in the set.
*
* @return array
*/
public function getNames()
{
return $this->names;
}
}

View File

@ -2,20 +2,10 @@
namespace Illuminate\Cache;
use Closure;
use DateTime;
use Carbon\Carbon;
use Illuminate\Contracts\Cache\Store;
class TaggedCache implements Store
class TaggedCache extends Repository
{
/**
* The cache store implementation.
*
* @var \Illuminate\Contracts\Cache\Store
*/
protected $store;
/**
* The tag set instance.
*
@ -32,69 +22,19 @@ class TaggedCache implements Store
*/
public function __construct(Store $store, TagSet $tags)
{
parent::__construct($store);
$this->tags = $tags;
$this->store = $store;
}
/**
* Determine if an item exists in the cache.
*
* @param string $key
* @return bool
* {@inheritdoc}
*/
public function has($key)
protected function fireCacheEvent($event, $payload)
{
return ! is_null($this->get($key));
}
$payload[] = $this->tags->getNames();
/**
* Retrieve an item from the cache by key.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key, $default = null)
{
$value = $this->store->get($this->taggedItemKey($key));