New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Laravel module without a DB #3942

Closed
marcelopm opened this Issue Jan 22, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@marcelopm

What are you trying to achieve?

To use codeception, with Laravel, without a database. My app doesn't need one

What do you get instead?

[InvalidArgumentException]   
Database [] not configured.

or

SQLSTATE[HY000] [2002] Connection refused

Unless I use a work around on .env.testing:

DB_CONNECTION=sqlite
DB_DATABASE=:memory:

Provide console output if related. Use -vvv mode for more details.

For:

DB_CONNECTION=

I get:

                               
  [InvalidArgumentException]   
  Database [] not configured.  
                               

Exception trace:
 () at /var/www/html/test/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:239
 Illuminate\Database\DatabaseManager->getConfig() at /var/www/html/test/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:158
 Illuminate\Database\DatabaseManager->makeConnection() at /var/www/html/test/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:68
 Illuminate\Database\DatabaseManager->connection() at /var/www/html/test/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:317
 Illuminate\Database\DatabaseManager->__call() at phar:///usr/local/bin/codecept/src/Codeception/Module/Laravel5.php:190
 Codeception\Module\Laravel5->_after() at phar:///usr/local/bin/codecept/src/Codeception/Subscriber/Module.php:68
 Codeception\Subscriber\Module->after() at n/a:n/a
 call_user_func() at phar:///usr/local/bin/codecept/vendor/symfony/event-dispatcher/EventDispatcher.php:174
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at phar:///usr/local/bin/codecept/vendor/symfony/event-dispatcher/EventDispatcher.php:43
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at phar:///usr/local/bin/codecept/src/Codeception/PHPUnit/Listener.php:124
 Codeception\PHPUnit\Listener->fire() at phar:///usr/local/bin/codecept/src/Codeception/PHPUnit/Listener.php:110
 Codeception\PHPUnit\Listener->endTest() at phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestResult.php:401
 PHPUnit_Framework_TestResult->endTest() at /var/www/html/test/vendor/codeception/codeception/src/Codeception/Test/Test.php:112
 Codeception\Test\Test->run() at phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestSuite.php:728
 PHPUnit_Framework_TestSuite->run() at phar:///usr/local/bin/codecept/src/Codeception/PHPUnit/Runner.php:98
 Codeception\PHPUnit\Runner->doEnhancedRun() at phar:///usr/local/bin/codecept/src/Codeception/SuiteManager.php:154
 Codeception\SuiteManager->run() at phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:183
 Codeception\Codecept->runSuite() at phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:152
 Codeception\Codecept->run() at phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:360
 Codeception\Command\Run->runSuites() at phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:287
 Codeception\Command\Run->execute() at phar:///usr/local/bin/codecept/vendor/symfony/console/Command/Command.php:262
 Symfony\Component\Console\Command\Command->run() at phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:826
 Symfony\Component\Console\Application->doRunCommand() at phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:189
 Symfony\Component\Console\Application->doRun() at phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:120
 Symfony\Component\Console\Application->run() at phar:///usr/local/bin/codecept/src/Codeception/Application.php:103
 Codeception\Application->run() at phar:///usr/local/bin/codecept/codecept:37
 require_once() at /usr/local/bin/codecept:7

If I don't include the db configuration, it will try to get from .env (I'd imagine). And them I get:

Test  tests/api/XCest.php:responseFormatTest
SQLSTATE[HY000] [2002] Connection refused
phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestSuite.php:728
phar:///usr/local/bin/codecept/src/Codeception/PHPUnit/Runner.php:98
phar:///usr/local/bin/codecept/src/Codeception/SuiteManager.php:154
phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:183
phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:152
phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:360
phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:287
phar:///usr/local/bin/codecept/vendor/symfony/console/Command/Command.php:262
phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:826
phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:189
phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:120
phar:///usr/local/bin/codecept/src/Codeception/Application.php:103
phar:///usr/local/bin/codecept/codecept:37
/usr/local/bin/codecept:7

Provide test source code if related

public function responseFormatTest(ApiTester $I) {
        $I->wantTo('bla');
        $I->sendGET(sprintf('/x/%d', self::ID));
        $I->seeResponseCodeIs(\Codeception\Util\HttpCode::OK); // 200
        $I->seeResponseIsJson();
        $I->seeResponseContainsJson(json_decode(self::JSON));
    }

Details

  • Codeception version: 2.2.8

  • PHP Version: 7.0.13

  • Operating System: Ubuntu 16.10

  • Installation type: Both, same error

  • List of installed packages
    behat/gherkin v4.4.5 Gherkin DSL parser for PHP 5.3
    classpreloader/classpreloader 3.1.0 Helps class loading performance by generating a single PHP file containing all of the autoloaded files for a specific ...
    codeception/codeception 2.2.8 BDD-style testing framework
    dnoegel/php-xdg-base-dir 0.1 implementation of xdg base directory specification for php
    doctrine/inflector v1.1.0 Common String Manipulations with regard to casing and singular/plural rules.
    doctrine/instantiator 1.0.5 A small, lightweight utility to instantiate objects in PHP without invoking their constructors
    facebook/webdriver 1.3.0 A PHP client for WebDriver
    fzaninotto/faker v1.6.0 Faker is a PHP library that generates fake data for you.
    guzzlehttp/guzzle 6.2.2 Guzzle is a PHP HTTP client library
    guzzlehttp/promises v1.3.1 Guzzle promises library
    guzzlehttp/psr7 1.3.1 PSR-7 message implementation
    hamcrest/hamcrest-php v1.2.2 This is the PHP port of Hamcrest Matchers
    jakub-onderka/php-console-color 0.1
    jakub-onderka/php-console-highlighter v0.3.2
    jeremeamia/SuperClosure 2.3.0 Serialize Closure objects, including their context and binding
    laravel/framework v5.3.29 The Laravel Framework.
    league/flysystem 1.0.32 Filesystem abstraction: Many filesystems, one API.
    mockery/mockery 0.9.7 Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other ...
    monolog/monolog 1.22.0 Sends your logs to files, sockets, inboxes, databases and various web services
    mtdowling/cron-expression v1.1.0 CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
    myclabs/deep-copy 1.5.5 Create deep copies (clones) of your objects
    nesbot/carbon 1.22.1 A simple API extension for DateTime.
    nikic/php-parser v3.0.2 A PHP parser written in PHP
    paragonie/random_compat v2.0.4 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
    phpdocumentor/reflection-common 1.0 Common reflection classes used by phpdocumentor to reflect the code structure
    phpdocumentor/reflection-docblock 3.1.1 With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information tha...
    phpdocumentor/type-resolver 0.2.1
    phpspec/prophecy v1.6.2 Highly opinionated mocking framework for PHP 5.3+
    phpunit/php-code-coverage 4.0.4 Library that provides collection, processing, and rendering functionality for PHP code coverage information.
    phpunit/php-file-iterator 1.4.2 FilterIterator implementation that filters files based on a list of suffixes.
    phpunit/php-text-template 1.2.1 Simple template engine.
    phpunit/php-timer 1.0.8 Utility class for timing
    phpunit/php-token-stream 1.4.9 Wrapper around PHP's tokenizer extension.
    phpunit/phpunit 5.7.5 The PHP Unit Testing framework.
    phpunit/phpunit-mock-objects 3.4.3 Mock Object library for PHPUnit
    psr/http-message 1.0.1 Common interface for HTTP messages
    psr/log 1.0.2 Common interface for logging libraries
    psy/psysh v0.8.1 An interactive shell for modern PHP.
    ramsey/uuid 3.5.2 Formerly rhumsaa/uuid. A PHP 5.4+ library for generating RFC 4122 version 1, 3, 4, and 5 universally unique identifier...
    sebastian/code-unit-reverse-lookup 1.0.0 Looks up which function or method a line of code belongs to
    sebastian/comparator 1.2.2 Provides the functionality to compare PHP values for equality
    sebastian/diff 1.4.1 Diff implementation
    sebastian/environment 2.0.0 Provides functionality to handle HHVM/PHP environments
    sebastian/exporter 2.0.0 Provides the functionality to export PHP variables for visualization
    sebastian/global-state 1.1.1 Snapshotting of global state
    sebastian/object-enumerator 2.0.0 Traverses array structures and object graphs to enumerate all referenced objects
    sebastian/recursion-context 2.0.0 Provides functionality to recursively process PHP variables
    sebastian/resource-operations 1.0.0 Provides a list of PHP built-in functions that operate on resources
    sebastian/version 2.0.1 Library that helps with managing the version number of Git-hosted PHP projects
    swiftmailer/swiftmailer v5.4.5 Swiftmailer, free feature-rich PHP mailer
    symfony/browser-kit v3.2.2 Symfony BrowserKit Component
    symfony/console v3.1.9 Symfony Console Component
    symfony/css-selector v3.1.9 Symfony CssSelector Component
    symfony/debug v3.1.9 Symfony Debug Component
    symfony/dom-crawler v3.1.9 Symfony DomCrawler Component
    symfony/event-dispatcher v3.2.2 Symfony EventDispatcher Component
    symfony/finder v3.1.9 Symfony Finder Component
    symfony/http-foundation v3.1.9 Symfony HttpFoundation Component
    symfony/http-kernel v3.1.9 Symfony HttpKernel Component
    symfony/polyfill-mbstring v1.3.0 Symfony polyfill for the Mbstring extension
    symfony/polyfill-php56 v1.3.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
    symfony/polyfill-util v1.3.0 Symfony utilities for portability of PHP codes
    symfony/process v3.1.9 Symfony Process Component
    symfony/routing v3.1.9 Symfony Routing Component
    symfony/translation v3.1.9 Symfony Translation Component
    symfony/var-dumper v3.1.9 Symfony mechanism for exploring and dumping PHP variables
    symfony/yaml v3.2.2 Symfony Yaml Component
    vlucas/phpdotenv v2.4.0 Loads environment variables from .env to getenv(), $_ENV and $_SERVER automagically.
    webmozart/assert 1.2.0 Assertions to validate method input/output with nice error messages.

  • Suite configuration:

class_name: ApiTester
modules:
    enabled:
        - REST:
            url: /api/v1
            depends: Laravel5
        - \Helper\Api
        - Laravel5:
            environment_file: .env.testing
            run_database_migrations: false
            run_database_seeder: false

@Naktibalda Naktibalda changed the title from Use without a DB to Use Laravel module without a DB Jan 22, 2017

@Naktibalda Naktibalda added the Laravel5 label Jan 22, 2017

@janhenkgerritsen janhenkgerritsen self-assigned this Jan 22, 2017

@janhenkgerritsen

This comment has been minimized.

Show comment
Hide comment
@janhenkgerritsen

janhenkgerritsen Jan 25, 2017

Contributor

Thanks for reporting this issue, it should be fixed by the referenced PR.

By the way, you can try out this fix by specifying 2.2.x-dev as the version for Codeception in your composer.json file, or you can wait for the next Codeception release, which we'll try to get out as soon as possible.

Contributor

janhenkgerritsen commented Jan 25, 2017

Thanks for reporting this issue, it should be fixed by the referenced PR.

By the way, you can try out this fix by specifying 2.2.x-dev as the version for Codeception in your composer.json file, or you can wait for the next Codeception release, which we'll try to get out as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment