How to unittest symfony2 core - php

After a fresh symfony2 install i can run phpunit -c app/ and phpunit tests the included demo application: OK (1 test, 1 assertion).
But i receive no output (even with verbosity) when i run phpunit -c vendor/symfony/ as described here: http://symfony.com/doc/2.0/contributing/code/tests.html.
Does anyone know how to make this work?
PHPUnit: 3.6.2
PHP: 5.3.8
Symfony: 2.0.5
Testing twig, doctrine and other plugins works as expected (although doctrine tests fail for some reason).

If you have no output it's maybe because you configured php not to display errors.
You must install the vendors using the vendors.php script before lauching the Symfony test suite:
$ php vendor/symfony/vendors.php

Are you running the tests using the provided phpunit.xml.dist configuration file?
From your projects root directory:
$ phpunit --configuration app/phpunit.xml.dist vendor/symfony/tests
That should add an autoloader for vendors.

Related

How to run phpunit in laravel 5.5

I have a problem running phpunit in my laravel 5.5. I already go to vendor/bin and then execute phpunit using my command prompt in windows. But cmd just give another option or flag as shown in the picture below :
I have read laravel 5.5 documentation for unittest. It's said that we just need to execute phpunit {as shown in https://laravel.com/docs/5.5/testing}
Then I tried this :
How to run single test method with phpunit?
phpunit --filter testBasicTest tests\Unit\ExampleTest
As shown below :
BUt it's said that 'cannot open the file'. Then I Tried
phpunit ExampleTest, but still cannot open the file. So what's wrong here...?
Thanks in advance
Note :
Here's my phpunit.xml :
You need to run phpunit without getting inside the bin folder.
Try this:
vendor/bin/phpunit
This will load your phpunit.xml file. Otherwise it cannot load your configuration file. Unless if you don't give spesific path:
vendor/bin/phpunit --configuration /path/to/laravels/phpunit.xml
Just install phpunit through composer:
composer global require phpunit/phpunit
then all you are set to test your laravel project.

Travis CI & Symfony2 integration .travis.yml issue

I am trying to sync my Symfony2 project with Travis CI. I followed all the instructions and managed to set everything up correctly. My final hurdle is .travis.yml file which i have added under the root directory of Symfony project.
Content of my .travis.yml file:
php:
- 5.4
script:
- ./binphpunit -c app
notifications:
email:
- myemail#gmail.com
My phpunit is installed under bin/phpunit as binary
Error log:
/usr/bin/env: php No such file or directory
The command "./bin/phpunit -c app" exited with 127
Probably you miss the language specification. Try putting this:
language: php
as first line.
Double check the phpunit travis configuration, probably simply without any path.
Check an example here
Hope this help

Laravel 4 phpunit is doing nothing

I am trying to run the default testcase of laravel 4 for an app. Phpunit works when I explicitly mention the testfile path but doesn't seem to work otherwise, furthermore it returns 255 code when I try to run Phpunit only.
Any idea?
Checkout your phpunit.xml file, there you will find bootstrap path to autoloader.
Are you using global PHPUNit framework or you are using local (installed with composer) ?
I created my vim mapping so it is pointing always to current file:
nmap ,t :!clear && phpunit %<esc>

Running PHP Unit from Terminal - just not working

I have installed PHP Unit and done everything the instructions tell me.
I'm told that I can just run:
$ phpunit
...and it will work. I may need to specify the config file and I can do that.
I have changed the directory to the PHP Unit folder, but nothing.
I am using Mac's Terminal if this means anything.
I have tried (with the error shown):
$ phpunit - $: command not found
phpunit - phpunit: command not found
php phpunit - ...doesn't return an error, but doesn't do return anything
% phpunit - fg: %: no such job
Also, the folder structure is like this:
- phpunit
- php-code-coverage
- php-file-iterator
- php-text-template
- php-timer
- php-token-stream
- phpunit
- phpunit-mock-objects
phpunit.php
- PHPUnit (folder)
- various things inside
... what am I actually running? The outer folder, inner folder or the phpunit.php file?
I must be doing something wrong?
My question: How'd you install PHPUnit? By "hand" (download it and just unzip it), via PEAR, ...?
Try executing (inside the phpunit folder):
./phpunit
Make sure the path where the phpunit executable lies is added to your $PATH variable.
A similiar question on SO on how to install phpunit can be found here, general installation instructions here.

Zend Studio 10 and PHPUnit from Composer

I have a project that uses Composer to manage it's dependencies; one of them being PHPUnit.
To run my project's test suite, I run the following command on the terminal:
bin/phpunit -c tests/
Using the binary from the Composer PHPUnit version and setting the configuration file to be loaded from the tests/ directory.
It runs perfectly.
With Zend Studio 10 (BETA), though, I can't configure my project to run the tests the same way but inside the IDE.
Is there anyway to do that?

Categories