Giter Club home page Giter Club logo

Comments (3)

particleflux avatar particleflux commented on June 21, 2024 1

Cannot reproduce in basic app.

Created a module using:

./yii gii/module --moduleClass 'app\modules\Test\Module' --moduleID test

Edited it to implement BootstrapInterface and add custom url rules on bootstrap:

<?php

namespace app\modules\Test;

use yii\base\BootstrapInterface;

/**
 * test module definition class
 */
class Module extends \yii\base\Module implements BootstrapInterface
{
    /**
     * {@inheritdoc}
     */
    public $controllerNamespace = 'app\modules\Test\controllers';

    /**
     * {@inheritdoc}
     */
    public function init()
    {
        parent::init();

        // custom initialization code goes here
    }

    public function bootstrap($app)
    {
        $app->getUrlManager()->addRules([
            [
                'verb'    => 'GET',
                'pattern' => '/org/config/incident/severity',
                'route'   => '/incident/severity-level/index',
            ],
            [
                'verb'    => 'GET,POST',
                'pattern' => '/org/config/incident/severity/new',
                'route'   => '/incident/severity-level/create',
            ],
            [
                'verb'    => 'GET,POST',
                'pattern' => '/org/config/incident/severity/<id:[0-9]+>/<action:(update|delete)>',
                'route'   => '/incident/severity-level/<action>',
            ],
        ], false);
    }
}

Added to config/test.php:

    'bootstrap' => [
        'class' => app\modules\Test\Module::class,
    ],
    'modules'             => [
        'admin'     => [
            'class' => app\modules\Test\Module::class
        ],
    ]

Tests run fine. (both unit tests and full test suites, including functional)

Any more info you can give? Or maybe a minimal reproduction project in a zip?

Edit: tested with current master version

codeception/codeception       5.0.x-dev 2f06902  BDD-style testing framework
codeception/lib-innerbrowser  4.0.0              Parent library for all Codeception framework modules and PhpBrowser
codeception/module-asserts    3.0.0              Codeception module containing various assertions
codeception/module-filesystem 3.0.0              Codeception module for testing local filesystem
codeception/module-yii2       1.1.9              Codeception module for Yii2 framework
codeception/verify            3.0.0              BDD assertion library for PHPUnit
symfony/browser-kit           6.4.x-dev 3f5752f  Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically
yiisoft/yii2                  dev-master ddf0f87 Yii PHP Framework Version 2
yiisoft/yii2-bootstrap5       dev-master cf7807d The Twitter Bootstrap v5 extension for the Yii framework
yiisoft/yii2-debug            2.1.25             The debugger extension for the Yii framework
yiisoft/yii2-faker            dev-master 98e4e4c Fixture generator. The Faker integration for the Yii framework.
yiisoft/yii2-gii              2.2.6              The Gii extension for the Yii framework
yiisoft/yii2-symfonymailer    2.0.4              The SymfonyMailer integration for the Yii framework

from yii2-app-basic.

cyril-amar avatar cyril-amar commented on June 21, 2024 1

I cannot reproduce either in basic-app for now, seems I have something else elsewhere. I'm still working on identifying the culprit.

from yii2-app-basic.

cyril-amar avatar cyril-amar commented on June 21, 2024

Hi,

Thanks!

I should have had added something indeed, my bad :( The issue only occurs if pretty URLs are enabled

'urlManager'   => [
            'enablePrettyUrl'     => true,
            'showScriptName'      => false,
            'enableStrictParsing' => true,
            'rules'               => $urls, // Declared rules for the "core" app, without modules
        ],

Switching enablePrettyUrl to false solves the issue and allows tests to run.
Commenting out all the rules definition in Module.php also works fine.

I'm running on

codeception/codeception            5.0.11             BDD-style testing framework                                                                   
codeception/lib-asserts            2.1.0              Assertion methods used by Codeception core and Asserts module                                 
codeception/lib-innerbrowser       3.1.3              Parent library for all Codeception framework modules and PhpBrowser                           
codeception/lib-web                1.0.2              Library containing files used by module-webdriver and lib-innerbrowser or module-phpbrowser   
codeception/module-asserts         3.0.0              Codeception module containing various assertions                                              
codeception/module-db              3.1.0              DB module for Codeception                                                                     
codeception/module-filesystem      3.0.0              Codeception module for testing local filesystem                                               
codeception/module-yii2            1.1.9              Codeception module for Yii2 framework                                                         
codeception/stub                   4.1.1              Flexible Stub wrapper for PHPUnit's Mock Builder                                              
codeception/verify                 3.0.0              BDD assertion library for PHPUnit                                                             
phpunit/php-code-coverage          9.2.29             Library that provides collection, processing, and rendering functionality for PHP code coverage information.
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.6.13             The PHP Unit Testing framework.
symfony/browser-kit                v6.3.2             Simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms programmatically
yiisoft/yii2                       2.0.49.1           Yii PHP Framework Version 2
yiisoft/yii2-bootstrap4            2.0.11             The Twitter Bootstrap extension for the Yii framework
yiisoft/yii2-bootstrap5            2.0.4              The Twitter Bootstrap v5 extension for the Yii framework
yiisoft/yii2-composer              2.0.10             The composer plugin for Yii extension installer
yiisoft/yii2-debug                 2.1.25             The debugger extension for the Yii framework
yiisoft/yii2-faker                 2.0.5              Fixture generator. The Faker integration for the Yii framework.
yiisoft/yii2-gii                   2.2.6              The Gii extension for the Yii framework
yiisoft/yii2-symfonymailer         3.0.0              The SymfonyMailer integration for the Yii framework
[...]

I'll try to reproduce in a brand new project and share it.

from yii2-app-basic.

Related Issues (20)

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.