szurubooru/tests/Dao/TokenDaoTest.php

30 lines
730 B
PHP
Raw Normal View History

2014-08-31 17:42:48 +02:00
<?php
namespace Szurubooru\Tests\Dao;
2014-09-01 20:51:59 +02:00
final class TokenDaoTest extends \Szurubooru\Tests\AbstractDatabaseTestCase
2014-08-31 17:42:48 +02:00
{
public function testRetrievingByValidName()
{
$tokenDao = new \Szurubooru\Dao\TokenDao($this->databaseConnection);
$token = new \Szurubooru\Entities\Token();
$token->setName('test');
2014-09-14 16:16:15 +02:00
$token->setPurpose(\Szurubooru\Entities\Token::PURPOSE_LOGIN);
2014-08-31 17:42:48 +02:00
$tokenDao->save($token);
$expected = $token;
$actual = $tokenDao->findByName($token->getName());
2014-08-31 17:42:48 +02:00
$this->assertEquals($actual, $expected);
}
public function testRetrievingByInvalidName()
{
$tokenDao = new \Szurubooru\Dao\TokenDao($this->databaseConnection);
$actual = $tokenDao->findByName('rubbish');
2014-08-31 17:42:48 +02:00
$this->assertNull($actual);
}
}