PHPUnit needs an absolute path to phpunit.xml - macos

I am trying to use phpunit through the CLI in order to migrate from Netbeans to Sublime Text.
I have the weirdest issue when giving phpunit the path to the phpunit.xml file : it only accepts absolute path et refuses any relative path.
Any relative path given to the phpunit.xml file leads to this error :
Could not read "phpunit.xml"
Example :
Maximes-MacBook-Pro:Frontoffice mbritto$ pwd
/Users/mbritto/Documents/Frontoffice
Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit -c phpunit.xml
Could not read "phpunit.xml".
The phpunit.xml is present in this folder and is readable by my user.
It actually works if I don't give the path to the file :
Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from /Users/mbritto/Documents/Frontoffice/phpunit.xml
#Preparing Application Unit Tests
.^C
Or if I give the absolute path to the file :
Maximes-MacBook-Pro:Frontoffice mbritto$ phpunit -c /Users/mbritto/Documents/Frontoffice/phpunit.xml
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from /Users/mbritto/Documents/Frontoffice/phpunit.xml
#Preparing Application Unit Tests
..^C
I need this in order to use the phpunit plugin in Sublime Text which gives the phpunit.xml file to the command line with the path to the file to test.
My config :
OSX 10.9.1
PHP 5.4.24 (via brew)
PHPUnit 3.7.28 (via brew) (also tested with a phar)
Any idea why it would do that ?

I finally found out what was wrong with my tests; in my bootstrap.php file I was doing this :
chdir(dirname(__FILE__) . "/../src/");
So that classes and autoload would find actual classes that are separated from my test classes.
If I remove this line, the tests crashes because it can't find my classes but at least my tests are executed.
I'll work on the include path rather than changing directory so my tests will be working again.

Related

Is it possible to change the cypress.config.ts/cypress.config.js location instead of have it on the root of the project?

Is a way to change thecypress.config.ts file's location instead of having it in the root of the project along with the package.json, tsconfig.json?
I changed the file (cypress.config.ts) location but it doesn't work I got an error message :
Could not find a Cypress configuration file in this folder:
/Users/Mycomputer/cypressDemoPomExample
I figure out how to fix it
You can simply run the command :
npx cypress open --config-file theNewCypressConfigPath

Generating config file for symmetric-encryption

I'm trying to use symmetric-encryption ina Ruby project but I'm having a hard time to generate the configuration file.
I have tried to use the symmetric-encryption --generate command as stated in the configuration guide but it is not working.
symmetric-encryption: No such file or directory.
I have also tried to install the binstub and run bin/symmetric-encryption --generate --app-name my_app --environments "development,test,preprod,acceptance,production" but I get
Unknown switches '--generate, --app-name, --environments'
Any ideas how to generate the file or where I can get a sample?
Thanks

Launch ClojureScript + ghost script from terminal

I installed phantomjs and casperjs, created a new project with lein new mies casper-ghost and added the [ghost "0.1.0-alpha1] dependency to project.clj.
I then copied over the example code from https://github.com/casperjs/ghost to the core.cljs file and successfully compiled it, with ./scripts/build.
When I try to run it with casperjs out/casper_ghost.js it gives me the error:
ClojureScript could not load :main, did you forget to specify :asset-path?
ReferenceError: Can't find variable: goog
file:///usr/lib/node_modules/casperjs/bin/bootstrap.js:1 in global code
I tried creating a custom build script as follows:
(require 'cljs.build.api)
(cljs.build.api/build "src"
{:main 'hello-world.core
:output-to "out/main.js"})
And ran that successfully with lein -m clojure.main build.clj, but running out/main.js with casperjs would cause the same error.
Can someone point me in the right direction how to run the ghost scripts from the linux terminal?
Making the Google closure compiler write everything into a single file by using :optimizations "simple" to the build options did the trick.

Why does running phpunit not run vendor/bin/phpunit?

I am having a weird issue,
when I run
$ phpunit
I get
Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 185
Call Stack:
0.0009 231392 1. {main}() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:0
0.0065 743872 2. PHPUnit_TextUI_Command::main() /home/vagrant/.composer/vendor/phpunit/phpunit/phpunit:47
0.0066 744512 3. PHPUnit_TextUI_Command->run() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:106
1.1720 6818904 4. PHPUnit_TextUI_TestRunner->doRun() /home/vagrant/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:155
1.4597 16188088 5. PHPUnit_TextUI_ResultPrinter->printResult() /vagrant/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:446
However, when I run
$ ./vendor/bin/phpunit
it works as expected and runs my tests.
Maybe I have another program or something that is using the phpunit alias or something?
How can I debug to find that out?
Any ideas?
Assume you had installed phpunit from composer.json of current Laravel App.
Run this:
vendor/phpunit/phpunit/phpunit
Because the global one might be incompatible version of phpunit. Which is called and execute in the current package.
On windows I have an incompatible version installed globally.
To workaround, create "phpunit.bat" in root of project with contents:
"vendor/bin/phpunit"
This takes precendece over the phpunit in the system path.
How did you configure adding /vendor/bin to path?
I have this in my ~/.bashrc file:
PATH="$PATH:/path/to/vendor/bin"
This adds /vendor/bin/ to the end of your path, so if there is any other executable called phpunit earlier in your path - in your case, the globally installed one - it will be called instead.
To fix this, add vendor/bin to the beginning of your path in ~/.bashrc:
PATH="/path/to/vendor/bin:$PATH"
Then log out and log in or run source ~/.bashrc, and the system should then find /vendor/bin/phpunit first when you runphpunit.
On Windows, you can set an enviroment variable in your project's root directory.
Type this in your console/terminal:
set phpunit=vendor/bin/phpunit
I had the same problem with Laravel and PhpStorm, and after i typed this in my PhpStorm terminal, the problem was solved.
I've just found about about doskeys for Windows. I think they are called aliases on Mac, but they allow you to create a command as an alias for another command.
This way, I can use:
doskey macroName=macroDefinition
which in my case is:
doskey p=.\vendor\bin\phpunit
which then means I can just use the command p from my project folder for phpunit - much quicker!
For example I can now use the command:
p --filter my_single_test tests/MyExampleTest.php

candc:could not open model configuration file for reading:models/config

I installed boxer, tool from C&C to convert CCG to DRS, from http://svn.ask.it.usyd.edu.au/trac/candc/wiki/Installation
System - Windows 7 (64 bit)
But then after installing I am getting following error:
C:\Users\abcd\Documents\candc-1.00\bin>candc.exe --models models
candc:could not open model configuration file for reading:models/config
I did check http://svn.ask.it.usyd.edu.au/trac/candc/wiki/FAQ and I have an empty config file in models directory . But still it doesnt work
Please help me to solve the problem
You are accessing models directory from within the bin directory.
Execute the same command from outside bin .
Try
bin\candc.exe --models models
It should work fine now

Resources