Behatch context not loading - behat

I'm running Behat + Mink and now I want to use the behatch context. So I added the behatch_context.phar to my project and also to my behat.yml file like this: behatch_contexts.phar: ~
But when running Behat I get the following error:
PHP Warning: require(behatch_contexts.phar): failed to open stream:
No such file or directory in
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Extension/ExtensionManager.php
on line 112 PHP Stack trace: PHP 1. {main}()
/usr/local/share/php/Behat/vendor/behat/behat/bin/behat:0 PHP 2.
Symfony\Component\Console\Application->run()
/usr/local/share/php/Behat/vendor/behat/behat/bin/behat:32 PHP 3.
Behat\Behat\Console\BehatApplication->doRun()
/usr/local/share/php/Behat/vendor/symfony/console/Symfony/Component/Console/Application.php:121
PHP 4. Behat\Behat\Console\BehatApplication->createCommand()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:66
PHP 5. Behat\Behat\Console\BehatApplication->createContainer()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:80
PHP 6. Behat\Behat\Console\BehatApplication->loadCoreExtension()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:93
PHP 7. Behat\Behat\DependencyInjection\BehatExtension->load()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Console/BehatApplication.php:165
PHP 8. Behat\Behat\Extension\ExtensionManager->activateExtension()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/DependencyInjection/BehatExtension.php:63
PHP 9. Behat\Behat\Extension\ExtensionManager->initializeExtension()
/usr/local/share/php/Behat/vendor/behat/behat/src/Behat/Behat/Extension/ExtensionManager.php:42
I have tried to require the phar in my FeatureContext but that doesn't do much.
Any idea's would be appreciated.

Related

ioncube_loader Issue: undefined symbol: zend_execute_ex

I have been struggling with the above problem for days. I need the ioncube_loader for my Shopware (version 5.3.2 with PHP version 7.1.8). The server on which Shopware runs has PHP version 5.6.40!
Inside the shop I am told that I am using the ionCube Loader but when I log in to the server via SSH the error occurs.
The following outputs are available for the following commands in the console:
PHP Version
[root#vh1 ~]# php -v
Failed loading /usr/lib64/php/modules/ioncube_loader_lin_7.1.so: /usr/lib64/php/modules/ioncube_loader_lin_7.1.so: undefined symbol: zend_execute_ex
PHP 5.4.16 (cli) (built: Oct 30 2018 19:30:51)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
extension_dir
[root#vh1 ~]# php -i | grep extension_dir
Failed loading /usr/lib64/php/modules/ioncube_loader_lin_7.1.so: /usr/lib64/php/modules/ioncube_loader_lin_7.1.so: undefined symbol: zend_execute_ex
extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules
PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in Unknown on line 0
sqlite3.extension_dir => no value => no value
set include
; Enable ioncube extension module
zend_extension = /usr/lib64/php/modules/ioncube_loader_lin_7.1.so
Can someone tell me what I did wrong? I can not find anything about the bug about Google.
undefined symbol: zend_execute_ex
Why zend_execute_ex? Where does it come from? Can the error occur due to the permissions?
[root#vh1 ~]# ll /usr/lib64/php/modules/
total 8940
-rwxr-xr-x 1 root root 1500368 16. Jul 11:11 ioncube_loader_lin_5.6.so
-rwxr-xr-x 1 root root 1366576 11. Jun 15:33 ioncube_loader_lin_7.1.so
EDIT:
As soon as I open the plugin manager in the backend of Shopware I get the following error:
The file /path/to/shop/engine/Shopware/Plugins/Community/Frontend/CoeVoucherUrl
/Bootstrap.php was encoded by the ionCube Encoder
for PHP 5.6 and cannot run under PHP 7.1 or later.
Please ask the of the script to provide a version
encoded with the ionCube Encoder for PHP 7.1.
File:Unknown
The ioncube-version you are using is for php 7.1 and not for php 5.6. When using PHP 5.6 you need the ioncube_loader_lin_5.6.so. It's provided with the current loader-packages as well. You need to make sure the loader version is compatible with your php-version. The error message already states, that you are using the encoder for php 7.1.
On most servers php versions are different between CLI and Web, so you need to make sure the CLI is using the same version as the webserver and the ioncube version is compatible with it. Sometimes there are possibilities to call different php versions via cli by adding the version number (like php7.1 ...).
On to of that, you can't use any plugin from the shopware store that is encrypted with php 7.1+, since the encryption of the store only supports 5.6 and 7.0. If you want to use php 7.1, you need to make sure there are no encrypted plugins in your system. In this case the plugin manager will work again.
https://docs.shopware.com/en/shopware-5-en/update-guides/update-guide-shopware-55#but-i-still-have-encrypted-plugins

PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0

Ubuntu 16.04
PHP 7.0.4
Phalcon 2.1.x
Zephir
$~: php -v
PHP Fatal error: Class 'jsonserializable' not found in Unknown on line 0
When add phalcon.so in php.ini
Somehow I found the answer on and old bug report here:
Segmentation fault after update to 2.1.x
The problem is that the phalcon extension is being loaded before the json extension, so I guess that you, as myself, added the extension=phalcon.so line in the main php.ini
What you have to do is add a file in /etc/php/7.0/mods-available called phalcon.ini with the line in it: extension=phalcon.so
Then you just go and make a softlink that points from /etc/php/7.0/cli/conf.d/50-phalcon.ini to that phalcon.ini file, (important to put a number higher than 20 so it gets loaded after the json extension) and that's it!
Repeat the process to any other configuration that you have for php (apache, nginx, etc).

Where comes this Fatal error from? cakephp phpunit

I created a cakephp3 project with composer.
composer create-project --prefer-dist cakephp/app foobar
Then, I baked a helper with
bin/cake bake helper Progress
And copypasted the helper-example in the cakephp testing tutorial
Switching in the directory and performing phpunit says
PHP Fatal error: Class Cake\TestSuite\Fixture\FixtureInjector contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addWarning) in /home/matthias/www/isbn.localhost/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 173
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:42
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:138
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:186
PHP 5. PHPUnit_TextUI_TestRunner->handleConfiguration() /home/matthias/www/foobar/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:145
PHP 6. require_once() /home/matthias/www/foobar/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:771
Fatal error: Class Cake\TestSuite\Fixture\FixtureInjector contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addWarning) in /home/matthias/www/foobar/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php on line 173
Call Stack:
0.0001 225152 1. {main}() /usr/bin/phpunit:0
0.0031 515440 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:42
0.0031 516064 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:138
0.6384 6931096 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:186
0.6384 6932312 5. PHPUnit_TextUI_TestRunner->handleConfiguration() /home/matthias/www/foobar/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:145
0.6458 7043088 6. require_once('/home/matthias/www/foobar/vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php') /home/matthias/www/foobar/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:771
Doesn't matter if the global installed phpunit 4.2.6 or the latest version, installed with composer, is used. Where comes this from and how to can I fix this?
Thanks a lot!
Do not use a global PHPUnit installation when you have one that is local to your CakePHP installation, as you can see this will conflict, look at the stacktrace, you're starting in /usr/bin/phpunit, and then it jumps into /home/matthias/www/foobar/vendor/phpunit/phpunit/....
That being said, you seem to have installed the "wrong" PHPUnit version in your CakePHP app, the mentioned method addWarning was introduced with PHPUnit 5.1 alpha! The whole 5.x branch is not yet stable, and CakePHP is not yet compatible to it was just recently updated (not yet released) to support the changes, so for now you should install the stable 4.x branch instead, like
$ composer require --dev phpunit/phpunit:~4.0
Unfortunately the prefer-stable option (which is by default set to true in the CakePHP app skeletons composer.json) doesn't seem to help here, as Composer will choose ~5.1#dev when not specifying a version on your own (even if it's just *).

yii2-advanced-template and phpStorm tests

Question: How do I setup codecetion tests in phpStorm 9 for the yii2-advanced-template?
Codeception is setup properly and when I go to the /tests/ folder and run codecept run then everything works perfectly fine, and all tests are executed.
But I can't get it to run in phpStom:
Under Settings->Language and Frameworks->PHP->PHPUnit I have set:
.) custom autoloader pointing to the autoload.php under vendor
.) no default config
.) no bootstrap file
And in Run/Debug Configuration I have used the Dictionary option with the /tests/ folder.
When I execute this with the Debug button I get:
/Applications/XAMPP/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9000 -dxdebug.remote_host=127.0.0.1 /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php --no-configuration /path/to/root/tests/
Testing started at 19:41 ...
Fatal error: Class 'tests\codeception\common\algorithm\DbTestCase' not found in /path/to/root/tests/codeception/common/algorithm/ObjectTest.php on line 23
Call Stack:
0.1083 357832 1. {main}() /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:0
0.1313 983624 2. IDE_Base_PHPUnit_TextUI_Command::main(???) /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:552
0.1313 989640 3. PHPUnit_TextUI_Command->run(???, ???) /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:294
0.1372 1233680 4. PHPUnit_Runner_BaseTestRunner->getTest(???, ???) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/TextUI/Command.php:146
0.1827 1430624 5. PHPUnit_Framework_TestSuite->addTestFiles(???) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Runner/BaseTestRunner.php:96
0.1827 1431896 6. PHPUnit_Framework_TestSuite->addTestFile(???, ???) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Framework/TestSuite.php:419
0.1844 1527936 7. PHPUnit_Util_Fileloader::checkAndLoad(???) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Framework/TestSuite.php:358
0.1845 1528152 8. PHPUnit_Util_Fileloader::load(???) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Util/Fileloader.php:79
0.1861 1710880 9. include_once('/Users/jareiter/Tabbie2/tabbie2.git/tests/codeception/common/algorithm/StrictWUDCRulesTest.php') /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Util/Fileloader.php:95
PHP Fatal error: Class 'tests\codeception\common\algorithm\DbTestCase' not found in /Users/jareiter/Tabbie2/tabbie2.git/tests/codeception/common/algorithm/StrictWUDCRulesTest.php on line 23
PHP Stack trace:
PHP 1. {main}() /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:0
PHP 2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*) /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:552
PHP 3. PHPUnit_TextUI_Command->run($argv = *uninitialized*, $exit = *uninitialized*) /private/var/folders/lz/s7xjwdbx6bxdxhmzr31c26580000gn/T/ide-phpunit.php:294
PHP 4. PHPUnit_Runner_BaseTestRunner->getTest($suiteClassName = *uninitialized*, $suiteClassFile = *uninitialized*) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/TextUI/Command.php:146
PHP 5. PHPUnit_Framework_TestSuite->addTestFiles($filenames = *uninitialized*) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Runner/BaseTestRunner.php:96
PHP 6. PHPUnit_Framework_TestSuite->addTestFile($filename = *uninitialized*, $phptOptions = *uninitialized*) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Framework/TestSuite.php:419
PHP 7. PHPUnit_Util_Fileloader::checkAndLoad($filename = *uninitialized*) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Framework/TestSuite.php:358
PHP 8. PHPUnit_Util_Fileloader::load($filename = *uninitialized*) /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Util/Fileloader.php:79
PHP 9. include_once() /Applications/XAMPP/xamppfiles/lib/php/PHPUnit/Util/Fileloader.php:95
Process finished with exit code 255
All files in the log exist!
Codeception framework is not currently supported by Testing subsystem of PhpStorm.
https://youtrack.jetbrains.com/issue/WI-16350 -- watch this ticket (star/vote/comment) to get notified on progress.
You are trying to use PHPUnit integration to run your Codeception tests ... but that will not work like that because IDE uses intermediate helper script that works with PHPUnit directly. As you can see autoloader does not seem to help here...

Fatal error running unit test in Yii app

This Question is local to my situation and not resolved (yet). But if you are experiencing this problem, the trouble shooting steps may give you a good path to start on.
I want to run a unit test in a Yii web application on localhost, which is running via WampServer 2.1 on Windows 7.
<?php
class LittleTest extends CTestCase
{
public function testApprove()
{
$value1 = "1";
$this->assertEquals($value1,$value1);
}
}
?>
I receive a fatal error when I try to run the test. Here is how I run it, on the Windows command line:
C:\wamp\www\app\protected\tests>
C:\wamp\www\app\protected\tests>cd unit
C:\wamp\www\app\protected\tests\unit>phpunit LittleTest.php
I receive (along with some stack trace lines):
PHP Fatal error:
class 'CTestCase' not found in [path to file]\LittleTest.php on line 4
Trouble shooting steps to this point:
The app runs. The default index page of the app looks good and I have used the gii tool to create a model class.
From command line, I can see php and phpunit are available (and I've been over my pear install to make sure it's all good):
C:\wamp\www\app\protected\tests>
C:\wamp\www\app\protected\tests>phpunit --version
PHPUnit 3.7.13 by Sebastian Bergmann.
C:\wamp\www\app\protected\tests>
C:\wamp\www\app\protected\tests>php --version
PHP 5.3.5 (cli)
... etc
display_errors is turned on. display_startup_errors is turned on.
I tried renaming the class so that name did not match the document name:
class LittleTestTweak extends CTestCase
I'm not sure of the precise command that runs the test, so I have tried variants like:
php LittleTest.php
Also I've tried running it various places in the folder structure. Here is the immediate structure:
/tests
| bootstrap.php
| my_tree.txt
| phpunit.xml
| WebTestCase.php
|
|---- /fixtures
|---- /functional
| SiteTest.php
|
|---- /report
`---- /unit
LittleTest.php
I also checked my php.ini for the path to PEAR; as far as I can tell, it's correct (but how can I test it?):
include_path=".;C:\wamp\bin\php\php5.3.5\PEAR;C:\wamp\www\app
More Info
In response to this:
cd wamp\www\app\protected\tests
phpunit unit\LittleTest.php
I receive this:
Warning: require_once(PHPUnit/Extensions/SeleniumTestCase.php):
failed to open stream: No such file or directory in
C:\wamp\www\yii\framework\test\CWebTestCase.php on line 12
Call Stack:
0.0007 339624 1. {main}() C:\wamp\bin\php\php5.3.5\phpunit:0
0.0164 698440 2. PHPUnit_TextUI_Command::main()
C:\wamp\bin\php\php5.3.5\phpunit:46
0.0164 698856 3. PHPUnit_TextUI_Command->run()
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\TextUI\Command.php:129
0.0164 698856 4. PHPUnit_TextUI_Command->handleArguments()
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\TextUI\Command.php:138
0.0289 1220944 5. PHPUnit_TextUI_Command->handleBootstrap()
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\TextUI\Command.php:606
0.0300 1233328 6. PHPUnit_Util_Fileloader::checkAndLoad()
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\TextUI\Command.php:778
0.0330 1233424 7. PHPUnit_Util_Fileloader::load()
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\Util\Fileloader.php:76
0.0334 1238096 8. include_once
('C:\wamp\www\app\protected\tests\bootstrap.php')
C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\Util\Fileloader.php:92
0.0412 1520256 9. require_once
('C:\wamp\www\app\protected\tests\WebTestCase.php')
C:\wamp\www\app\protected\tests\bootstrap.php:8
0.0413 1520520 10. YiiBase::autoload()
C:\wamp\www\yii\framework\YiiBase.php:0
0.0423 1543904 11.
include('C:\wamp\www\yii\framework\test\CWebTestCase.php')
C:\wamp\www\yii\framework\YiiBase.php:395
Fatal error: require_once(): Failed opening required
'PHPUnit/Extensions/SeleniumTestCase.php'
(include_path='.;C:\wamp\bin\php\php5.3.5\PEAR\pear;C:\wamp\bin\php\php5.3.5\pear')
in C:\wamp\www\yii\framework\test\CWebTestCase.php on line 12
Call Stack:
0.0007 339624 1. {main}() C:\wamp\bin\php\php5.3.5\phpunit:0
0.0164 698440 2. PHPUnit_TextUI_Command::main()
...et cetera...
The failed requirement is PHPUnit/Extensions/SeleniumTestCase.php. I wonder if the issue is that PHPUnit is installed locally under C:\wamp.
I opened my php.ini and added to include_path: C:\wamp\bin\php\php5.3.5\PEAR\PHPUnit\Extensions. Restarted wamp. No change in error reporting.
RESOLUTION
My security setup uses DansGuardian and I had neglected to loosen the settings for banned extension types, which blocks file downloads. In fact I don't care to ban any types, and modifying that file allows everything to work. Woops, that's my Linux set. PHPUnit is working there, and it is working on WAMP also. Recreating the steps on WAMP is impossible; but I do know I had to open cmd.exe as administrator and pear update-channels, pear upgrade-all, etc. I also had to clear pear's cache at one point, and I had to overcome an issue with curl recognition to install Selenium:
pear install --force phpunit/PHPUnit_Selenium
To run unit tests in Yii with phpunit, you'll need to let phpunit load the protected/tests/bootstrap.php file which basically sets up a configuration, and autoloads the required classes (mainly pertaining to testing). The bootstrap.php file loads yiit.php which actually autoloads the required classes.
Now we can load all this configuration either by command line options when running phpunit, or let the configuration be read automatically through the protected/tests/phpunit.xml file.
For the latter method, the directory from where phpunit is invoked should have the phpunit.xml file in it, and in Yii default webapp, this directory is protected/tests. Therefore you need to do the following to run your tests:
cd wamp\www\app\protected\tests
phpunit unit\LittleTest.php