Git Product home page Git Product logo

module-lumen's Introduction

Stand With Ukraine

Codeception

Latest Stable Total Downloads StandWithUkraine Build status

Modern PHP Testing for everyone

Codeception is a modern full-stack testing framework for PHP. Inspired by BDD, it provides an absolutely new way of writing acceptance, functional and even unit tests.

Contributions

At Codeception we are glad to receive contributions from the community. If you want to send additions or fixes to the code or the documentation please check the Contributing guide.

At a Glance

Describe what you test and how you test it. Use PHP to write descriptions faster.

Run tests and see what actions were taken and what results were seen.

Sample test

$I->amOnPage('/');
$I->click('Pages');
$I->click('New');
$I->see('New Page');
$I->submitForm('form#new_page', ['title' => 'Movie Review']);
$I->see('page created'); // notice generated
$I->see('Movie Review','h1'); // head of page of is our title
$I->seeInCurrentUrl('pages/movie-review'); // slug is generated
$I->seeInDatabase('pages', ['title' => 'Movie Review']); // data is stored in database

For unit testing you can stay on classic PHPUnit tests, as Codeception can run them too.

Installation

Composer

php composer.phar require "codeception/codeception"

TODO: Document how to install the modules, e.g.

php composer.phar require "codeception/module-phpbrowser"

Phar

Download codecept.phar

Copy it into your project.

You can also make Codeception an executable and it put it into your $PATH, for instance:

wget https://codeception.com/codecept.phar

chmod +x codecept.phar

sudo mv codecept.phar /usr/local/bin/codecept

You can then run Codecept in the command line using: codecept bootstrap, codecept run, etc

Run CLI utility:

php codecept.phar

See also Installation | QuickStart

Getting Started

After you successfully installed Codeception, run this command:

codecept bootstrap

This will create a default directory structure and default test suites.

Documentation

View Documentation

The documentation source files can be found at https://github.com/Codeception/codeception.github.com/tree/master/docs/.

License

MIT

module-lumen's People

Contributors

arhell avatar astepin avatar davertmik avatar exorus avatar gimler avatar ibpavlov avatar janhenkgerritsen avatar kt81 avatar lendormi avatar maxakawizard avatar naktibalda avatar retnek avatar tavoniievez avatar thomaslandauer avatar turbo8p avatar zbateson avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

module-lumen's Issues

Lumen 9.0.2 - Declaration of DummyKernel must be compatible with HttpKernelInterface

What are you trying to achieve?

Run tests in general (using make).

What do you get instead?

Fatal error: Declaration of Codeception\Lib\Connector\Lumen\DummyKernel::handle(Symfony\Component\HttpFoundation\Request $request, $type = self::MASTER_REQUEST, $catch = true): void must be compatible with Symfony\Component\HttpKernel\HttpKernelInterface::handle(Symfony\Component\HttpFoundation\Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Symfony\Component\HttpFoundation\Response in /var/www/vendor/codeception/module-lumen/src/Codeception/Lib/Connector/Lumen/DummyKernel.php on line 15

FATAL ERROR. TESTS NOT FINISHED.
Declaration of Codeception\Lib\Connector\Lumen\DummyKernel::handle(Symfony\Component\HttpFoundation\Request $request, $type = self::MASTER_REQUEST, $catch = true): void must be compatible with Symfony\Component\HttpKernel\HttpKernelInterface::handle(Symfony\Component\HttpFoundation\Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Symfony\Component\HttpFoundation\Response 
in /var/www/vendor/codeception/module-lumen/src/Codeception/Lib/Connector/Lumen/DummyKernel.php:15

Details

  • Codeception version: 5.0.0-RC5
  • PHP Version: 8.1
  • Operating System: Ubuntu with Docker
  • Installation type: Composer
  • List of installed packages (composer show):
behat/gherkin                      v4.9.0    Gherkin DSL parser for PHP
brick/math                         0.9.3     Arbitrary-precision arithmetic library
codeception/codeception            5.0.0-RC5 BDD-style testing framework
codeception/lib-asserts            2.0.0     Assertion methods used by Codeception core and Asserts module
codeception/lib-innerbrowser       3.1.2     Parent library for all Codeception framework modules and PhpBrowser
codeception/lib-web                1.0.1     Library containing files used by module-webdriver and lib-innerbrowser or module-phpbrowser
codeception/lib-xml                1.0.0     Files used by module-rest and module-soap
codeception/module-asserts         3.0.0     Codeception module containing various assertions
codeception/module-db              3.0.1     DB module for Codeception
codeception/module-lumen           3.0.0     Codeception module for Lumen framework
codeception/module-rest            3.1.0     REST module for Codeception
codeception/stub                   4.0.2     Flexible Stub wrapper for PHPUnit's Mock Builder
doctrine/cache                     2.2.0     PHP Doctrine Cache library is a popular cache implementation that supports many different dr...
doctrine/dbal                      3.3.7     Powerful PHP database abstraction layer (DBAL) with many features for database schema intros...
doctrine/deprecations              v1.0.0    A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to di...
doctrine/event-manager             1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the v...
doctrine/inflector                 2.0.4     PHP Doctrine Inflector is a small library that can perform string manipulations with regard ...
doctrine/instantiator              1.4.1     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                     1.2.3     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
dragonmantank/cron-expression      v3.3.1    CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due
egulias/email-validator            3.2.1     A library for validating emails against several RFCs
fruitcake/php-cors                 v1.2.0    Cross-origin resource sharing library for the Symfony HttpFoundation
graham-campbell/result-type        v1.0.4    An Implementation Of The Result Type
guzzlehttp/guzzle                  7.4.5     Guzzle is a PHP HTTP client library
guzzlehttp/promises                1.5.1     Guzzle promises library
guzzlehttp/psr7                    2.4.0     PSR-7 message implementation that also provides common utility methods
illuminate/auth                    v9.18.0   The Illuminate Auth package.
illuminate/broadcasting            v9.18.0   The Illuminate Broadcasting package.
illuminate/bus                     v9.18.0   The Illuminate Bus package.
illuminate/cache                   v9.18.0   The Illuminate Cache package.
illuminate/collections             v9.18.0   The Illuminate Collections package.
illuminate/conditionable           v9.18.0   The Illuminate Conditionable package.
illuminate/config                  v9.18.0   The Illuminate Config package.
illuminate/console                 v9.18.0   The Illuminate Console package.
illuminate/container               v9.18.0   The Illuminate Container package.
illuminate/contracts               v9.18.0   The Illuminate Contracts package.
illuminate/database                v9.18.0   The Illuminate Database package.
illuminate/encryption              v9.18.0   The Illuminate Encryption package.
illuminate/events                  v9.18.0   The Illuminate Events package.
illuminate/filesystem              v9.18.0   The Illuminate Filesystem package.
illuminate/hashing                 v9.18.0   The Illuminate Hashing package.
illuminate/http                    v9.18.0   The Illuminate Http package.
illuminate/log                     v9.18.0   The Illuminate Log package.
illuminate/macroable               v9.18.0   The Illuminate Macroable package.
illuminate/pagination              v9.18.0   The Illuminate Pagination package.
illuminate/pipeline                v9.18.0   The Illuminate Pipeline package.
illuminate/queue                   v9.18.0   The Illuminate Queue package.
illuminate/session                 v9.18.0   The Illuminate Session package.
illuminate/support                 v9.18.0   The Illuminate Support package.
illuminate/testing                 v9.18.0   The Illuminate Testing package.
illuminate/translation             v9.18.0   The Illuminate Translation package.
illuminate/validation              v9.18.0   The Illuminate Validation package.
illuminate/view                    v9.18.0   The Illuminate View package.
justinrainbow/json-schema          5.2.12    A library to validate a json schema.
kraken-io/kraken-php               1.6       Official Kraken.io SDK
laravel/lumen-framework            v9.0.2    The Laravel Lumen Framework.
laravel/serializable-closure       v1.2.0    Laravel Serializable Closure provides an easy and secure way to serialize closures in PHP.
masterminds/html5                  2.7.5     An HTML5 parser and serializer.
monolog/monolog                    2.7.0     Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/deep-copy                  1.11.0    Create deep copies (clones) of your objects
nesbot/carbon                      2.58.0    An API extension for DateTime that supports 281 different languages.
nikic/fast-route                   v1.3.0    Fast request router for PHP
nikic/php-parser                   v4.14.0   A PHP parser written in PHP
paragonie/constant_time_encoding   v2.6.3    Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)
paragonie/random_compat            v9.99.100 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                   2.0.3     Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                    3.2.1     Library for handling version information and constraints
php-amqplib/php-amqplib            v3.1.2    Formerly videlalvaro/php-amqplib.  This library is a pure PHP implementation of the AMQP pro...
phpdocumentor/reflection-common    2.2.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  5.3.0     With this component, a library can provide support for annotations via DocBlocks or otherwis...
phpdocumentor/type-resolver        1.6.1     A PSR-5 based resolver of Class names, Types and Structural Element Names
phpoption/phpoption                1.8.1     Option Type for PHP
phpseclib/phpseclib                3.0.14    PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 ...
phpspec/prophecy                   v1.15.0   Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          9.2.15    Library that provides collection, processing, and rendering functionality for PHP code cover...
phpunit/php-file-iterator          3.0.6     FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-invoker                3.1.1     Invoke callables with a timeout
phpunit/php-text-template          2.0.4     Simple template engine.
phpunit/php-timer                  5.0.3     Utility class for timing
phpunit/phpunit                    9.5.21    The PHP Unit Testing framework.
predis/predis                      v1.1.10   Flexible and feature-complete Redis client for PHP and HHVM
psr/cache                          3.0.0     Common interface for caching libraries
psr/container                      2.0.2     Common Container Interface (PHP FIG PSR-11)
psr/event-dispatcher               1.0.0     Standard interfaces for event handling.
psr/http-client                    1.0.1     Common interface for HTTP clients
psr/http-factory                   1.0.1     Common interfaces for PSR-7 HTTP message factories
psr/http-message                   1.0.1     Common interface for HTTP messages
psr/log                            3.0.0     Common interface for logging libraries
psr/simple-cache                   3.0.0     Common interfaces for simple caching
psy/psysh                          v0.11.5   An interactive shell for modern PHP.
ralouphie/getallheaders            3.0.3     A polyfill for getallheaders.
ramsey/collection                  1.2.2     A PHP library for representing and manipulating collections.
ramsey/uuid                        4.3.1     A PHP library for generating and working with universally unique identifiers (UUIDs).
rinvex/countries                   v8.1.1    Rinvex Countries is a simple and lightweight package for retrieving country details with fle...
sebastian/cli-parser               1.0.1     Library for parsing CLI options
sebastian/code-unit                1.0.8     Collection of value objects that represent the PHP code units
sebastian/code-unit-reverse-lookup 2.0.3     Looks up which function or method a line of code belongs to
sebastian/comparator               4.0.6     Provides the functionality to compare PHP values for equality
sebastian/complexity               2.0.2     Library for calculating the complexity of PHP code units
sebastian/diff                     4.0.4     Diff implementation
sebastian/environment              5.1.4     Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 4.0.4     Provides the functionality to export PHP variables for visualization
sebastian/global-state             5.0.5     Snapshotting of global state
sebastian/lines-of-code            1.0.3     Library for counting the lines of code in PHP source code
sebastian/object-enumerator        4.0.4     Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector         2.0.4     Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context        4.0.4     Provides functionality to recursively process PHP variables
sebastian/resource-operations      3.0.3     Provides a list of PHP built-in functions that operate on resources
sebastian/type                     3.0.0     Collection of value objects that represent the types of the PHP type system
sebastian/version                  3.0.2     Library that helps with managing the version number of Git-hosted PHP projects
sendgrid/php-http-client           3.14.4    HTTP REST client, simplified for PHP
sendgrid/sendgrid                  7.11.5    This library allows you to quickly and easily send emails through Twilio SendGrid using PHP.
softcreatr/jsonpath                0.8.0     JSONPath implementation for parsing, searching and flattening arrays
starkbank/ecdsa                    0.0.5     fast openSSL-compatible implementation of the Elliptic Curve Digital Signature Algorithm (EC...
stripe/stripe-php                  v7.128.0  Stripe PHP Library
symfony/browser-kit                v6.1.0    Simulates the behavior of a web browser, allowing you to make requests, click on links and s...
symfony/console                    v6.1.2    Eases the creation of beautiful and testable command line interfaces
symfony/css-selector               v6.1.0    Converts CSS selectors to XPath expressions
symfony/deprecation-contracts      v3.1.1    A generic function and convention to trigger deprecation notices
symfony/dom-crawler                v6.1.0    Eases DOM navigation for HTML and XML documents
symfony/error-handler              v6.1.0    Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher           v6.1.0    Provides tools that allow your application components to communicate with each other by disp...
symfony/event-dispatcher-contracts v3.1.1    Generic abstractions related to dispatching event
symfony/finder                     v6.1.0    Finds files and directories via an intuitive fluent interface
symfony/http-foundation            v6.1.2    Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                v6.1.2    Provides a structured process for converting a Request into a Response
symfony/mime                       v6.1.1    Allows manipulating MIME messages
symfony/polyfill-ctype             v1.26.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme     v1.26.0   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-idn          v1.26.0   Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer   v1.26.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring          v1.26.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php72             v1.26.0   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php80             v1.26.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81             v1.26.0   Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions
symfony/process                    v6.1.0    Executes commands in sub-processes
symfony/service-contracts          v3.1.1    Generic abstractions related to writing services
symfony/string                     v6.1.2    Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and graph...
symfony/translation                v6.1.0    Provides tools to internationalize your application
symfony/translation-contracts      v3.1.1    Generic abstractions related to translation
symfony/var-dumper                 v6.1.0    Provides mechanisms for walking through any arbitrary PHP variable
symfony/yaml                       v6.1.2    Loads and dumps YAML files
theseer/tokenizer                  1.2.1     A small library for converting tokenized PHP source code into XML and potentially other formats
vlucas/phpdotenv                   v5.4.1    Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.
voku/portable-ascii                2.0.1     Portable ASCII library - performance optimized (ascii) string functions for php.
webmozart/assert                   1.11.0    Assertions to validate method input/output with nice error messages.

  • Suite configuration:
actor: ApiTester
suite_namespace: \Api
modules:
    enabled:
      - REST:
          url: /api/v1/
          depends: Lumen

firstRequest decision misunderstanding

Hey Guys again,

if (!$this->firstRequest) {

In this line the code checks the current call is the very first or not. If not the first, it does the initialization. First tough, it is not clear and could causes misunderstanding, and does not work with multiple REST calls in a single test method.
When somebody runs at least three REST calls consecutive, the third will causes error:

Call to a member function connection() on null

because of the wrong initialization condition. I think the author would write that code in a true check:

if ($this->firstRequest) {

If I remove the exclamation mark it works well.

Cheers,
Istvan

Multiple inititalize in Lumen module

Hey Guys!

I'm here again with an another issue with the Lumen module. When I'd like to make tests that contains more than one facade mocks, then the second mock won't be applied (it remains the original class).

for example:

// this is a facade mock:
\AnyNamespace\Facades\Classname::shouldReceive('command1')->andReturnTrue();
$I->sendGET('/path');

// this isn't:
\AnyNamespace\Facades\Classname::shouldReceive('command2')->andReturnTrue();
$I->sendGET('/path');

...because the Lumen connector initialize the client again after the second REST call (see doRequest method below), and this function will clear the previously resolved instances.

// in Codeception/Lib/Connector/Lumen.php
public function __construct($module)
{
    ...
    // constructor already initialize the module
    $this->initialize();
}
...
protected function doRequest($request)
{
    // firstRequest is true by default
    if (!$this->firstRequest) {
        // I really don't know why suppose to re-initialize the whole module, 
        // it's already initilaized in the constructor method
        $this->initialize($request);
    }
    $this->firstRequest = false;
    ....
}

private function initialize($request = null)
{
    ....
    if (class_exists(Facade::class)) {
        // this will drop all previously resolved facades, 
        // and won't let my tests run correctly
        Facade::clearResolvedInstances();
    }
    ....

The whole firstRequest check should be removed in my opinion. I can make a PR for this.

  • Codeception version: 2.5.6
  • PHP Version: 7.2.13

[Lumen] How can I make sure which configure file codecept read?

correctly run codeception with configure file

[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'

Details

  • Framework: Laravel Framework Lumen (5.7.6) (Laravel Components 5.7.*)
  • Codeception version: Codeception 2.5.1
  • Operating System: linux
  • Installation type: Composer

I have two codecept installed in machine, one of them was installed by composer. when I run

$ codecept run unit App/ZtTransformerTest -vvv

under ProjectRoot/ it shows

 ==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.5.1 by Sebastian Bergmann and contributors.
Running with seed: 

my ProjectRoot/tests/unit.suite.yml is like

#   5 actor: UnitTester
  6 modules:
  7     enabled:
  8         - Asserts
  9         - \Helper\Unit
 10         - Lumen:
 11                 bootstrap: Application/Api/bootstrap/app.php
 12                 environment_file: Application/Api/.env.test

and under ProjectRoot/Application/Api/ there exists a file .env.test

 15 # event store DB 主库
 16 DB_CONNECTION=mysql
 17 DB_ZKNAME=********
 18 DB_HOST=*******
 19 DB_PORT=******
 20 DB_DATABASE=******
 21 DB_USERNAME=******
 22 DB_PASSWORD=*******

I'm sure the database configuration is completely right. But it still report that error. So I add a statement

dd(env('DB_HOST'));

in ProjectRoot/Application/Api/config/database.php it's like

dd(env('DB_HOST'));
return [
    'migrations'  => 'migrations',
    'default'     => 'mysql',
    'connections' => [
        'mysql'       => [
            'driver'    => 'mysql',
            'zkname'    => env('DB_ZKNAME', ''),
            'host'      => env('DB_HOST', '127.0.0.1'),
            'port'      => env('DB_PORT', '3306'),
            'database'  => env('DB_DATABASE', 'forge'),
            'username'  => env('DB_USERNAME', 'forge'),
            'password'  => env('DB_PASSWORD', ''),
            'charset'   => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix'    => '',
            'strict'    => true,
            'engine'    => null,
        ],

But when I run codecept again it report

==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 7.5.1 by Sebastian Bergmann and contributors.
Running with seed: 


Unit Tests (1) --------------------------------------------------------------------------------------------
- ZtTransformerTest: Some featurenull
PHP Fatal error:  Uncaught RuntimeException: Command Did Not Finish Properly in ProjectRoot/vendor/codeception/codeception/src/Codeception/Subscriber/ErrorHandler.php:101

as you can see the dd print "null" to screen which means .env.test file does not work, I wonder how can I make the codecept read configure file correctly?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.