nerds-and-company / craft-unit-test-suite
A library that helps you mocking Craft database/model classes
Installs: 5 385
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- php: >= 5.3
This package is not auto-updated.
Last update: 2022-11-30 10:06:47 UTC
README
PHPUnit test suit helps you with mocking several craft services and classes.
It enable you to:
- Configure any abstract classes you wish to load before running unit tests
- Save time by not having to manually mock Craft's database models and it's required classes
- Simply override or add extra methods to the mocked classes mocked in UnitTestSuite_AbstractTest
Requirements:
- PHP 5.4+
- Craft 2.4+
Installation:
The library can be installed using Composer.
composer require nerds-and-company/unit-test-suite ~1.0.0
Classes:
The library is composed of two classes:
UnitTestSuite_AbstractTest
is the abstract class you can extend that contains the mocked Craft database classesAbstractTestLoader
is used to load custom abstract classes that for example extend UnitTestSuite_AbstractTest and add extra functionality
Usage
- Make sure the phpunit bootstrap points at
bootstrap="vendor/unittestsuite/src/bootstrap.php
- Copy the
unittestsuite.yml
supplied with this package/craft/config
and add extra (abstract) classes you wish to pre-load - Extend
UnitTestSuite_AbstractTest
and override or add extra data to the returned mocks - Calling $this->mockCraftDb() should cover most of the Craft DB methods