Codeception C3 configuration for coverage using webDriver - phpunit

Here's what I did:
Added c3.php in root
app_code
├── c3.php
└── index.php
Included c3.php in index.php
<?php
include 'c3.php';
//some other includes
?>
Enabled coverage in codeception.yml
coverage:
enabled: true
remote: false
c3_url: http://mylocalenv.mine
Webdriver config in acceptance.yml
config:
WebDriver:
url: http://mylocalenv.mine
xdebug remote is on
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => /logs/xdebug.log => /logs/xdebug.log
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
I did the chmod for output
This is report I get
Did I miss anything?

Related

Why is Oneup/UploaderBundle so slow to upload a 'big' file (1GB)?

In a Symfony project, I have implemented the Oneup/UploaderBundle with the Oneup/FlysystemBundle to upload files to a S3 compatible storage.
I tried to upload a 1GB file, and it took about 3 min using the Aws\S3\S3Client adapter (https://flysystem.thephpleague.com/docs/adapter/aws-s3-v3/), which is way too slow.
oneup_uploader.yaml :
object_scaleway_sync:
frontend: dropzone
storage:
type: flysystem
filesystem: oneup_flysystem.object_scaleway_sync_filesystem
oneup_flysystem.yaml :
oneup_flysystem:
adapters:
xxx_fr_sync.flysystem_adapter:
awss3v3:
client: xxx_fr.sync_s3_client
bucket: 'xxxtest'
prefix: ''
filesystems:
object_scaleway_sync:
adapter: xxx_fr_sync.flysystem_adapter
After that, I tried to upload the same file using directly the S3Client in a controller, and it took about 98 seconds, which is faster, but still too slow for 1GB.
MainController.php :
$client = new S3S3Client([
'region' => 'fr-par',
'endpoint' => 'https://s3.fr-par.scw.cloud',
'version' => 'latest',
'credentials' => [
'key' => 'publickey',
'secret' => 'secretkey'
]
]);
$pathToFile = $this->getParameter('kernel.project_dir') . '/public/big.bin';
$resource = \fopen($pathToFile, 'r');
$result = $client->putObject([
'Bucket' => 'xxxtest',
'Key' => 'big.bin',
'Body' => $resource
]);
return new Response("Ok");
Strangely, this simple plain php script below took 28 seconds to upload the same file :
$s3 = new Aws\S3\S3Client([
'region' => 'fr-par',
'version' => 'latest',
'endpoint' => 'https://s3.fr-par.scw.cloud',
'credentials' => [
'key' => "publickey",
'secret' => "secretkey",
]
]);
$result = $s3->putObject([
'Bucket' => 'xxxtest',
'Key' => 'big.bin',
'SourceFile' => './big.bin'
]);
Why is this script faster than the Symfony method ? Is there a way to optimize the upload speed ?
I tried using the async S3 Simple Client (https://async-aws.com/integration/simple-s3.html) but it returned the error "Could not contact remote server" at the end of the upload.
Same error with the async S3Client (https://async-aws.com/clients/s3.html).

Codeception fails with Message 'An option named "config" already exists.'

Running Codeception 2.4.5 in a php Webproject on Ubuntu, where codeception is installed via composer
==== Redirecting to Composer-installed version in vendor/codeception ====
I get the Error
An option named "config" already exists.
While not finding the cause and the reason for this error, my temporary solution was to empty the /vendor/codeception Directory and run
composer install
This fixed the error. But now I made some changes to my tests, and it reappears.
What can be the reason ?
$: which codecept
/usr/local/bin/codecept
Content of codeception.yml
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
modules:
config:
Db:
dsn: ''
user: ''
password: ''
dump: tests/_data/dump.sql
Content of tests/acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- PhpBrowser
- \Helper\Acceptance
config:
PhpBrowser:
url: 'http://localhost/suite/www/'
Debug Output (Equal with codecept run, bin/codecept run or vendor/codeception/codeception/codecept run)
w#machine:/var/www/_wbs/wbs_suite[master]$ ./vendor/codeception/codeception/codecept run -vvv
In InputDefinition.php line 232:
[Symfony\Component\Console\Exception\LogicException]
An option named "config" already exists.
Exception trace:
Symfony\Component\Console\Input\InputDefinition->addOption() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Input/InputDefinition.php:222
Symfony\Component\Console\Input\InputDefinition->addOptions() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Command/Command.php:306
Symfony\Component\Console\Command\Command->mergeApplicationDefinition() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Command/Command.php:206
Symfony\Component\Console\Command\Command->run() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Application.php:946
Symfony\Component\Console\Application->doRunCommand() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Application.php:248
Symfony\Component\Console\Application->doRun() at /var/www/_wbs/wbs_suite/vendor/symfony/console/Application.php:148
Symfony\Component\Console\Application->run() at /var/www/_wbs/wbs_suite/vendor/codeception/codeception/src/Codeception/Application.php:108
Codeception\Application->run() at /var/www/_wbs/wbs_suite/vendor/codeception/codeception/codecept:42
Debug Output in Symfony/Console/Command/Command.php->mergeApplicationDefinition()
mergeApplicationDefinitionArray
(
[help] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => help
[shortcut:Symfony\Component\Console\Input\InputOption:private] => h
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Display this help message
)
[quiet] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => quiet
[shortcut:Symfony\Component\Console\Input\InputOption:private] => q
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Do not output any message
)
[verbose] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => verbose
[shortcut:Symfony\Component\Console\Input\InputOption:private] => v|vv|vvv
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
)
[version] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => version
[shortcut:Symfony\Component\Console\Input\InputOption:private] => V
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Display this application version
)
[ansi] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => ansi
[shortcut:Symfony\Component\Console\Input\InputOption:private] =>
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Force ANSI output
)
[no-ansi] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => no-ansi
[shortcut:Symfony\Component\Console\Input\InputOption:private] =>
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Disable ANSI output
)
[no-interaction] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => no-interaction
[shortcut:Symfony\Component\Console\Input\InputOption:private] => n
[mode:Symfony\Component\Console\Input\InputOption:private] => 1
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Do not ask any interactive question
)
[config] => Symfony\Component\Console\Input\InputOption Object
(
[name:Symfony\Component\Console\Input\InputOption:private] => config
[shortcut:Symfony\Component\Console\Input\InputOption:private] => c
[mode:Symfony\Component\Console\Input\InputOption:private] => 4
[default:Symfony\Component\Console\Input\InputOption:private] =>
[description:Symfony\Component\Console\Input\InputOption:private] => Use custom path for config
)
)
In InputDefinition.php line 232:
[Symfony\Component\Console\Exception\LogicException]
An option named "config" already exists.
In the codeception Source are several Commands (>10), where the Option 'config' is added to the Command:
new InputOption('config', 'c', InputOption::VALUE_OPTIONAL, 'Use custom path for config')
No Idea, where to reset this and how to avoid the double Option ...

Yii2 module (not under /vendor folder) class not found in config/main.php

I've created a module under folder api (which itself is same level as backend & frontend in yii2 advanced app).
Folder structure:
api
-- common
------ controllers
------ models
-- config
-- modules
------ v1
---------- controllers
---------- models
-- runtime
-- tests
-- web
In api/config/main.php:
return [
'id' => 'app-api',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'modules' => [
'v1' => [
'basePath' => '#app/modules/v1',
'class' => 'api\modules\v1\Module'
]
],
I get error:
ReflectionException
Class api\modules\v1\Module does not exist
The class is definitely there.
I've run a composer dumpautoload (no errors).
urlManager in config/main.php:
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
'v1/site/index' => 'v1/site/index', //module/controller/action
],
]
Any help much appreciated,
thanks
OK got it:
in common/config/bootstrap.php, add:
Yii::setAlias('#api', dirname(dirname(__DIR__)) . '/api');
Then in config/main.php use:
'modules' => [
'v1' => [
'basePath' => '#api/modules/v1',
'class' => 'api\modules\v1\Module'
]
],
This seems to work, thanks guys
Thanks, gvanto. Also check whether you include common/config/bootstrap.php in \api\web\index.php . Like here
<?php
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require(__DIR__ . '/../../vendor/autoload.php');
require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
require (__DIR__ . '/../../common/config/bootstrap.php');
$config = yii\helpers\ArrayHelper::merge(
require(__DIR__ . '/../../common/config/main.php'),
require(__DIR__ . '/../../common/config/main-local.php'),
require(__DIR__ . '/../config/main.php'),
require(__DIR__ . '/../config/main-local.php')
);
$application = new yii\web\Application($config);
$application->run();
that was my mistake. Maybe it will help someone

Yii2 console script not working

I want to automatically download my database backup weekly. I'm using xampp on windows. I've google around and found that I've to make use of windows task scheduler and the action script in my console controller. I've read this and this and tried running the command from command prompt. I'm getting 'Unknown command'.
My code in console controller for now just for testing
<?php
namespace console\controllers;
use Yii;
use yii\console\Controller;
/**
* Cron controller
*/
class TestController extends Controller {
public function actionIndex() {
echo "cron service runnning";
}
}
And my main config file
<?php
$params = array_merge(
require(__DIR__ . '/../../common/config/params.php'),
require(__DIR__ . '/../../common/config/params-local.php'),
require(__DIR__ . '/params.php'),
require(__DIR__ . '/params-local.php')
);
return [
'id' => 'app-console',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'controllerNamespace' => 'console\controllers',
'components' => [
'log' => [
'targets' => [
[
'class' => 'yii\log\FileTarget',
'levels' => ['error', 'warning'],
],
],
],
'authManager' => [
'class' => 'yii\rbac\DbManager',
],
],
'modules' => [
'rbac' => [
'class' => 'johnitvn\rbacplus\Module'
]
],
'params' => $params,
];
The error I'm getting
Make sure you have TestController.php file in console/controllers folder and its name is written correctly.
Then from project root folder you can call your command like that:
php yii test/index
or just:
php yii test
(because index is a default action (configured in $defaultAction) and you can omit it).
If you are outside of project folder, make sure to provide correct path:
php /path/to/project/folder/yii test

Migrate Drupal site from XAMPP to MAMP

I created a Drupal website in a XAMPP environment, but would like to further develop it in a MAMP environment. That is, without losing all the content I already added. I changed the settings.php file like this
$databases = array (
'default' =>
array (
'default' =>
array (
'database' => 'drupal',
'username' => 'root',
'password' => 'root',
'host' => 'localhost:8889',
'port' => '',
'driver' => 'mysql',
'prefix' => '',
),
),
);
But I get the error:
PDOException: SQLSTATE[HY000] [2005] Unknown MySQL server host 'localhost:8889' (2) in lock_may_be_available() (line 164 of /Applications/MAMP/htdocs/kooknet2/includes/lock.inc).
Does anyone know how I can solve this? Thanks!
It's a tiny error, you've got the port as part of your host string (:8889) when you should be adding it to the array key that actually says port. Try this:
$databases = array (
'default' => array (
'database' => 'drupal',
'username' => 'root',
'password' => 'root',
'host' => 'localhost',
'port' => '8889',
'driver' => 'mysql',
'prefix' => '',
),
),
);
If you have local MySQL server, login to it from console, check user-pass-port. It see,s you haven't MySQL instance on 8899 port
I would suggest using the backup and migrate module to grab a copy of your database. Then setup your site on mamp (with a new db/install), and use BAM to restore from your backup.
If you're using the same file path, there shouldn't be any other steps to worry about otherwise you might need to copy/move your files directory and also reconfigure your file path settings in the drupal interface. (Also you may need to be aware that any links to internal content that is embedded in your node body may also need to be adjusted so the path is correct)

Resources