I am trying to run my functional test and this is the error message i get
[PHPUnit_Framework_Exception] Undefined index: config in C:\wamp\www\test.qsims.com\tests\functional_bootstrap.php on line 4**
I'm trying to parse URL in the functional/_bootstrap.php file. The code for the following is below
<?php
define('DS', DIRECTORY_SEPARATOR);
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
defined('YII_TEST_ENTRY_FILE') or define('YII_TEST_ENTRY_FILE', dirname(dirname(__DIR__)) . '/web/index-test.php');
// Define our application_env variable as provided by nginx/apache
if (!defined('APPLICATION_ENV'))
{
if (getenv('APPLICATION_ENV') != false)
define('APPLICATION_ENV', getenv('APPLICATION_ENV'));
else
define('APPLICATION_ENV', 'dev');
}
$env = require(__DIR__ . '/../../config/env.php');
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', $env['debug']);
defined('YII_ENV') or define('YII_ENV', APPLICATION_ENV);
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
$config = require(__DIR__ . '/../../config/web.php');
$_SERVER['SCRIPT_FILENAME'] = YII_TEST_ENTRY_FILE;
$_SERVER['SCRIPT_NAME'] = YII_TEST_ENTRY_URL;
$_SERVER['SERVER_NAME'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_HOST);
$_SERVER['SERVER_PORT'] = parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PORT) ?: '80';
Yii::setAlias('#tests', dirname(__DIR__));
(new yii\web\Application($config));
When I run my $ ./vendor/bin/codecept run. I get the above error.
So the parse_url line i.e. the 4th line is breaking the code. Can anyone help me out in this, trying to solve it from past 6 hrs or so.. Thanks in advance
Codeception.yml
actor: Tester
#coverage:
# #c3_url: http://localhost:8080/index-test.php/
# enabled: true
# #remote: true
# #remote_config: '../tests/codeception.yml'
# white_list:
# include:
# - ../models/*
# - ../controllers/*
# - ../commands/*
# - ../mail/*
# blacklist:
# include:
# - ../assets/*
# - ../config/*
# - ../runtime/*
# - ../vendor/*
# - ../views/*
# - ../web/*
# - ../tests/*
paths:
tests: codeception
log: codeception/_output
data: codeception/_data
helpers: codeception/_support
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
memory_limit: 1024M
log: true
colors: true
config:
# the entry script URL (with host info) for functional and acceptance tests
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
test_entry_url: http://localhost:8080/index-test.php
functional.suite.yml
class_name: FunctionalTester
modules:
enabled:
- Filesystem
- Yii2
config:
Yii2:
configFile: 'codeception/config/functional.php'
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH));
Change the above line to the code mentioned below
defined('YII_TEST_ENTRY_URL') or define('YII_TEST_ENTRY_URL', 'http://test.qsims.com/web/index-test.php');
For some reason it was not retrieving my url form codeception.yml form so I have hardcorded the url in the place of parse_url(\Codeception\Configuration::config()['config']['test_entry_url'], PHP_URL_PATH))to actual url :'http://test.qsims.com/web/index-test.php'
Related
I'm trying to implement vue-monaco, but I get these errors:
ERROR Failed to compile with 2 errors 4:59:58 PM
error in ./node_modules/monaco-editor/esm/vs/basic-languages/_.contribution.js
Module parse failed: Unexpected token (37:13)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| return lazyLanguageLoaders[languageId];
| }
> _languageId;
| _loadingTriggered;
| _lazyLoadPromise;
# ./node_modules/monaco-editor/esm/vs/basic-languages/typescript/typescript.contribution.js 9:0-56 10:0-16
# include-loader!./node_modules/vue-monaco/node_modules/monaco-editor/esm/vs/editor/editor.main.js
# ./node_modules/vue-monaco/dist/vue-monaco.es.js
# ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://X.X.X.X:8081&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
error in ./node_modules/monaco-editor/esm/vs/language/typescript/monaco.contribution.js
Module parse failed: Unexpected token (76:15)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| })(ModuleResolutionKind || {});
| var LanguageServiceDefaultsImpl = class {
> _onDidChange = new monaco_editor_core_exports.Emitter();
| _onDidExtraLibsChange = new monaco_editor_core_exports.Emitter();
| _extraLibs;
# include-loader!./node_modules/vue-monaco/node_modules/monaco-editor/esm/vs/editor/editor.main.js 101:0-92
# ./node_modules/vue-monaco/dist/vue-monaco.es.js
# ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue?vue&type=script&lang=js&
# ./src/views/PlaygroundView.vue
# ./src/router/index.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://X.X.X.X:8081&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
I think these issues are related to my vue.config.js; this is it:
const MonacoEditorPlugin = require('monaco-editor-webpack-plugin')
module.exports = {
transpileDependencies: [
'vuetify'
],
configureWebpack: {
plugins: [
new MonacoEditorPlugin({
languages: ['javascript', 'typescript']
})
],
},
}
Component implementation is almost identical to the guide. The guide seems pretty straightforward, so what am I doing wrong?
P.S. I even tried monaco-editor-vue, but I got almost the same errors.
To make it work I had to downgrade monaco-editor-webpack-plugin to 1.9.1; related link here. Note that typescript language is also needed, even though you want only javascript; related link here.
With a ezPlatform 2.5 project (based on Symfony 3.4) i need to import and convert some images. I'm using version 2.2.0 of LiipImagineBundle
I store my images in directories : "web/images/typeA/", "web/images/typeB/" etc...
Here's my configuration :
liip_imagine:
resolvers:
default:
web_path:
web_root: "%kernel.project_dir%/web"
cache_prefix: "media/cache"
loaders:
default:
filesystem:
data_root: "%kernel.root_dir%/../web"
# - "%kernel.project_dir%/web"
# - "%kernel.project_dir%/web/images"
driver: gd
data_loader: default
cache: default
filter_sets:
# list of filters...
Directories "web/images" and subfolders are created by a symfony command (sources files are imported from NFS). So, if they aren't created yet, i've have the error :
In FileSystemLocator.php line 52:
Source image not resolvable "/path/to/project/www/web/images/typeA/image.jpg" in
root path(s) "/path/to/project/www/web"
I had the error, and I solved it by setting the following in config/packages/liip_image.yaml:
liip_imagine :
resolvers :
default :
web_path : ~
loaders:
default:
filesystem:
data_root: "/" # <-- This setting
thank you for your answer. I've fixed it like this :
liip_imagine:
driver: "%liip_imagine_driver%"
resolvers:
default:
web_path:
web_root: "%kernel.project_dir%/web"
cache_prefix: assets/media/cache
loaders:
default:
filesystem:
data_root:
- "%kernel.root_dir%/../web"
I am having trouble to follow the doc in https://codeception.com/docs/modules/Doctrine2. This the error
[ModuleException] Doctrine2: Module can't be accessed
I want to access $entityManger in the unit test. The doctrine bootstrap.php have a createEntityManager function that returns entityManager.
#codeception.yml
suites:
unit:
path: .
actor: UnitTester
modules:
enabled:
# add more modules here
- Asserts
settings:
bootstrap: ../config/bootstrap.php
shuffle: true
lint: true
paths:
tests: tests
output: tests/_output
support: tests/_support
data: tests
# unit.suite.yml
actor: UnitTester
modules:
enabled:
- Asserts
- Doctrine2:
connection_callback: ['createEntityManager']
cleanup: true # All doctrine queries will be wrapped in a transaction, which will be rolled back at the end of each test
- \Helper\Unit
Your problem is that you have unit suite configured in codeception.yml file, so your unit.suite.yml is ignored.
Remove this section from codeception.yml or remove unit.suite.yml and update codeception.yml
suites:
unit:
path: .
actor: UnitTester
modules:
enabled:
# add more modules here
- Asserts
Whenever I install a new package via npm install my angular 2 import is not recognizing the package and my browser returns 404 error.
For example, I've been trying to install the following package:
https://github.com/dougludlow/ng2-bs3-modal
and this is what my browser returns:
GET http://localhost:3000/node_modules/ng2-bs3-modal/ng2-bs3-modal 404 (Not Found)fetchTextFromURL # system.src.js:1154(anonymous function) # system.src.js:1710ZoneAwarePromise # angular2-polyfills.js:589(anonymous function) # system.src.js:1709(anonymous function) # system.src.js:2734(anonymous function) # system.src.js:3308(anonymous function) # system.src.js:3575(anonymous function) # system.src.js:3960(anonymous function) # system.src.js:4419(anonymous function) # system.src.js:4671(anonymous function) # system.src.js:406ZoneDelegate.invoke # angular2-polyfills.js:332Zone.run # angular2-polyfills.js:227(anonymous function) # angular2-polyfills.js:576ZoneDelegate.invokeTask # angular2-polyfills.js:365Zone.runTask # angular2-polyfills.js:263drainMicroTaskQueue # angular2-polyfills.js:482ZoneTask.invoke # angular2-polyfills.js:434
angular2-polyfills.js:332 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-bs3-modal/ng2-bs3-modal(…)
Although I can see that node_modules\ng2-bs3-modal is existing.
What's wrong here?
You need to configure SystemJS to load right files from the library.
You could try the following configuration:
<script>
System.configure({
map: {
'ng2-bs3-modal': 'node_modules/ng2-bs3-modal'
},
packages: {
'ng2-bs3-modal': {
format: 'register',
defaultExtension: 'js'
}
}
});
(...)
</script>
I am having such behat.yml
default:
autoload:
#'': %paths.base%/tests/AppBundle/features/user_registration/bootstrap
#'': %paths.base%/tests/AppBundle/features/user_login/bootstrap
[ %paths.base%/tests/AppBundle/features/user_registration/bootstrap, %paths.base%/tests/AppBundle/features/user_login/bootstrap ]
formatters:
progress: ~
suites:
app_features:
#paths:
#features: %paths.base%/tests/AppBundle/features
paths: [ %paths.base%//tests/AppBundle/features ]
contexts:
#- tests\AppBundle\user_registration\UserRegistrationContext
- UserRegistrationContext
- UserLoginContext
#suites:
# default:
# contexts:
# - FeatureContext:
# session: '#session'
extensions:
Behat\Symfony2Extension: ~
Also having this folder structure:
With UserRegistrationContext class its ok, it does not throw errors. Then I added UserLoginContext and it cannot find.
I am using "behat/behat": "^3.1" in composer.json.
behat.yml file is in same level as 'tests' directory.
UserLoginContext looks like this:
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Behat\Behat\Context\Context;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Driver\GoutteDriver;
use Behat\Mink\Session;
use AppBundle\Controller\UserController;
/**
* Defines application features from the specific context.
*/
class UserLoginContext implements Context, SnippetAcceptingContext
{
private $session;
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct()
{
// Choose a Mink driver. More about it in later chapters.
$driver = new GoutteDriver();
$this->session = new Session($driver);
}
}
Why the UserLoginContext is not found?
Update
I noticed that if I do like this - leave one contexts, then UserLoginContext is found:
default:
autoload:
#'': %paths.base%/tests/AppBundle/features/user_registration/bootstrap
'': %paths.base%/tests/AppBundle/features/user_login/bootstrap
#[ %paths.base%/tests/AppBundle/features/user_registration/bootstrap, %paths.base%/tests/AppBundle/features/user_login/bootstrap ]
formatters:
progress: ~
suites:
app_features:
#paths:
#features: %paths.base%/tests/AppBundle/features
paths: [ %paths.base%//tests/AppBundle/features ]
contexts:
#- tests\AppBundle\user_registration\UserRegistrationContext
#- UserRegistrationContext
- UserLoginContext
#suites:
# default:
# contexts:
# - FeatureContext:
# session: '#session'
extensions:
Behat\Symfony2Extension: ~
Update
Temporary solution I found - to create a new profile for each context. But I guess its not how it should be, but still will show how I have done:
user_login:
autoload:
'': %paths.base%/tests/AppBundle/features/user_login/bootstrap
formatters:
progress: ~
suites:
app_features:
paths: [ %paths.base%//tests/AppBundle/features ]
contexts:
- UserLoginContext
extensions:
Behat\Symfony2Extension: ~
And then run with --profile parameter:
sudo vendor/behat/behat/bin/behat --profile user_login
The small problem is that when I will want to run all tests, I will have to run many commands. Also config repetition. Still waiting for better solution.
Here I noticed small text which helped a bit.
http://docs.behat.org/en/v3.0/guides/6.profiles.html
Using behat.yml to autoload will only allow for PSR-0. You can also
use composer.json to autoload, which will also allow for PSR-4
Shame for behat - they really would need to write more about this, cause new user would not understand at all how to use it together with composer.json.
What I have done:
added namespace for the UserLoginContext class same as folder structure
namespace Tests\AppBundle\features\user_login\bootstrap;
Added this namespace to behat.yml near contexts:
.
# for each context class - new profile.
default:
autoload:
'': %paths.base%/tests/AppBundle/features/user_registration/bootstrap
formatters:
progress: ~
suites:
app_features:
#paths:
#features: %paths.base%/tests/AppBundle/features
paths: [ %paths.base%//tests/AppBundle/features ]
contexts:
- UserRegistrationContext
- Tests\AppBundle\features\user_login\bootstrap\UserLoginContext
#suites:
# default:
# contexts:
# - FeatureContext:
# session: '#session'
extensions:
Behat\Symfony2Extension: ~
Also those who have not in their composer.json, need to add this:
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
Ran
composer dump-autoload -o
I am lucky that I have experience with PSR-4 and could guess the solution and that I had time to think and experiment.