2017 © Pedro Peláez
 

library symfony-phpunit-helpers

image

dbstudios/symfony-phpunit-helpers

  • Friday, July 7, 2017
  • by LartTyler
  • Repository
  • 0 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Configuration

Add the following to app/AppKernel.php., (*1)

<?php
    // app/AppKernel.php

    // ...
    class AppKernel extends Kernel {
        public function registerBundles() {
            // ...
            if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
                // ...
                if ($this->getEnvironment() === 'test') {
                    $bundles[] = new Liip\FunctionalTestBundle\LiipFunctionalTestBundle();
                }
            }

            return $bundles;
        }

        // ...
    }

Next, enable the Liip bundle. Additionally, you should also configure Doctrine to use a temporary SQLite database, in lieu of your normal database connection., (*2)

liip_functional_test:
    cache_sqlite_db: true

# Optional, but recommended; tells Doctrine to use a temporary SQLite database for testing
doctrine:
    dbal:
        driver: pdo_sqlite
        path: '%kernel.cache_dir%/test.db'

Please read the LiipFunctionalTestBundle documentation for more information on configuring the Liip bundle., (*3)

Usage

Simply have your test cases extend from DaybreakStudios\Utility\SymfonyPHPUnitHelpers\WebTestCase., (*4)

<?php
    use DaybreakStudios\Utility\SymfonyPHPUntHelpers\WebTestCase;

    class MyTestCase extends WebTestCase {
        public function testItRespondsSuccessfully() {
            $this->client->request('GET', '/home');

            $response = $this->client->getResponse();

            $this->isSuccessful($response);
        }
    }

The Versions