Download the PHP package cosma/testing-bundle without Composer
On this page you can find all versions of the php package cosma/testing-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cosma/testing-bundle
More information about cosma/testing-bundle
Files in cosma/testing-bundle
Package testing-bundle
Short Description Testing Bundle
License MIT
Homepage http://github.com/cosma/testing-bundle
Informations about the package testing-bundle
Testing Bundle
An extension of h4cc/AliceFixturesBundle , a Symfony2 bundle for flexible usage of nelmio/alice fixtures integrated with very powerful data generator fzaninotto/Faker. This bundle integrates mockery/mockery library, too. The Testing Bundle bundle works with data fixtures in .yml format, detached from the common Doctrine DataFixtures. There are multiple ways of loading fixture files. The Testing Bundle offers loading Fixtures from .yml , dropping and recreating the ORM Schema.
Table of Contents
- Installation
- Configuration
- Generate Test Class
- Test Cases
- Retry Tests
- Fixtures
- Advanced Usage
- Run Tests
- License
Installation
Follow the 'dev-master' branch for latest dev version. But i recommend to use more stable version tags if available.
After that, add the h4ccAliceFixturesBundle and TestingBundle to your Kernel, most likely in the "dev" or "test" environment.
Configuration
In case you want to change default paths of fixture directory you can configure the testing bundle's fixture_path. This sets a new relative path to the fixture directory in your bundle.
Generate Test Class
With the command cosma_testing:generate:test you can generate stub Test Classes for classes and traits from a php file.
Test Cases
Supports the following Test Cases:
- Simple Test Case
- Web Test Case
- DB Test Case
- Solr Test Case
- Elastic Search Test Case
- Selenium Test Case
- Redis Test Case
- Composed Test Cases
Simple Test Case
This case is an extension of PHPUnit_Framework_TestCase, with two extra simple methods:
- getMockedEntityWithId ($entity, $id)
- getEntityWithId ($entity, $id)
- getTestClassPath ()
Web Test Case
This case is an extension of Symfony2 WebTestCase - Symfony\Bundle\FrameworkBundle\Test\WebTestCase It has the following methods:
- getKernel ()
- getContainer ()
- getClient (array $server)
DB Test Case
This case is an extension of Symfony WebTestCase with Database and fixtures support
It has the following methods:
- dropDatabase ()
- loadFixtures (array $fixtures, $dropDatabaseBefore = true)
- getEntityManager ()
- getEntityRepository ($entity)
- getFixtureManager ()
Solr Test Case
This case is an extension of WebTestCase, from current bundle, with extra Solr support It has the following methods:
- getSolariumClient ()
Elastic Search Test Case
This case is an extension of WebTestCase, from current bundle, with extra ElasticSearch support It has the following methods:
- getElasticIndex ()
- getElasticClient ()
Selenium Test Case
This case is an extension of WebTestCase, with extra Selenium support It has the following methods:
- getRemoteWebDriver ()
- getTestDomain ()
- open ($url)
- openSecure ($url)
Redis Test Case
This case is an extension of WebTestCase, with extra Redis support It has the following methods:
- getRedisClient ()
Composed Test Cases
You can build composed Test Cases using the following defined traits under \Cosma\Bundle\TestingBundle\TestCase\Traits: Supports following test cases:
- SimpleTrait
- DBTrait
- CommandTrait
- ElasticTrait
- SolrTrait
- SeleniumTrait
- RedisTrait
All composed TestCases can use one or more traits and extends Cosma\Bundle\TestingBundle\TestCase\WebTestCase
Retry Tests
Use the @retry annotation for a Class or Method to retry tests in case of failure. Method annotations are overwriting Class annotation.
Fixtures
Alice fixtures are integrated with Faker.
The most basic functionality of Alice is to turn flat yaml files into objects.
You can define many objects of different classes in one file as such:
Importing/Exporting Fixture Files
You can easily dump Database data to Yaml fixture files with the command cosma_testing:fixtures:dump
You can easily import Yaml fixture to Database with command h4cc_alice_fixtures:load:files
Advanced Usage
Adding own Providers for Faker
A provider for Faker can be any class, that has public methods. These methods can be used in the fixture files for own testdata or even calculations. To register a provider, create a service and tag it.
Example:
Adding own Processors for Alice
A alice processor can be used to manipulate a object before and after persisting. To register a own processor, create a service and tag it.
Example:
Mockery
Mockery is a simple yet flexible PHP mock object framework for use in unit testing
Run Tests
vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist --coverage-text --coverage-html=Tests/coverage Tests
License
The bundle is licensed under MIT.
All versions of testing-bundle with dependencies
phpunit/phpunit Version 4.*
doctrine/orm Version ~2.2,>=2.2.3
symfony/framework-bundle Version 2.8.*
h4cc/alice-fixtures-bundle Version 0.5.*
solarium/solarium Version 3.4.*
ruflin/elastica Version 3.*
facebook/webdriver Version 1.1.*
predis/predis Version 1.0.*
mockery/mockery Version 0.9.*