Skip to content
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

yii\base\ErrorException: Uninitialized string offset: 0 #4447

Closed
savinpaul opened this issue Jul 25, 2014 · 7 comments
Closed

yii\base\ErrorException: Uninitialized string offset: 0 #4447

savinpaul opened this issue Jul 25, 2014 · 7 comments
Assignees
Labels
status:to be verified Needs to be reproduced and validated.

Comments

@savinpaul
Copy link

Hi ,

I got an issue in yii2 codeception functional test. I tried to add functional test for my login page. It works fine for the empty condition and wrong condition, but for success condition I got the above error. Below is the full output. If I remove the success condition it works fine.

Codeception PHP Testing Framework v2.0.3
Powered by PHPUnit 4.1.4 by Sebastian Bergmann.

Functional Tests (1) -------------------------------------------------------------------------------------------------------
Trying to Ensure login page works (LoginCept)
Scenario:

  • I am on page "frontend.kochi-dev.portalv2.mysau.com.au/index.php?r=site%2Flogin"
  • I am going to Submit login form with no data
  • I fill field "input[name="LoginForm[username]"]",""
  • I fill field "input[name="LoginForm[password]"]",""
  • I click "login-button"
  • I expect to See validations errors
  • I see element ".form-login-error_true"
  • I am going to Try to login with wrong credentials
  • I expect to see validations errors
  • I fill field "input[name="LoginForm[username]"]","admin"
  • I fill field "input[name="LoginForm[password]"]","wrong"
  • I click "login-button"
  • I expect to see validations errors
  • I see element ".form-login-error_true"
  • I am going to Try to login with correct credentials
  • I fill field "input[name="LoginForm[username]"]","test@dev.com"
  • I fill field "input[name="LoginForm[password]"]","123456"
  • I click "login-button"
    ERROR

  1. Failed to ensure login page works in LoginCept (/var/www/html/portalv2/portalv2_base/frontend/tests/functional/LoginCept.php)
    Couldn't click "login-button":
    yii\base\ErrorException: Uninitialized string offset: 0

Scenario Steps:
18. I click "login-button"
17. I fill field "input[name="LoginForm[password]"]","123456"
16. I fill field "input[name="LoginForm[username]"]","test@test.com"
15. I am going to Try to login with correct credentials
14. I see element ".form-login-error_true"
13. I expect to see validations errors
12. I click "login-button"
#1 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/web/AssetBundle.php:147
#2 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/web/View.php:264
#3 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/web/View.php:160
#4 /var/www/html/portalv2/portalv2_base/frontend/views/layouts/main_login.php:102
#5 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/base/View.php:315
#6 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/base/View.php:247
#7 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/base/Controller.php:365
#8 /var/www/html/portalv2/portalv2_base/frontend/controllers/SiteController.php:208
#9 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/base/InlineAction.php:54
#10 /var/www/html/portalv2/portalv2_base/vendor/yiisoft/yii2/base/Controller.php:147

Time: 1.64 seconds, Memory: 22.25Mb

There was 1 error:


FAILURES!
Tests: 1, Assertions: 2, Errors: 1.

@samdark samdark added this to the 2.0 RC milestone Jul 25, 2014
@samdark samdark self-assigned this Jul 25, 2014
@qiangxue
Copy link
Member

How is your asset bundle class defined? The error indicates you have an invalid js property in your asset bundle class.

@qiangxue qiangxue removed this from the 2.0 RC milestone Jul 25, 2014
@savinpaul
Copy link
Author

Thank You for your reply. Sorry for the late reply. Here is my AppAsset class which extends AssetBundle class.

namespace frontend\assets;
use yii\web\AssetBundle;

/**
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @since 2.0
 */
class AppAsset extends AssetBundle
{
    public $basePath = '@webroot';
    public $baseUrl = '@web';
    public $css = [
        'css/site.css',
         'css/bootstrap.css',
         'css/font-icons/entypo/css/entypo.css',
         'css/neon-core.css',
         'css/neon-theme.css',
         'css/neon-forms.css',
         'css/custom.css',
         'css/custom.css',
         'css/neon-forms.css',
         'js/datatables/responsive/css/datatables.responsive.css',
         'js/select2/select2-bootstrap.css',
         'js/select2/select2.css',
    ];
    public $js = [

    'js/gsap/main-gsap.js',          
        'js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js', 
        'js/resizeable.js',         
        'js/neon-api.js',         
        'js/select2/select2.min.js',         
      'js/neon-chat.js',                        
      'js/neon-demo.js',         
        'js/jquery.validate.min.js',         
        'js/neon-login.js',
        'js/bootstrap.js',

    ];
    public $depends = [
       'yii\web\YiiAsset',
        'yii\bootstrap\BootstrapAsset',    
    ];
}

@qiangxue
Copy link
Member

What is at: /var/www/html/portalv2/portalv2_base/frontend/views/layouts/main_login.php:102

@savinpaul
Copy link
Author

Body ends at main_login.php 102

endBody(); ?>

@jitheshborgia
Copy link

Run codecept build command after including PHPBrowser as a module in functional.suite.yml and try again.

@qiangxue
Copy link
Member

I can't tell how this would cause the error. Did you configure assetManager in your app config? If so, what is it? Did you use any other asset bundles? What are they?

@savinpaul
Copy link
Author

Hi ,
This is working well now. I have just enabled PhpBrowser in functional.suite.yml file as suggested by @jitheshborgia . Problem seems to be solved. Thanks to all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:to be verified Needs to be reproduced and validated.
Projects
None yet
Development

No branches or pull requests

4 participants