Пример #1
0
<?php

use Api\Models\User;
require_once __DIR__ . '/../TestConfig.php';
require_once __DIR__ . '/../TestEnvironment.php';
TestEnvironment::ensureDatabaseConfigured();
class UserModelTest extends PHPUnit_Framework_TestCase
{
    public function testPassword_Ok()
    {
        $user = User::find(170);
        $this->assertNotNull($user);
        $plain_password = '******';
        $isAuth = $user->passwordCheck($plain_password);
        $this->assertTrue($isAuth);
    }
    public function testFindByLogin_Ok()
    {
        $user = User::findByLogin('bogus_login');
        $this->assertNull($user);
        $user = User::findByLogin('test');
        $this->assertNotNull($user);
        $this->assertEquals('test', $user->login);
    }
    public function testProjectsJoin_Ok()
    {
        $user = User::findByLogin('test');
        $this->assertNotNull($user);
        $projects = $user->projects;
        $c = count($projects);
        $this->assertEquals(2, $c);