<?php
namespace Szurubooru\Tests\Dao;
use Szurubooru\Dao\TokenDao;
use Szurubooru\Entities\Token;
use Szurubooru\Tests\AbstractDatabaseTestCase;
final class TokenDaoTest extends AbstractDatabaseTestCase
{
public function testRetrievingByValidName()
$token = new Token();
$token->setName('test');
$token->setPurpose(Token::PURPOSE_LOGIN);
$tokenDao = $this->getTokenDao();
$tokenDao->save($token);
$expected = $token;
$actual = $tokenDao->findByName($token->getName());
$this->assertEntitiesEqual($actual, $expected);
}
public function testRetrievingByInvalidName()
$actual = $tokenDao->findByName('rubbish');
$this->assertNull($actual);
public function testRetrievingByAdditionalDataAndPurpose()
$this->assertEntitiesEqual($expected, $tokenDao->findByAdditionalDataAndPurpose(null, Token::PURPOSE_LOGIN));
$this->assertNull($tokenDao->findByAdditionalDataAndPurpose(null, Token::PURPOSE_ACTIVATE));
private function getTokenDao()
return new TokenDao($this->databaseConnection);