szurubooru/tests/Dao/UserDaoTest.php

47 lines
948 B
PHP
Raw Normal View History

2014-09-01 20:51:59 +02:00
<?php
namespace Szurubooru\Tests\Dao;
final class UserDaoTest extends \Szurubooru\Tests\AbstractDatabaseTestCase
{
public function testRetrievingByValidName()
{
$userDao = $this->getUserDao();
2014-09-01 20:51:59 +02:00
$user = new \Szurubooru\Entities\User();
$user->name = 'test';
$userDao->save($user);
$expected = $user;
$actual = $userDao->getByName($user->name);
$this->assertEquals($actual, $expected);
}
public function testRetrievingByInvalidName()
{
$userDao = $this->getUserDao();
2014-09-01 20:51:59 +02:00
$actual = $userDao->getByName('rubbish');
$this->assertNull($actual);
}
public function testCheckingUserPresence()
{
$userDao = $this->getUserDao();
2014-09-01 20:51:59 +02:00
$this->assertFalse($userDao->hasAnyUsers());
$user = new \Szurubooru\Entities\User();
$user->name = 'test';
$userDao->save($user);
$this->assertTrue($userDao->hasAnyUsers());
}
private function getUserDao()
{
return new \Szurubooru\Dao\UserDao($this->databaseConnection);
}
2014-09-01 20:51:59 +02:00
}