in phar:///home/jenkins/workspace/Xxxtrunk/build/tools/codecept.phar/src/Codeception/Lib/Connector/Yii2.php:71
Yii2 2.0.10
Codeception PHP Testing Framework v2.2.5
Powered by PHPUnit 5.5.5 by Sebastian Bergmann and contributors.
<?php
namespace tests\unit\models;
use app\models\User;
use Codeception\Test\Unit;
class UserTest extends Unit
{
public function testFindUserById()
{
$this->assertNotEmpty($user = User::findIdentity(100));
$this->assertEquals('admin', $user->username);
$this->assertEmpty(User::findIdentity(999));
}
public function testFindUserByAccessToken()
{
$this->assertNotEmpty($user = User::findIdentityByAccessToken('100-token'));
$this->assertEquals('admin', $user->username);
$this->assertEmpty(User::findIdentityByAccessToken('non-existing'));
}
public function testFindUserByUsername()
{
$this->assertNotEmpty($user = User::findByUsername('admin'));
$this->assertEmpty(User::findByUsername('not-admin'));
}
/**
* @depends testFindUserByUsername
*/
public function testValidateUser($user)
{
$user = User::findByUsername('admin');
$this->assertNotEmpty($user->validateAuthKey('test100key'));
$this->assertEmpty($user->validateAuthKey('test102key'));
$this->assertNotEmpty($user->validatePassword('admin'));
$this->assertEmpty($user->validatePassword('123456'));
}
}
โโโ config
โโโ tests
โโโ acceptance
โย ย โโโ _bootstrap.php
โโโ acceptance.suite.yml.example
โโโ bin
โย ย โโโ yii
โย ย โโโ yii.bat
โโโ _bootstrap.php
โโโ _data
โย ย โโโ dump.sql
โโโ _envs
โโโ functional
โย ย โโโ _bootstrap.php
โโโ functional.suite.yml
โโโ _output
โย ย โโโ report.xml
โโโ _support
โย ย โโโ AcceptanceTester.php
โย ย โโโ FunctionalTester.php
โย ย โโโ _generated
โย ย โย ย โโโ AcceptanceTesterActions.php
โย ย โย ย โโโ FunctionalTesterActions.php
โย ย โย ย โโโ UnitTesterActions.php
โย ย โโโ Helper
โย ย โย ย โโโ Acceptance.php
โย ย โย ย โโโ Functional.php
โย ย โย ย โโโ Unit.php
โย ย โโโ UnitTester.php
โโโ unit
โย ย โโโ _bootstrap.php
โย ย โโโ models
โย ย โโโ UserTest.php
โโโ unit.suite.yml
seems that your composer is not autoloading Yii. Can you verify?
How do I define the problem? I make sure that it has been added to the environment variable.
# composer -v
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.2.0 2016-07-19 01:28:52
are you sure Yii is in your Vendor folder?
Yes, I'm sure!
Do you need a global install yii2? I'm studying it myself.
global? no just locally in your vendor
You need include Yii
manually - it is not autoloaded.
https://github.com/yiisoft/yii2-app-basic/blob/master/tests/_bootstrap.php
I tried for a long time, but haven't found out where the problem is!
# codecept run unit
Codeception PHP Testing Framework v2.2.6
Powered by PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
Unit Tests (4) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- UserTest: Find user by id
FATAL ERROR. TESTS NOT FINISHED.
Class 'Yii' not found
in /root/.composer/vendor/codeception/codeception/src/Codeception/Lib/Connector/Yii2.php:71
@rob006 You helped me find the problem, Thank you very much! At the same time thank you @dynasource
Im sorry but how you include yii manually? can you show me how to do it? thankyou
Most helpful comment
You need include
Yii
manually - it is not autoloaded.https://github.com/yiisoft/yii2-app-basic/blob/master/tests/_bootstrap.php