0

I am having some problems with Codeception using Yii2. I just upgraded to Yii 2.0.10 and have been using this guide

I am getting the error: Codeception\Test\Unit not found in vendor\codeception\base\shim.php. If I ocmment this class out, the next one fails which is:

namespace Codeception\Module {

class Symfony2 extends Symfony {
}

This is what've done: I created a file test.php and put it in my config folder:

<?php
// config/test.php
$config =  yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/main.php'),
require(__DIR__ . '/main-local.php'),
[
'id' => 'app-tests',
'components' => [
    'db1' => require(__DIR__ . '/db.php'),
]
]
);
return $config;

codeception.yaml

actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
memory_limit: 1024M
colors: true
modules:
config:
    Yii2:
        configFile: 'config/test.php'

unit.suite.yml

class_name: UnitTester
modules:
enabled:
  - Asserts
  - Yii2:
        part: [orm, email]

I'm completely new to Codeception, so not sure what I've done wrong

2 Answers 2

1

As far as I remember you have to do nothing except php vendor/bin/codecept run in directory where you have codeception.yaml.

Please note that path vendor/bin/codecept may differ in your case. Generally speaking Codeception will parse your configuration and do the magic.


It's not necessary to know but if you're interested: it parses configuration and establishes relations between namespaces and paths dynamically by using its own PSR-4 compatible class autoloader implementation.

Take a look here - https://github.com/Codeception/Codeception/blob/2.2/src/Codeception/Configuration.php#L214 and here https://github.com/Codeception/Codeception/blob/2.2/src/Codeception/Util/Autoload.php

Sign up to request clarification or add additional context in comments.

Comments

0

In this situation as I upgraded from 2.0.9 -> 2.0.10. I had to composer remove yiisoft/yii2-codeception, codeception/codeception, codeception\verify, codeception\specify, codeception\base.

I copied the test folder structure over. Changed my composer.json in the root project to include:

    "require-dev": {
    "yiisoft/yii2-debug": "*",
    "yiisoft/yii2-gii": "*",
    "yiisoft/yii2-faker": "*",
    "codeception/base": "^2.2.3",
    "codeception/verify": "~0.3.1",
    "codeception/specify": "~0.4.3"
},

I also added the test.php and test_db.php files to /config

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.