Create tests for page controller

This commit is contained in:
brantje 2016-10-07 21:27:57 +02:00
parent 2c90899e63
commit 62aa51dfe9
No known key found for this signature in database
GPG key ID: 5FF1D117F918687F
3 changed files with 17 additions and 5 deletions

View file

@ -52,7 +52,7 @@ before_script:
- mkdir -p build
- curl -sSL https://phar.phpunit.de/phpunit.phar -o build/phpunit.phar
- npm install
# - ./occ maintenance:install --database-name oc_autotest --database-user oc_autotest --admin-user admin --admin-pass admin --database $DB --database-pass=''
script:

View file

@ -47,7 +47,7 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function bookmarklet($url='',$title='') {
$params = array('url' => $url, 'label' => $title);
$params = array('url' => $url, 'title' => $title);
return new TemplateResponse('passman', 'bookmarklet', $params);
}
@ -56,7 +56,7 @@ class PageController extends Controller {
* @NoCSRFRequired
* @PublicPage
*/
public function publicSharePage($shareKey) {
public function publicSharePage() {
return new TemplateResponse('passman', 'public_share');
}

View file

@ -29,12 +29,24 @@ class PageControllerTest extends PHPUnit_Framework_TestCase {
);
}
public function testIndex() {
$result = $this->controller->index();
$this->assertEquals(['user' => 'john'], $result->getParams());
$this->assertEquals('main', $result->getTemplateName());
$this->assertTrue($result instanceof TemplateResponse);
}
public function testBookmarklet() {
$result = $this->controller->bookmarklet('http://google.com', 'Google');
print_r($result->getParams());
$this->assertEquals(['url' => 'http://google.com', 'title' => 'Google'], $result->getParams());
$this->assertEquals('bookmarklet', $result->getTemplateName());
$this->assertTrue($result instanceof TemplateResponse);
}
public function testPublicSharePage() {
$result = $this->controller->publicSharePage();
$this->assertEquals('public_share', $result->getTemplateName());
$this->assertTrue($result instanceof TemplateResponse);
}
}