Unit tests with CakePHP 3 and PHPUnit 8 outside project - php

Is there someway to do unit testing in CakePHP 3.x with the latest version of PHPUnit?
Using composer inside the project is limited to PHPUnit version 6.

Related

Testing old PHP versions with PHPUnit 7

I am using Composer for dependencies.
My project's dependencies require PHP 5.5 or later, so I want to test my project on PHP 5.5 - 7.2 (latest) with PHPUnit 7.
I set up Travis CI tests with different PHP versions:
language: php
php:
- '5.5'
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- hhvm # on Trusty only
- nightly
The problem is that the PHPUnit 7 requires PHP 7.1, so I can't test project on PHP 5.5 - 7.0.
I could test old PHP versions with old PHPUnit versions, but the problem is that after PHPUnit 6, PHPUnit's units of code are namespaced, so I will have to write different tests for PHPUnit 4 - 5 and PHPUnit 6 - 7.
How can I test my project on old PHP versions with PHPUnit 7 with Travis CI?
Sebastian Bergmann noticed me that the PHPUnit 4.8 has forward compatibility, so I can use namespace syntax with PHPUnit 4.8, PHPUnit 5.6, PHPUnit 6, and PHPUnit 7.
"the problem is that after PHPUnit 6, PHPUnit's units of code are namespaced, so I will have to write different tests for PHPUnit 4 - 5 and PHPUnit 6 - 7" is not true as PHPUnit 4.8 has the same forward compatibility layer as PHPUnit 5.6. TL;DR: PHPUnit\Framework\TestCase can be used with PHPUnit 4.8, PHPUnit 5.6, PHPUnit 6, and PHPUnit 7. – Sebastian Bergmann
See PHPUnit 4.8 Changelog for details about forward compatibility.

TestCase not found in KernelTestCase.php with Symfony 3.2.7

I'm having problems when running Symfony (PHPUnit integrated) tests in my server, it works as expected in my build host but when I upload them to Gitlab CI via Git it throws me the next error:
Class 'PHPUnit\Framework\TestCase' not found in /project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php on line 24
I tried executing phpunit, phpunit ., phpunit tests all with the same results
It was working until a few weeks ago.
My server Symfony version is 3.2.7 and the PHPUnit version is 4.2.6
PHPUnit version is 4.2.6 is very old, and does not contain any Namespaced classes. The Symfony KernelTestCase.php now uses those PHPUnit namespaces to pull on the TestCase class.
There is forward compatibility in PHPUnit 5.4.3, though v5.7, if not 6.0 would be better.
So, you'll want to upgrade your composer.json file and tests to use the new namespaces.

Unit testing laravel package using jenkins

I have created a package in Laravel 4 and uploaded it to github. How can I automate the unit testing using Jenkins CI as laravel package doesn't have vendor folder pused to github.

Laravel: How to modularize? [duplicate]

php artisan workbench vendor/package --resources
command is not available in laravel 5, but how now create package in laravel 5 ?
Shameless self-promotion, but I've written a post about this called "Creating Laravel 5 packages for dummies" that explains how to create the package, how to put it on GitHub & Packagist and how to push changes/new versions afterwards.
If you're already familiar with creating packages in Laravel 4, the fastest solution I've found was to use this CLI tool.
The laravel workbench has been renamed in laravel 5 to "Package Development" in the documentation
http://laravel.com/docs/master/packages
Notice that there is no longer a workbench command and you need to create your own package structure, as the Laravel creator want to limit the dependency between created packages and the Laravel framework (#ref)
UPDATE: Laravel 5 is now stable and the illuminate/workbench package can be used in a laravel 5 application as I suggested in this post
In Laravel, these are some handy tricks I follow each time I need to create a Laravel package
Solution 1: Get a boilerplate template from https://github.com/cviebrock/laravel5-package-template, and put it under packages/ (follow the instruction in the repo)
Solution 2: Use a packager (with Laravel >= 5.5)
Install packager it as dev dependency > composer require jeroen-g/laravel-packager --dev (check instruction in the repo here)
create the package > composer require jeroen-g/laravel-packager --dev etc, see full tuto
then, we have a choice to keep the package in our project, or just remove it by rollingback composer.json
Hope this is a good update for Laravel lovers ;)

How to unittest symfony2 core

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.

Categories