diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c13fd299..5434a4df5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,23 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed Requirements - Changed minimum PHP Version to 7.1 +### Changed Dependencies +- Updated Laravel Illuminate packages to 5.8 +- Updated Twig to 2.11 +- Updated PHPUnit to 7.5 +- Updated Mockery to 1.2 +- Updated nikic/php-parser to 4.2.2 +- Updated PHPMailer/PHPMailer to 6.0.7 +- Updated league/csv to 9.2.1 +- Updated symfony/console to 4.3 +- Updated vlucas/phpdotenv to 3.4.0 + ### Added - Separated `BakeCommand` class into multiple methods to make it easier for sprinkle to add custom command to the `bake` command. ### Fix - `bake` command return error if account sprinkle is not included ([#944]) +- Email is case-sensitive ([#881]; [#1012]) ### Changed - Account sprinkle now extend the Core `BakeCommand` class to add the `create-admin` to the general bake command. Any sprinkle already extending the Core `BakeCommand` might need adjustments. @@ -26,12 +38,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [v4.2.3] ### Added -- Config to set Domain of RememberMe Cookie ([#990]; [#991]; Thanks @xrobau!) +- Config to set Domain of RememberMe Cookie ([#990], [#991]; Thanks @xrobau !) - Config settings for password min/max length ([#993]) ### Fixed -- [PHPMailer] Turn off opportunistic TLS when disabled ([#986]; [#987]) -- Migrator now ignore files that don't end in `.php` ([#965]; Temporary fix for [#998]) +- [PHPMailer] Turn off opportunistic TLS when disabled ([#986], [#987]) +- Migrator now ignore files that don't end in `.php` ([#965], [#998]) +- Respects CSRF_ENABLED environment variable ([#976]; Thanks @Poldovico !) ## [v4.2.2] @@ -773,6 +786,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x [#854]: https://github.com/userfrosting/UserFrosting/issues/854 [#869]: https://github.com/userfrosting/UserFrosting/issues/869 [#872]: https://github.com/userfrosting/UserFrosting/issues/872 +[#881]: https://github.com/userfrosting/UserFrosting/issues/881 [#888]: https://github.com/userfrosting/UserFrosting/issues/888 [#893]: https://github.com/userfrosting/UserFrosting/issues/893 [#919]: https://github.com/userfrosting/UserFrosting/issues/919 @@ -785,6 +799,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x [#963]: https://github.com/userfrosting/UserFrosting/issues/963 [#965]: https://github.com/userfrosting/UserFrosting/issues/965 [#968]: https://github.com/userfrosting/UserFrosting/issues/968 +[#976]: https://github.com/userfrosting/UserFrosting/issues/976 [#981]: https://github.com/userfrosting/UserFrosting/issues/981 [#983]: https://github.com/userfrosting/UserFrosting/issues/983 [#986]: https://github.com/userfrosting/UserFrosting/issues/986 @@ -793,6 +808,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x [#991]: https://github.com/userfrosting/UserFrosting/issues/991 [#993]: https://github.com/userfrosting/UserFrosting/issues/993 [#998]: https://github.com/userfrosting/UserFrosting/issues/998 +[#1012]: https://github.com/userfrosting/UserFrosting/issues/1012 [v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0 [v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v.4.2.1 diff --git a/app/sprinkles/account/composer.json b/app/sprinkles/account/composer.json index 7a6163e8a..87992e0a2 100644 --- a/app/sprinkles/account/composer.json +++ b/app/sprinkles/account/composer.json @@ -13,7 +13,7 @@ ], "require": { "birke/rememberme" : "^2.0", - "nikic/php-parser" : "^1" + "nikic/php-parser" : "^4.2.2" }, "autoload": { "psr-4": { diff --git a/app/sprinkles/account/src/Authorize/AccessConditionExpression.php b/app/sprinkles/account/src/Authorize/AccessConditionExpression.php index b957cc978..9bfbbec77 100644 --- a/app/sprinkles/account/src/Authorize/AccessConditionExpression.php +++ b/app/sprinkles/account/src/Authorize/AccessConditionExpression.php @@ -12,9 +12,8 @@ use Monolog\Logger; use PhpParser\Error as PhpParserException; -use PhpParser\Lexer\Emulative as EmulativeLexer; use PhpParser\NodeTraverser; -use PhpParser\Parser as Parser; +use PhpParser\ParserFactory as Parser; use PhpParser\PrettyPrinter\Standard as StandardPrettyPrinter; use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface; @@ -75,7 +74,7 @@ public function __construct(ParserNodeFunctionEvaluator $nodeVisitor, UserInterf { $this->nodeVisitor = $nodeVisitor; $this->user = $user; - $this->parser = new Parser(new EmulativeLexer()); + $this->parser = (new Parser())->create(Parser::ONLY_PHP7); $this->traverser = new NodeTraverser(); $this->traverser->addVisitor($nodeVisitor); $this->prettyPrinter = new StandardPrettyPrinter(); @@ -119,7 +118,7 @@ public function evaluateCondition($condition, $params) $stmts = $this->traverser->traverse($stmts); // Evaluate boolean statement. It is safe to use eval() here, because our expression has been reduced entirely to a boolean expression. - $expr = $this->prettyPrinter->prettyPrintExpr($stmts[0]); + $expr = $this->prettyPrinter->prettyPrintExpr($stmts[0]->expr); $expr_eval = 'return ' . $expr . ";\n"; $result = eval($expr_eval); diff --git a/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php b/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php index 9caf95c35..179a00e23 100644 --- a/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php +++ b/app/sprinkles/account/src/Authorize/ParserNodeFunctionEvaluator.php @@ -71,7 +71,7 @@ public function leaveNode(Node $node) { // Look for function calls if ($node instanceof \PhpParser\Node\Expr\FuncCall) { - $eval = new \PhpParser\Node\Scalar\LNumber(); + $eval = new \PhpParser\Node\Scalar\LNumber(0); // Get the method name $callbackName = $node->name->toString(); diff --git a/app/sprinkles/core/composer.json b/app/sprinkles/core/composer.json index a44275781..836f0b2db 100644 --- a/app/sprinkles/core/composer.json +++ b/app/sprinkles/core/composer.json @@ -32,28 +32,27 @@ "illuminate/database": "5.8.*", "illuminate/events": "5.8.*", "illuminate/filesystem": "5.8.*", - "league/csv": "^8.1", + "league/csv": "^9.2.1", "league/flysystem": "~1.0", "league/flysystem-aws-s3-v3": "~1.0", "league/flysystem-cached-adapter": "~1.0", "league/flysystem-rackspace": "~1.0", "league/flysystem-sftp": "~1.0", "monolog/monolog": "^1", - "phpmailer/phpmailer": "5.2.10", - "rockettheme/toolbox": "1.3.1", + "phpmailer/phpmailer": "^6.0.7", "slim/csrf": "^0.8", "slim/slim": "^3", - "slim/twig-view": "^1.2", + "slim/twig-view": "^2.5", "symfony/http-foundation": "*", - "twig/twig": "^1.18", - "userfrosting/assets": "^5.0.4", - "userfrosting/config": "~4.2.0", - "userfrosting/cache": "~4.2.0", - "userfrosting/fortress": "~4.2.0", - "userfrosting/i18n": "~4.2.0", - "userfrosting/session": "~4.2.2", - "userfrosting/support": "~4.2.0", - "vlucas/phpdotenv": "^2" + "twig/twig": "^2.11", + "userfrosting/assets": "^6.0.0", + "userfrosting/config": "~4.3.0", + "userfrosting/cache": "~4.3.0", + "userfrosting/fortress": "~4.3.0", + "userfrosting/i18n": "~4.3.0", + "userfrosting/session": "~4.3.0", + "userfrosting/support": "~4.3.0", + "vlucas/phpdotenv": "^3.4.0" }, "autoload": { "files" : [ diff --git a/app/sprinkles/core/config/default.php b/app/sprinkles/core/config/default.php index eedcd73ef..ba27a43e6 100755 --- a/app/sprinkles/core/config/default.php +++ b/app/sprinkles/core/config/default.php @@ -97,7 +97,7 @@ * Note : CSRF Middleware should only be disabled for dev or debug purposes. */ 'csrf' => [ - 'enabled' => getenv('CSRF_ENABLED') ?: true, + 'enabled' => (getenv('CSRF_ENABLED') !== false) ? getenv('CSRF_ENABLED') : true, 'name' => 'csrf', 'storage_limit' => 200, 'strength' => 16, diff --git a/app/sprinkles/core/src/Bakery/MigrateCommand.php b/app/sprinkles/core/src/Bakery/MigrateCommand.php index 7d2d0586e..390abf1b9 100644 --- a/app/sprinkles/core/src/Bakery/MigrateCommand.php +++ b/app/sprinkles/core/src/Bakery/MigrateCommand.php @@ -14,6 +14,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use UserFrosting\Sprinkle\Core\Bakery\Helper\ConfirmableTrait; +use UserFrosting\Sprinkle\Core\Database\Migrator\Migrator; use UserFrosting\System\Bakery\BaseCommand; /** @@ -79,13 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output) try { $migrated = $migrator->run(['pretend' => $pretend, 'step' => $step]); } catch (\Exception $e) { - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); $this->io->error($e->getMessage()); exit(1); } // Get notes and display them - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); // If all went well, there's no fatal errors and we have migrated // something, show some success @@ -128,4 +129,16 @@ protected function setupMigrator(InputInterface $input) return $migrator; } + + /** + * Display migrator notes. + * + * @param Migrator $migrator + */ + protected function displayNotes(Migrator $migrator) + { + if (!empty($notes = $migrator->getNotes())) { + $this->io->writeln($notes); + } + } } diff --git a/app/sprinkles/core/src/Bakery/MigrateRefreshCommand.php b/app/sprinkles/core/src/Bakery/MigrateRefreshCommand.php index ecbab8772..2f932eb6d 100644 --- a/app/sprinkles/core/src/Bakery/MigrateRefreshCommand.php +++ b/app/sprinkles/core/src/Bakery/MigrateRefreshCommand.php @@ -71,13 +71,13 @@ protected function execute(InputInterface $input, OutputInterface $output) try { $rolledback = $migrator->rollback(['pretend' => false, 'steps' => $steps]); } catch (\Exception $e) { - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); $this->io->error($e->getMessage()); exit(1); } // Get notes and display them - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); // Stop if nothing was rolledback if (empty($rolledback)) { @@ -88,7 +88,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // Run back up again $migrated = $migrator->run(['pretend' => false, 'step' => false]); - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); // If all went well, there's no fatal errors and we have migrated // something, show some success diff --git a/app/sprinkles/core/src/Bakery/MigrateResetCommand.php b/app/sprinkles/core/src/Bakery/MigrateResetCommand.php index 034bd2f16..5a52b5dfa 100644 --- a/app/sprinkles/core/src/Bakery/MigrateResetCommand.php +++ b/app/sprinkles/core/src/Bakery/MigrateResetCommand.php @@ -87,13 +87,13 @@ protected function performReset(InputInterface $input) try { $resetted = $migrator->reset($pretend); } catch (\Exception $e) { - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); $this->io->error($e->getMessage()); exit(1); } // Get notes and display them - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); // Delete the repository if (!$pretend && $migrator->repositoryExists()) { diff --git a/app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php b/app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php index 0ffb2d0e7..4c1c64e77 100644 --- a/app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php +++ b/app/sprinkles/core/src/Bakery/MigrateRollbackCommand.php @@ -80,13 +80,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $migrated = $migrator->rollback(['pretend' => $pretend, 'steps' => $steps]); } } catch (\Exception $e) { - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); $this->io->error($e->getMessage()); exit(1); } // Get notes and display them - $this->io->writeln($migrator->getNotes()); + $this->displayNotes($migrator); // If all went well, there's no fatal errors and we have migrated // something, show some success diff --git a/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php b/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php index 3ee918af1..7059be976 100644 --- a/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php +++ b/app/sprinkles/core/src/Database/Migrator/MigrationLocator.php @@ -56,7 +56,7 @@ public function getMigrations() foreach ($migrationFiles as $migrationFile) { // Note that PSR4 insists that all php files must end in PHP, so ignore all // files that don't end in PHP. - if (preg_match('/php$/', $migrationFile)) { + if ($migrationFile->getExtension() == 'php') { $migrations[] = $this->getMigrationDetails($migrationFile); } } diff --git a/app/sprinkles/core/src/Database/Models/Model.php b/app/sprinkles/core/src/Database/Models/Model.php index 33b7cbbb3..4ad00e5d3 100644 --- a/app/sprinkles/core/src/Database/Models/Model.php +++ b/app/sprinkles/core/src/Database/Models/Model.php @@ -68,7 +68,7 @@ public function attributeExists($key) */ public static function findUnique($value, $identifier, $checkDeleted = true) { - $query = static::where($identifier, $value); + $query = static::whereRaw("LOWER($identifier) = ?", [mb_strtolower($value)]); if ($checkDeleted) { $query = $query->withTrashed(); diff --git a/app/sprinkles/core/src/Mail/Mailer.php b/app/sprinkles/core/src/Mail/Mailer.php index 1bd0702b3..c523811f2 100644 --- a/app/sprinkles/core/src/Mail/Mailer.php +++ b/app/sprinkles/core/src/Mail/Mailer.php @@ -11,6 +11,8 @@ namespace UserFrosting\Sprinkle\Core\Mail; use Monolog\Logger; +use PHPMailer\PHPMailer\Exception as phpmailerException; +use PHPMailer\PHPMailer\PHPMailer; /** * Mailer Class. @@ -37,14 +39,14 @@ class Mailer * @param Logger $logger A Monolog logger, used to dump debugging info for SMTP server transactions. * @param mixed[] $config An array of configuration parameters for phpMailer. * - * @throws \phpmailerException Wrong mailer config value given. + * @throws phpmailerException Wrong mailer config value given. */ public function __construct($logger, $config = []) { $this->logger = $logger; // 'true' tells PHPMailer to use exceptions instead of error codes - $this->phpMailer = new \PHPMailer(true); + $this->phpMailer = new PHPMailer(true); // Configuration options switch ($config['mailer']) { @@ -79,7 +81,7 @@ public function __construct($logger, $config = []) } break; default: - throw new \phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'."); + throw new phpmailerException("'mailer' must be one of 'smtp', 'mail', 'qmail', or 'sendmail'."); } // Set any additional message-specific options @@ -97,7 +99,7 @@ public function __construct($logger, $config = []) /** * Get the underlying PHPMailer object. * - * @return \PHPMailer + * @return PHPMailer */ public function getPhpMailer() { @@ -113,7 +115,7 @@ public function getPhpMailer() * @param MailMessage $message * @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times. * - * @throws \phpmailerException The message could not be sent. + * @throws phpmailerException The message could not be sent. */ public function send(MailMessage $message, $clearRecipients = true) { @@ -163,7 +165,7 @@ public function send(MailMessage $message, $clearRecipients = true) * @param MailMessage $message * @param bool $clearRecipients Set to true to clear the list of recipients in the message after calling send(). This helps avoid accidentally sending a message multiple times. * - * @throws \phpmailerException The message could not be sent. + * @throws phpmailerException The message could not be sent. */ public function sendDistinct(MailMessage $message, $clearRecipients = true) { diff --git a/app/sprinkles/core/src/ServicesProvider/ServicesProvider.php b/app/sprinkles/core/src/ServicesProvider/ServicesProvider.php index 3abba9aa2..f9acb5f82 100755 --- a/app/sprinkles/core/src/ServicesProvider/ServicesProvider.php +++ b/app/sprinkles/core/src/ServicesProvider/ServicesProvider.php @@ -234,7 +234,7 @@ public function register(ContainerInterface $container) $container['config'] = function ($c) { // Grab any relevant dotenv variables from the .env file try { - $dotenv = new Dotenv(\UserFrosting\APP_DIR); + $dotenv = Dotenv::create(\UserFrosting\APP_DIR); $dotenv->load(); } catch (InvalidPathException $e) { // Skip loading the environment config file if it doesn't exist. diff --git a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateCommandTest.php b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateCommandTest.php index 8e8653b17..6c40636bf 100644 --- a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateCommandTest.php +++ b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateCommandTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use UserFrosting\Sprinkle\Core\Bakery\MigrateCommand; @@ -21,6 +22,8 @@ */ class BakeryMigrateCommandTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRefreshCommandTest.php b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRefreshCommandTest.php index f8b3208f3..d85d3e6cf 100644 --- a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRefreshCommandTest.php +++ b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRefreshCommandTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use UserFrosting\Sprinkle\Core\Bakery\MigrateRefreshCommand; @@ -21,6 +22,8 @@ */ class BakeryMigrateRefreshCommandTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateResetCommandTest.php b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateResetCommandTest.php index 242b65290..289470a8f 100644 --- a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateResetCommandTest.php +++ b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateResetCommandTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use UserFrosting\Sprinkle\Core\Bakery\MigrateResetCommand; @@ -21,6 +22,8 @@ */ class BakeryMigrateResetCommandTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRollbackCommandTest.php b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRollbackCommandTest.php index 6484d88d9..6be711fc7 100644 --- a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRollbackCommandTest.php +++ b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateRollbackCommandTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use UserFrosting\Sprinkle\Core\Bakery\MigrateRollbackCommand; @@ -21,6 +22,8 @@ */ class BakeryMigrateRollbackCommandTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateStatusCommandTest.php b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateStatusCommandTest.php index de1018c89..a9f86b996 100644 --- a/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateStatusCommandTest.php +++ b/app/sprinkles/core/tests/Integration/Bakery/BakeryMigrateStatusCommandTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Bakery; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; use UserFrosting\Sprinkle\Core\Bakery\MigrateStatusCommand; @@ -21,6 +22,8 @@ */ class BakeryMigrateStatusCommandTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php index a5c0fbdcb..dbb94f16c 100644 --- a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php +++ b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationLocatorTest.php @@ -90,7 +90,13 @@ public function testGetMigrations() new Resource($resourceStream, $resourceAccountLocation, 'one/CreatePasswordResetsTable.php'), new Resource($resourceStream, $resourceAccountLocation, 'two/CreateFlightsTable.php'), new Resource($resourceStream, $resourceAccountLocation, 'CreateMainTable.php'), - new Resource($resourceStream, $resourceAccountLocation, 'README.md'), // This shoudn't be returned by the migrator + + // Theses shoudn't be returned by the migrator + new Resource($resourceStream, $resourceAccountLocation, 'README.md'), + new Resource($resourceStream, $resourceAccountLocation, 'php.md'), + new Resource($resourceStream, $resourceAccountLocation, 'foo.foophp'), + new Resource($resourceStream, $resourceAccountLocation, 'blah.phpphp'), + new Resource($resourceStream, $resourceAccountLocation, 'bar.phpbar'), ]); // Create a new MigrationLocator instance with our simulated ResourceLocation diff --git a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationRepositoryTest.php b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationRepositoryTest.php index b1659417b..72db91363 100644 --- a/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationRepositoryTest.php +++ b/app/sprinkles/core/tests/Integration/Database/Migrator/MigrationRepositoryTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Integration\Database\Migrator; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Illuminate\Support\Collection; use UserFrosting\Sprinkle\Core\Database\Migrator\DatabaseMigrationRepository; use UserFrosting\Tests\TestCase; @@ -20,6 +21,8 @@ */ class MigrationRepositoryTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Integration/Seeder/SeederTests.php b/app/sprinkles/core/tests/Integration/Seeder/SeederTests.php index 9031032f8..799953d8f 100644 --- a/app/sprinkles/core/tests/Integration/Seeder/SeederTests.php +++ b/app/sprinkles/core/tests/Integration/Seeder/SeederTests.php @@ -11,6 +11,7 @@ namespace UserFrosting\Tests\Integration\Seeder; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use Interop\Container\ContainerInterface; use UserFrosting\UniformResourceLocator\ResourceLocator; use UserFrosting\Sprinkle\Core\Database\Seeder\Seeder; @@ -18,8 +19,10 @@ use UserFrosting\Tests\TestCase; use Slim\Container; -class DatabaseTests extends TestCase +class SeederTests extends TestCase { + use MockeryPHPUnitIntegration; + /** * @var Container $fakeCi */ diff --git a/app/sprinkles/core/tests/Unit/Database/Relations/BelongsToManyThroughTest.php b/app/sprinkles/core/tests/Unit/Database/Relations/BelongsToManyThroughTest.php index a343fd435..548479deb 100644 --- a/app/sprinkles/core/tests/Unit/Database/Relations/BelongsToManyThroughTest.php +++ b/app/sprinkles/core/tests/Unit/Database/Relations/BelongsToManyThroughTest.php @@ -13,6 +13,7 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use PHPUnit\Framework\TestCase; use UserFrosting\Sprinkle\Core\Database\Builder as QueryBuilder; use UserFrosting\Sprinkle\Core\Database\Models\Model; @@ -23,6 +24,8 @@ */ class BelongsToManyThroughTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/sprinkles/core/tests/Unit/Sprunje/SprunjeTest.php b/app/sprinkles/core/tests/Unit/Sprunje/SprunjeTest.php index c5501ea72..ece876313 100644 --- a/app/sprinkles/core/tests/Unit/Sprunje/SprunjeTest.php +++ b/app/sprinkles/core/tests/Unit/Sprunje/SprunjeTest.php @@ -11,6 +11,7 @@ namespace UserFrosting\Sprinkle\Core\Tests\Unit\Sprunje; use Mockery as m; +use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; use PHPUnit\Framework\TestCase; use UserFrosting\Sprinkle\Core\Database\Builder as Builder; use UserFrosting\Sprinkle\Core\Database\Models\Model; @@ -23,6 +24,8 @@ */ class SprunjeTest extends TestCase { + use MockeryPHPUnitIntegration; + public function tearDown() { parent::tearDown(); diff --git a/app/tests/Unit/SprinkleManagerTest.php b/app/tests/Unit/SprinkleManagerTest.php index 034f6bd1d..370bf8854 100644 --- a/app/tests/Unit/SprinkleManagerTest.php +++ b/app/tests/Unit/SprinkleManagerTest.php @@ -61,42 +61,34 @@ public function testGetSetSprinklesPath(SprinkleManager $sprinkleManager) /** * @depends testConstructor - * @param SprinkleManager $sprinkleManager - * @return SprinkleManager - */ - public function testInitFromSchema(SprinkleManager $sprinkleManager) - { - $sprinkleManager->initFromSchema(__DIR__ . '/data/sprinkles.json'); - - return $sprinkleManager; - } - - /** - * @depends testConstructor - * @expectedException \UserFrosting\Support\Exception\FileNotFoundException */ public function testLoadSprinkleWithNonExistingFile() { $sprinkleManager = new SprinkleManager($this->fakeCi); + $this->expectException(\UserFrosting\Support\Exception\FileNotFoundException::class); $sprinkleManager->initFromSchema('foo.json'); } /** - * @depends testInitFromSchema + * @depends testConstructor * @param SprinkleManager $sprinkleManager + * @return SprinkleManager */ public function testGetSprinkles(SprinkleManager $sprinkleManager) { + $sprinkleManager->initFromSchema(__DIR__ . '/data/sprinkles.json'); $sprinkles = $sprinkleManager->getSprinkles(); $this->assertEquals([ 'foo' => null, 'bar' => null, 'test' => new \UserFrosting\Sprinkle\Test\Test(), ], $sprinkles); + + return $sprinkleManager; } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @param SprinkleManager $sprinkleManager */ public function testGetSprinkleNames(SprinkleManager $sprinkleManager) @@ -106,7 +98,7 @@ public function testGetSprinkleNames(SprinkleManager $sprinkleManager) } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @depends testGetSprinkleNames * @param string $sprinkleName * @param bool $isAvailable @@ -133,7 +125,7 @@ public function testIsAvailable($sprinkleName, $isAvailable, SprinkleManager $sp } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @param string $sprinkleName * @param SprinkleManager $sprinkleManager * @testWith ["foo"] @@ -148,31 +140,32 @@ public function testGetSprinklePath($sprinkleName, SprinkleManager $sprinkleMana } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @depends testGetSprinklePath - * @expectedException \UserFrosting\Support\Exception\FileNotFoundException * @param SprinkleManager $sprinkleManager */ public function testGetSprinklePathWherePathDoesntExist(SprinkleManager $sprinkleManager) { $basePath = 'app/tests/Unit/foo/'; $sprinkleManager->setSprinklesPath($basePath); + + $this->expectException(\UserFrosting\Support\Exception\FileNotFoundException::class); $sprinkleManager->getSprinklePath('foo'); } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @depends testGetSprinklePath - * @expectedException \UserFrosting\Support\Exception\FileNotFoundException * @param SprinkleManager $sprinkleManager */ public function testGetSprinklePathWhereSprinkleDoesntExist(SprinkleManager $sprinkleManager) { + $this->expectException(\UserFrosting\Support\Exception\FileNotFoundException::class); $sprinkleManager->getSprinklePath('blah'); } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @param SprinkleManager $sprinkleManager */ public function testRegisterAllServices(SprinkleManager $sprinkleManager) @@ -185,11 +178,11 @@ public function testRegisterAllServices(SprinkleManager $sprinkleManager) ->getMock(); class_alias('foo', 'UserFrosting\Sprinkle\Test\ServicesProvider\ServicesProvider'); - $sprinkleManager->registerAllServices(); + $this->assertNull($sprinkleManager->registerAllServices()); } /** - * @depends testInitFromSchema + * @depends testGetSprinkles * @depends testGetSprinklePath * @param SprinkleManager $sprinkleManager */ @@ -197,7 +190,8 @@ public function testAddResources(SprinkleManager $sprinkleManager) { $basePath = 'app/tests/Unit/data/'; $sprinkleManager->setSprinklesPath($basePath); - $sprinkleManager->addResources(); + + $this->assertNull($sprinkleManager->addResources()); } /** @@ -215,11 +209,11 @@ public function testLoadSprinkleWithTxtFile() /** * @depends testConstructor - * @expectedException \UserFrosting\Support\Exception\JsonException */ public function testLoadSprinkleWithBadJson() { $sprinkleManager = new SprinkleManager($this->fakeCi); + $this->expectException(\UserFrosting\Support\Exception\JsonException::class); $sprinkleManager->initFromSchema(__DIR__ . '/data/sprinkles-bad.json'); } diff --git a/composer.json b/composer.json index bc403c21e..d6bba3a99 100755 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ "php": ">=7.1", "ext-gd": "*", "composer/installers": "^1.4.0", - "userfrosting/uniformresourcelocator": "~4.2.3", - "symfony/console": "^3.3", + "userfrosting/uniformresourcelocator": "~4.3.0", + "symfony/console": "^4.3", "wikimedia/composer-merge-plugin": "^1.4.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.13", - "phpunit/phpunit": "^5.7", - "mockery/mockery": "1.0.0-alpha1", + "phpunit/phpunit": "^7.5", + "mockery/mockery": "^1.2", "league/factory-muffin": "^3.0", "league/factory-muffin-faker": "^2.0" },