php-arsenal / symfony-mongo-testing-foundation
This package is abandoned and no longer maintained.
No replacement package was suggested.
Foundation classes for Symfony and MongoDB ODM testing
Package info
github.com/php-arsenal/symfony-mongo-testing-foundation
pkg:composer/php-arsenal/symfony-mongo-testing-foundation
1.0.2
2023-09-27 14:45 UTC
Requires
- php: >=8.0
- ext-json: *
- doctrine/mongodb-odm-bundle: ^4.3
- php-arsenal/faker: ^1.9
- phpunit/phpunit: ^9.5
- spatie/phpunit-snapshot-assertions: ^4.2
- symfony/framework-bundle: ^5.2
Provides
- ext-mongo: *
README
PhpUnit Symfony Unit, Functional, Integration test cases (+MongoDB)
composer require --dev php-arsenal/symfony-mongo-testing-foundation
Setup
Define MONGODB_DB of your test database in .env.test
Example tests/autoload.php:
<?php $rootDir = realpath(__DIR__.'/..'); require $rootDir.'/vendor/autoload.php'; use Symfony\Component\Dotenv\Dotenv; $dotenv = (new Dotenv())->usePutenv(true); $dotenv->load("$rootDir/.env"); $dotenv->load("$rootDir/.env.test"); if (file_exists("$rootDir/.env.test.local")) { $dotenv->load("$rootDir/.env.test.local"); }
Features
Extend the following for your tests respectivelly as needed:
PhpArsenal\SymfonyMongoTestingFoundation\UnitTestCasePhpArsenal\SymfonyMongoTestingFoundation\FunctionalTestCasePhpArsenal\SymfonyMongoTestingFoundation\IntegrationTestCase
Traits:
DatabaseTraithandles commond DocumentManager functions and clears the test database upon test start.FakerTraitgives you access to the faker to help you generate data for testsLoggerTraitgives you easy access to the logger if necessary