Skip to content
This repository has been archived by the owner on Mar 19, 2021. It is now read-only.

Commit

Permalink
Unit Tests
Browse files Browse the repository at this point in the history
All Controllers are tested if the index function is present and responding.
Most of the Models are now tested if the fetchAll function is doing well.
  • Loading branch information
fbergkemper committed Jan 17, 2014
1 parent 2ef875f commit cd906a2
Show file tree
Hide file tree
Showing 22 changed files with 635 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/AdminTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace AdminTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class AdminControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/admin');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Admin');
$this->assertControllerName('Admin\Controller\Admin');
$this->assertControllerClass('AdminController');
$this->assertMatchedRouteName('admin');
}

}
28 changes: 28 additions & 0 deletions tests/ClientTest/Controller/IndexControllerTest.php
@@ -0,0 +1,28 @@
<?php

namespace ClientTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class ClientControllerTest extends AbstractHttpControllerTestCase
{
protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/client');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Client');
$this->assertControllerName('Client\Controller\Client');
$this->assertControllerClass('ClientController');
$this->assertMatchedRouteName('client');
}

}
36 changes: 36 additions & 0 deletions tests/ClientTest/Model/ClientTableTest.php
@@ -0,0 +1,36 @@
<?php

namespace ClientTest\Model;

use Client\Model\ClientTable;
use Client\Model\Client;
use Zend\Db\ResultSet\ResultSet;
use PHPUnit_Framework_TestCase;

class ClientTableTest extends PHPUnit_Framework_TestCase
{

public function testFetchAllReturnsAllClients()
{
$resultSet = new ResultSet();

$mockTableGateway = $this->getMock(
'Zend\Db\TableGateway\TableGateway',
array('select'),
array(),
'',
false
);

$mockTableGateway->expects($this->once())
->method('select')
->with()
->will($this->returnValue($resultSet));

$clientTable = new ClientTable($mockTableGateway);

$this->assertSame($resultSet, $clientTable->fetchAll());

}

}
29 changes: 29 additions & 0 deletions tests/DashboardTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace DashboardTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class DashboardControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/dashboard');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Dashboard');
$this->assertControllerName('Dashboard\Controller\Dashboard');
$this->assertControllerClass('DashboardController');
$this->assertMatchedRouteName('dashboard');
}

}
29 changes: 29 additions & 0 deletions tests/DirectorTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace DirectorTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class DirectorControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/director');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Director');
$this->assertControllerName('Director\Controller\Director');
$this->assertControllerClass('DirectorController');
$this->assertMatchedRouteName('director');
}

}
29 changes: 29 additions & 0 deletions tests/FileTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace FileTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class FileControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/file');
$this->assertResponseStatusCode(200);
$this->assertModuleName('File');
$this->assertControllerName('File\Controller\File');
$this->assertControllerClass('FileController');
$this->assertMatchedRouteName('file');
}

}
36 changes: 36 additions & 0 deletions tests/FileTest/Model/FileTableTest.php
@@ -0,0 +1,36 @@
<?php

namespace FileTest\Model;

use File\Model\FileTable;
use File\Model\File;
use Zend\Db\ResultSet\ResultSet;
use PHPUnit_Framework_TestCase;

class FileTableTest extends PHPUnit_Framework_TestCase
{

public function testFetchAllReturnsAllJobs()
{
$resultSet = new ResultSet();

$mockTableGateway = $this->getMock(
'Zend\Db\TableGateway\TableGateway',
array('select'),
array(),
'',
false
);

$mockTableGateway->expects($this->once())
->method('select')
->with()
->will($this->returnValue($resultSet));

$fileTable = new FileTable($mockTableGateway);

$this->assertSame($resultSet, $fileTable->fetchAll());

}

}
29 changes: 29 additions & 0 deletions tests/FilesetTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace FilesetTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class FilesetControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/fileset');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Fileset');
$this->assertControllerName('Fileset\Controller\Fileset');
$this->assertControllerClass('FilesetController');
$this->assertMatchedRouteName('fileset');
}

}
36 changes: 36 additions & 0 deletions tests/FilesetTest/Model/FilesetTableTest.php
@@ -0,0 +1,36 @@
<?php

namespace FilesetTest\Model;

use Fileset\Model\FilesetTable;
use Fileset\Model\Fileset;
use Zend\Db\ResultSet\ResultSet;
use PHPUnit_Framework_TestCase;

class FilesetTableTest extends PHPUnit_Framework_TestCase
{

public function testFetchAllReturnsAllFilesets()
{
$resultSet = new ResultSet();

$mockTableGateway = $this->getMock(
'Zend\Db\TableGateway\TableGateway',
array('select'),
array(),
'',
false
);

$mockTableGateway->expects($this->once())
->method('select')
->with()
->will($this->returnValue($resultSet));

$filesetTable = new FilesetTable($mockTableGateway);

$this->assertSame($resultSet, $filesetTable->fetchAll());

}

}
Binary file not shown.
29 changes: 29 additions & 0 deletions tests/LogTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace LogTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class LogControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/log');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Log');
$this->assertControllerName('Log\Controller\Log');
$this->assertControllerClass('LogController');
$this->assertMatchedRouteName('log');
}

}
34 changes: 34 additions & 0 deletions tests/LogTest/Model/LogTableTest.php
@@ -0,0 +1,34 @@
<?php

namespace LogTest\Model;

use Log\Model\LogTable;
use Log\Model\Log;
use Zend\Db\ResultSet\ResultSet;
use PHPUnit_Framework_TestCase;

class LogTableTest extends PHPUnit_Framework_TestCase
{
public function testFetchAllReturnsAllLogs()
{
$resultSet = new ResultSet();

$mockTableGateway = $this->getMock(
'Zend\Db\TableGateway\TableGateway',
array('select'),
array(),
'',
false
);

$mockTableGateway->expects($this->once())
->method('select')
->with()
->will($this->returnValue($resultSet));

$logTable = new LogTable($mockTableGateway);

$this->assertSame($resultSet, $logTable->fetchAll());

}
}
29 changes: 29 additions & 0 deletions tests/MediaTest/Controller/IndexControllerTest.php
@@ -0,0 +1,29 @@
<?php

namespace MediaTest\Controller;

use Zend\Test\PHPUnit\Controller\AbstractHttpControllerTestCase;

class MediaControllerTest extends AbstractHttpControllerTestCase
{

protected $traceError = true;

public function setUp()
{
$this->setApplicationConfig(
include './config/application.config.php'
);
}

public function testIndexActionCanBeAccessed()
{
$this->dispatch('/media');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Media');
$this->assertControllerName('Media\Controller\Media');
$this->assertControllerClass('MediaController');
$this->assertMatchedRouteName('media');
}

}

0 comments on commit cd906a2

Please sign in to comment.