Write unit tests - Aimeos documentation Skip to content Version Aimeos documentation Version Laravel Laravel Getting started Setup Customize Extend Optimize Create themes TYPO3 TYPO3 Getting started Setup Customize Extend Optimize FAQ User manual User manual Getting started Filtering lists Working with sites Currencies/languages Products Products Available products Product details Categories Categories Manage categories Category details Pricing rules Pricing rules Available rules Rule details Built-in extensions Vouchers/Coupons Vouchers/Coupons Available coupon Coupon details Built-in extensions Payment/Delivery Payment/Delivery Available services Service details Built-in extensions Orders Subscriptions Basket plugins Basket plugins Available plugins Plugins details Development Development Getting started Architecture Create extensions Add translations Git workflow Phing build system Frontend Frontend HTML HTML Theme basics Adapt themes Create new themes Overwrite templates Implement components Extend components Create subparts Account components Basket components Catalog components Checkout components Locale components Adapt price format Parameter names JSON API JSON API Getting started Search basics Catalog handling Basket management Basket products Basket addresses Basket services Basket coupons Order management Customer handling Customer addresses Customer properties Customer relations Customer reviews Get reviews Admin Admin JQAdm backend JQAdm backend Overwrite templates Implement panels Panel templates Create subparts Extend panels Customize JsonAdm API JsonAdm API Overview Retrieve metadata Search and filter Manage resources Manage trees Manage index Error handling Cronjobs Cronjobs Available cronjobs Create job controller Product CSV import Category CSV import Subscription processors Models Models Managing items Filtering items Extend managers Providers Providers Service provider Service provider Basics Payment provider Delivery provider Create decorators Write unit tests Write unit tests Table of contents Test setup Supporting method Get front-end / back-end configuration Check front-end / back-end configuration Check optional methods Test payment processing Direct status update Notification status update Batch status update Test optional methods Basket plugins Coupon provider Pricing rules Infrastructure Infrastructure DI container Cache Database Filesystems Mails Migrations Read/write files View and helpers Configuration Configuration HTML clients HTML clients Account download Account favorite Account history Account profile Account review Account subscription Account watch Basket bulk Basket cache Basket mini Basket related Basket standard Catalog actions Catalog attribute Catalog count Catalog detail Catalog filter Catalog home Catalog lists Catalog partials Catalog price Catalog product Catalog search Catalog selection Catalog session Catalog social Catalog stage Catalog stock Catalog suggest Catalog supplier Catalog tree Checkout confirm Checkout standard Checkout update Common address Common cache Common decorators Common partials Common summary Locale select Supplier detail JSON REST API JSON REST API Common Decorators URL Attribute Basket Catalog Customer Locale Order Product Review Service Site Stock Subscription Supplier Frontend controller Frontend controller Attribute Basket Catalog Common Customer Locale Order Product Review Service Site Stock Subscription Supplier JQAdm backend JQAdm backend Api Dataset Common Partial Permissions Template URL Attribute Catalog Coupon Customer Dashboard Group Locale Log Order Plugin Product Review Rule Service Settings Subscription Supplier Type JsonAdm API JsonAdm API Base Common Decorators Permissions URL Attribute Catalog Coupon Customer Locale Media Order Partials Plugin Price Product Rule Service Stock Supplier Text Job controller Job controller Admin cache Admin log Attribute import Catalog export Catalog import Coupon import Customer email Customer group Customer import Decorators Index optimize Index rebuild Media scale Order cleanup Order email Order export Order service Order status Product bought Product export Product import Stock import Subscription process Subscription export Supplier import XML import MShop MShop Attribute Catalog Common Coupon Customer Index Locale Media Order Plugin Price Product Review Rule Service Stock Subscription Supplier Tag Text Coupon provider Plugin provider Service provider MAdmin MAdmin Cache Common Job Log Changelog Changelog 2021.x -> 2022.x 2020.x -> 2021.x 2019.x -> 2020.x 2018.x -> 2019.x 2017.x -> 2018.x Table of contents Test setup Supporting method Get front-end / back-end configuration Check front-end / back-end configuration Check optional methods Test payment processing Direct status update Notification status update Batch status update Test optional methods Write unit tests Testing is an essential part of software development. Unit tests can execute test cases automatically and will save you a lot of time by avoiding manual tests after changes. They uncover programming and logical errors by executing the code paths so your goal should be to have a code coverage of at least 90% and test most of your code paths. Test classes are located in the ./test/ directory next to the ./src/ directory and use the same directory structure as in the ./src/ directory. The test class file itself is named like the original file but with "Test" at the end, e.g. if your service provider class file is named "Myprovider.php" then the test class file must be named "MyproviderTest.php". Tip For a basic understanding of unit tests in PHP, please read the documentation of PHPUnit first! Test setup# A test class for service providers needs a setUp() method to create an object you can run your tests against. This method is executed before every test method so you have a clean object in each test. A basic skeleton of a test class will look like this: namespace Aimeos\MShop\Service\Provider\Payment;