Top Qs
Chronologie
Chat
Contexte
PHPUnit
framework de test unitaire pour PHP De Wikipédia, l'encyclopédie libre
Remove ads
PHPUnit est un framework open source de tests unitaires dédié au langage de programmation PHP[2].
Remove ads
Il permet l'implémentation des tests de régression en vérifiant que les exécutions correspondent aux assertions prédéfinies.
Remove ads
Historique
Créé par Sebastian Bergmann en 2004, il intègre les concepts communs aux bibliothèques de tests unitaires xUnit. Le code source de PHPUnit est hébergé sur GitHub[2].
Utilisations
- CakePHP depuis la V2
- eZ Components
- Horde 4
- Laravel
- Propel
- Serendipity
- Symfony depuis la V2
- Zend Framework
Exemple
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
class StackTest extends TestCase
{
public function testPushAndPop(): void
{
$stack = array();
$this->assertEquals(0, count($stack));
array_push($stack, 'foo');
$this->assertEquals('foo', $stack[count($stack)-1]);
$this->assertEquals(1, count($stack));
$this->assertEquals('foo', array_pop($stack));
$this->assertEquals(0, count($stack));
}
}
Remove ads
Références
Voir aussi
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads