Giter VIP home page Giter VIP logo

jediatoumbundle's Introduction

/!\ This bundle is now deprecated, use atoum/AtoumBundle instead /!\


This bundle provides a (very) simple integration of Atoum, the unit testing framework, from mageekguy into Symfony2.

Installation

All with composer

{
    "require": {
        "jedi/atoum-bundle": "dev-master",
        "mageekguy/atoum": "dev-master"
    },
    "config": {
        "bin-dir": "bin"
    }
}

Composer & Atoum Phar

{
    "require": {
        "jedi/atoum-bundle": "dev-master"
    }
}

Download the Atoum PHAR archive.

Simple Usage

Make your test class extends the Tests\Units\Test class of the bundle.

Don't forget to load this class with your favorite method (require, autoload, ...)

<?php

//if you don't use a bootstrap file, you need to require the autoload
require __DIR__ . '/../../../../../../../vendor/autoload.php';

// use path of the atoum.phar as bello if you don't want to use atoum via composer
//require_once __DIR__ . '/../../../../../vendor/mageekguy.atoum.phar';

use Jedi\AtoumBundle\Tests\Units;

class helloWorld extends Units\Test
{
}

Web test case

You can create easily a kernel environment :

<?php

require __DIR__ . '/../../../../../../../vendor/autoload.php';

use Jedi\AtoumBundle\Tests\Units;

class helloWorld extends Units\WebTestCase
{
    public function testMyTralala()
    {
        $client = self::createClient();
    }
}

Known issues

  • The path of the AppKernel cannot be find, override the method getKernelDirectory and add the path to your app directory.

Test a controller

You can test your controller with the ControllerTest class (it extends WebTestCase) :

<?php

namespace vendor\FooBundle\Tests\Controller;

use Jedi\AtoumBundle\Tests\Units\WebTestCase;
use Jedi\AtoumBundle\Tests\Controller\ControllerTest;

class BarController extends ControllerTest
{
    //test a json api method
    public function testGet()
    {
        $client   = static::createClient();
        $crawler  = $client->request('GET', '/api/foobar');
        $response = $client->getResponse();

        $this
            ->integer($response->getStatusCode())
                ->isEqualTo(200)

            ->string($response->headers->get('Content-Type'))
                ->isEqualTo('application/json')
        ;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.