Symfony 2. PHPUnit – 1. Installation – 2. Let's Battle



Symfony 2. PHPUnit – 1. Installation – 2. Let's Battle

0 0


vadim2404.github.io

Symfony2. PHPUnit. Presentation

On Github vadim2404 / vadim2404.github.io

Symfony 2. PHPUnit

Vadim Kharitonov

1. Installation

1.1 OS package

# apt-get install phpunit

1.2 phpunit.phar

$ wget https://phar.phpunit.de/phpunit.phar $ chmod +x phpunit.phar

1.3 Composer

$ ./composer.phar require 'phpunit/phpunit=4.1.*'

1.4 PEAR

# pear config-set auto_discover 1# pear install pear.phpunit.de/PHPUnit

2. Let's Battle

2.1 Entity

Entity\User

Tests\Entity\UserTest

2.2 Repository

composer.json

AppKernel

config_test.yml

Repository\UserRepository

Tests\Repository\UserRepositoryTest

Tests\Repository\Fixtures\LoadUserData

2.3 Controller

Controller\DemoController

Tests\Controller\DemoControllerTest

2.4 Console Commands

Command\HelloWorldCommand

Tests\Command\HelloWorldCommandTest

2.5 Forms

Form\UserType

Tests\Form\UserTypeTest

2.6 Extensions

DependencyInjection\Configuration

DependencyInjection\AcmeDemoExtension

Tests\DependencyInjection\AcmeDemoExtensionTest

2.7 Event Listeners

EventListeners\UserNotifierListener

Events\UserEvent

Resources\config\services.xml

Tests\EventListeners\UserNotifierListenerTest

2.8 Twig Extensions

Resources\config\services.xml

Twig\Extension\SqrExtension

Tests\Twig\Extension\SqrExtensionTest

Tests\Twig\Extension\Fixtures\filters\sqr.test

Twig\Extension\UserExtension

Tests\Twig\Extension\UserExtensionTest

3. Code Characteristics

What percentage of the code coverage do u have?

3.1. Code coverage

$ bin/phpunit -c app --coverage-text
$ bin/phpunit -c app --coverage-html=../report

3.2 PHP Copy/Paste Detector

$ wget https://phar.phpunit.de/phpcpd.phar $ chmod +x phpcpd.phar $ ./phpcpd.phar --exclude="*Test" src