Skip to content

Instantly share code, notes, and snippets.

@cornernote
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save cornernote/5bfe015e66d1aca0fe93 to your computer and use it in GitHub Desktop.

Select an option

Save cornernote/5bfe015e66d1aca0fe93 to your computer and use it in GitHub Desktop.
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'test');
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', '/index.php');
defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', __DIR__ . '/_app/web/index.php');
defined('VENDOR_DIR') or define('VENDOR_DIR', __DIR__ . '/../../vendor');
require_once(VENDOR_DIR . '/autoload.php');
<?php
use AspectMock\Kernel;
require __DIR__ . '/_init.php';
$kernel = Kernel::getInstance();
$kernel->init([
'debug' => true,
'includePaths' => [__DIR__ . '/../../', VENDOR_DIR],
'excludePaths' => [__DIR__],
'cacheDir' => '/tmp/yii2-audit/aop',
]);
$kernel->loadFile(VENDOR_DIR . '/yiisoft/yii2/Yii.php');
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
$_SERVER['SERVER_NAME'] = 'localhost';
Yii::setAlias('@tests', dirname(__DIR__));
Yii::setAlias('@bedezign/yii2/audit', realpath(__DIR__ . '../../src'));
class_name: FunctionalTester
modules:
enabled:
- Yii2
- tests\codeception\_support\FixtureHelper
- tests\codeception\_support\MailHelper
config:
Yii2:
configFile: 'codeception/_config/functional.php'

$ ../vendor/bin/codecept build

Building Actor classes for suites: functional, unit
bedezign\yii2\audit\tests\FunctionalTester includes modules: Yii2, tests\codeception\_support\FixtureHelper, tests\codeception\_support\MailHelper
FunctionalTester.php generated successfully. 54 methods added
bedezign\yii2\audit\tests\UnitTester includes modules: Asserts, tests\codeception\_support\CodeHelper
UnitTester.php generated successfully. 19 methods added

$ ../vendor/bin/codecept run --debug --fail-fast

Codeception PHP Testing Framework v2.0.14
Powered by PHPUnit 4.6.10 by Sebastian Bergmann and contributors.

Bedezign\yii2\audit\tests.functional Tests (1) ----------------------------------------------------------------------
Modules: Yii2, FixtureHelper, MailHelper
---------------------------------------------------------------------------------------------------------------------
Ensure that home page works (HomeCept)
Scenario:
PHP Fatal error:  Class 'FunctionalTester' not found in /vagrant/git/yii2-audit/tests/codeception/functional/HomeCept.php on line 7
PHP Stack trace:
PHP   1. {main}() /vagrant/git/yii2-audit/vendor/codeception/codeception/codecept:0
PHP   2. Symfony\Component\Console\Application->run() /vagrant/git/yii2-audit/vendor/codeception/codeception/codecept:27
PHP   3. Symfony\Component\Console\Application->doRun() /vagrant/git/yii2-audit/vendor/symfony/console/Application.php:126
PHP   4. Symfony\Component\Console\Application->doRunCommand() /vagrant/git/yii2-audit/vendor/symfony/console/Application.php:195
PHP   5. Symfony\Component\Console\Command\Command->run() /vagrant/git/yii2-audit/vendor/symfony/console/Application.php:878
PHP   6. Codeception\Command\Run->execute() /vagrant/git/yii2-audit/vendor/symfony/console/Command/Command.php:259
PHP   7. Codeception\Command\Run->runSuites() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Command/Run.php:192
PHP   8. Codeception\Codecept->run() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Command/Run.php:263
PHP   9. Codeception\Codecept->runSuite() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Codecept.php:158
PHP  10. Codeception\SuiteManager->run() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Codecept.php:175
PHP  11. Codeception\PHPUnit\Runner->doEnhancedRun() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
PHP  12. PHPUnit_Framework_TestSuite->run() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php:100
PHP  13. PHPUnit_Framework_TestCase->run() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestSuite.php:722
PHP  14. PHPUnit_Framework_TestResult->run() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php:699
PHP  15. PHPUnit_Framework_TestCase->runBare() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestResult.php:609
PHP  16. PHPUnit_Framework_TestCase->runTest() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php:743
PHP  17. ReflectionMethod->invokeArgs() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php:866
PHP  18. Codeception\TestCase\Cept->testCodecept() /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php:866
PHP  19. require() /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/TestCase/Cept.php:64
<pre>PHP Fatal Error &#039;yii\base\ErrorException&#039; with message &#039;Class &#039;FunctionalTester&#039; not found&#039;

in /vagrant/git/yii2-audit/tests/codeception/functional/HomeCept.php:7

Stack trace:
#0 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php(866): Codeception\TestCase\Cept-&gt;testCodecept()
#1 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php(866): ReflectionMethod-&gt;invokeArgs()
#2 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php(743): PHPUnit_Framework_TestCase-&gt;runTest()
#3 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestResult.php(609): PHPUnit_Framework_TestCase-&gt;runBare()
#4 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestCase.php(699): PHPUnit_Framework_TestResult-&gt;run()
#5 /vagrant/git/yii2-audit/vendor/phpunit/phpunit/src/Framework/TestSuite.php(722): PHPUnit_Framework_TestCase-&gt;run()
#6 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/PHPUnit/Runner.php(100): PHPUnit_Framework_TestSuite-&gt;run()
#7 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/SuiteManager.php(158): Codeception\PHPUnit\Runner-&gt;doEnhancedRun()
#8 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Codecept.php(175): Codeception\SuiteManager-&gt;run()
#9 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Codecept.php(158): Codeception\Codecept-&gt;runSuite()
#10 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Command/Run.php(263): Codeception\Codecept-&gt;run()
#11 /vagrant/git/yii2-audit/vendor/codeception/codeception/src/Codeception/Command/Run.php(192): Codeception\Command\Run-&gt;runSuites()
#12 /vagrant/git/yii2-audit/vendor/symfony/console/Command/Command.php(259): Codeception\Command\Run-&gt;execute()
#13 /vagrant/git/yii2-audit/vendor/symfony/console/Application.php(878): Symfony\Component\Console\Command\Command-&gt;run()
#14 /vagrant/git/yii2-audit/vendor/symfony/console/Application.php(195): Symfony\Component\Console\Application-&gt;doRunCommand()
#15 /vagrant/git/yii2-audit/vendor/symfony/console/Application.php(126): Symfony\Component\Console\Application-&gt;doRun()
#16 /vagrant/git/yii2-audit/vendor/codeception/codeception/codecept(27): Symfony\Component\Console\Application-&gt;run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment