Skip to content

PhpUnit Symfony Unit, Functional, Integration test cases (+MongoDB)

License

Notifications You must be signed in to change notification settings

php-arsenal/symfony-mongo-testing-foundation

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-arsenal/symfony-mongo-testing-foundation

PhpUnit Symfony Unit, Functional, Integration test cases (+MongoDB)

composer require --dev php-arsenal/symfony-mongo-testing-foundation

Release CI Packagist

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\UnitTestCase
  • PhpArsenal\SymfonyMongoTestingFoundation\FunctionalTestCase
  • PhpArsenal\SymfonyMongoTestingFoundation\IntegrationTestCase

Traits:

  • DatabaseTrait handles commond DocumentManager functions and clears the test database upon test start.
  • FakerTrait gives you access to the faker to help you generate data for tests
  • LoggerTrait gives you easy access to the logger if necessary

About

PhpUnit Symfony Unit, Functional, Integration test cases (+MongoDB)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%