server/src/tests/Controllers/DocumentListControllerTest.php
author ymh <ymh.work@gmail.com>
Tue, 23 Jun 2015 17:01:39 +0200
changeset 2 00e2916104fe
child 4 f55970e41793
permissions -rw-r--r--
Migrate to php 5.6 + Laravel 5.1 + add phpunit test

<?php

use CorpusParole\Repositories\DocumentRepository;
use Mockery as m;

/**
 *
 */
class DocumentListControllerTest extends TestCase {

    private $documentRepository;

    public function setUp() {

        parent::setup();

        // create a mock of the post repository interface and inject it into the
        // IoC container
        $this->documentRepository = m::mock('CorpusParole\Repositories\DocumentRepository');
        $this->app->instance('CorpusParole\Repositories\DocumentRepository', $this->documentRepository);
    }

    public function tearDown() {
        m::close();
        parent::tearDown();
    }

    public function testIndex() {
        $this->documentRepository->shouldReceive('all')->once()->andReturn(array());

        $response = $this->call('GET', '/bo/docs');

        $this->assertResponseOk($response);
        $this->assertViewHas('docs');
    }
}