2017-02-18 00:22:50 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\NewsSync;
|
|
|
|
|
|
|
|
|
|
|
|
class TestUser extends \PHPUnit\Framework\TestCase {
|
|
|
|
use Test\Tools;
|
|
|
|
|
|
|
|
protected $data;
|
|
|
|
|
|
|
|
function setUp() {
|
2017-02-19 05:22:16 +00:00
|
|
|
$drv = Test\User\DriverInternalMock::class;
|
2017-02-18 00:22:50 +00:00
|
|
|
$conf = new Conf();
|
2017-02-19 05:22:16 +00:00
|
|
|
$conf->userDriver = $drv;
|
|
|
|
$conf->userAuthPreferHTTP = true;
|
2017-02-18 00:22:50 +00:00
|
|
|
$this->data = new Test\RuntimeData($conf);
|
|
|
|
$this->data->user = new User($this->data);
|
2017-02-19 05:22:16 +00:00
|
|
|
$this->data->db = new $drv($this->data);
|
|
|
|
Test\User\DriverInternalMock::$db = [];
|
|
|
|
$_SERVER['PHP_AUTH_USER'] = "john.doe@example.com";
|
|
|
|
$_SERVER['PHP_AUTH_PW'] = "secret";
|
|
|
|
}
|
|
|
|
|
|
|
|
function testAddingAUser() {
|
|
|
|
$this->assertCount(0,$this->data->user->list());
|
|
|
|
$this->data->user->add($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
|
|
|
|
$this->assertCount(1,$this->data->user->list());
|
|
|
|
$this->assertException("alreadyExists", "User");
|
|
|
|
$this->data->user->add($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']);
|
2017-02-18 00:22:50 +00:00
|
|
|
}
|
|
|
|
}
|