Notice: You are browsing the documentation for PrestaShop 9, which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8. Read the current version of this page
Unit tests are great if you want to validate the behavior of a single unit of code. By “unit of code” we usually mean a class although it could also be a script.
Everything is explained in the PHPUnit 5.7 documentation.
For unit tests, we strongly encourage you to base your test on the PHPUnit’s TestCase
class only.
For instance:
<?php
namespace Tests\Unit\Foo;
use PHPUnit\Framework\TestCase;
class BarTest extends TestCase
{
/* ... */
}
Unit tests should be located into tests/Unit
folder and follow the same path as the tested class: if a class is located into src/Core/Foo/Baz
, the unit test should be into tests/Unit/Core/Foo/Baz
folder.