Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Start to write functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Phoen committed Jul 2, 2016
1 parent 02b36d2 commit 6180fe7
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
6 changes: 0 additions & 6 deletions app/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ doctrine:
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"

orm:
auto_generate_proxy_classes: "%kernel.debug%"
Expand Down
6 changes: 6 additions & 0 deletions app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ framework:
web_profiler:
toolbar: false
intercept_redirects: false

doctrine:
dbal:
driver: pdo_sqlite
path: "%kernel.root_dir%/../var/test_db.db3"
charset: UTF8
4 changes: 4 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
</testsuite>
</testsuites>

<php>
<server name="KERNEL_DIR" value="./app/" />
</php>

<logging>
<log type="coverage-clover" target="clover.xml"/>
</logging>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Functional\BackendBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class RepositoriesControllerTest extends WebTestCase
{
public function testTheRepositoriesListRequiresAuthentication()
{
$client = static::createClient();
$client->request('GET', '/backend/repositories');

$this->assertEquals(401, $client->getResponse()->getStatusCode());
}

public function testThatAnAuthorizedUserCanAccessTheRepositoriesList()
{
$client = static::createAdminClient();
$client->request('GET', '/backend/repositories');

$this->assertTrue($client->getResponse()->isSuccessful());
}

private static function createAdminClient()
{
return static::createClient([], [
'PHP_AUTH_USER' => 'admin',
'PHP_AUTH_PW' => 'admin',
]);
}
}

0 comments on commit 6180fe7

Please sign in to comment.