mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2025-01-08 17:02:41 +00:00
More test re-organization
This commit is contained in:
parent
845b47e656
commit
7e458dddbc
5 changed files with 157 additions and 163 deletions
|
@ -139,7 +139,6 @@ trait SeriesFeed {
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
$this->primeDatabase($this->data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testListLatestItems() {
|
function testListLatestItems() {
|
||||||
|
|
|
@ -6,49 +6,46 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
|
||||||
use Phake;
|
use Phake;
|
||||||
|
|
||||||
trait SeriesFolder {
|
trait SeriesFolder {
|
||||||
function setUpSeries() {
|
protected $data = [
|
||||||
$this->data = [
|
'arsse_users' => [
|
||||||
'arsse_users' => [
|
'columns' => [
|
||||||
'columns' => [
|
'id' => 'str',
|
||||||
'id' => 'str',
|
'password' => 'str',
|
||||||
'password' => 'str',
|
'name' => 'str',
|
||||||
'name' => 'str',
|
'rights' => 'int',
|
||||||
'rights' => 'int',
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
'arsse_folders' => [
|
'rows' => [
|
||||||
'columns' => [
|
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
||||||
'id' => "int",
|
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
||||||
'owner' => "str",
|
|
||||||
'parent' => "int",
|
|
||||||
'name' => "str",
|
|
||||||
],
|
|
||||||
/* Layout translates to:
|
|
||||||
Jane
|
|
||||||
Politics
|
|
||||||
John
|
|
||||||
Technology
|
|
||||||
Software
|
|
||||||
Politics
|
|
||||||
Rocketry
|
|
||||||
Politics
|
|
||||||
*/
|
|
||||||
'rows' => [
|
|
||||||
[1, "john.doe@example.com", null, "Technology"],
|
|
||||||
[2, "john.doe@example.com", 1, "Software"],
|
|
||||||
[3, "john.doe@example.com", 1, "Rocketry"],
|
|
||||||
[4, "jane.doe@example.com", null, "Politics"],
|
|
||||||
[5, "john.doe@example.com", null, "Politics"],
|
|
||||||
[6, "john.doe@example.com", 2, "Politics"],
|
|
||||||
]
|
|
||||||
],
|
],
|
||||||
];
|
],
|
||||||
$this->primeDatabase($this->data);
|
'arsse_folders' => [
|
||||||
}
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'owner' => "str",
|
||||||
|
'parent' => "int",
|
||||||
|
'name' => "str",
|
||||||
|
],
|
||||||
|
/* Layout translates to:
|
||||||
|
Jane
|
||||||
|
Politics
|
||||||
|
John
|
||||||
|
Technology
|
||||||
|
Software
|
||||||
|
Politics
|
||||||
|
Rocketry
|
||||||
|
Politics
|
||||||
|
*/
|
||||||
|
'rows' => [
|
||||||
|
[1, "john.doe@example.com", null, "Technology"],
|
||||||
|
[2, "john.doe@example.com", 1, "Software"],
|
||||||
|
[3, "john.doe@example.com", 1, "Rocketry"],
|
||||||
|
[4, "jane.doe@example.com", null, "Politics"],
|
||||||
|
[5, "john.doe@example.com", null, "Politics"],
|
||||||
|
[6, "john.doe@example.com", 2, "Politics"],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
function testAddARootFolder() {
|
function testAddARootFolder() {
|
||||||
$user = "john.doe@example.com";
|
$user = "john.doe@example.com";
|
||||||
|
|
|
@ -8,111 +8,111 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
|
||||||
use Phake;
|
use Phake;
|
||||||
|
|
||||||
trait SeriesSubscription {
|
trait SeriesSubscription {
|
||||||
|
protected $data = [
|
||||||
|
'arsse_users' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => 'str',
|
||||||
|
'password' => 'str',
|
||||||
|
'name' => 'str',
|
||||||
|
'rights' => 'int',
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
||||||
|
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'arsse_folders' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'owner' => "str",
|
||||||
|
'parent' => "int",
|
||||||
|
'name' => "str",
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
[1, "john.doe@example.com", null, "Technology"],
|
||||||
|
[2, "john.doe@example.com", 1, "Software"],
|
||||||
|
[3, "john.doe@example.com", 1, "Rocketry"],
|
||||||
|
[4, "jane.doe@example.com", null, "Politics"],
|
||||||
|
[5, "john.doe@example.com", null, "Politics"],
|
||||||
|
[6, "john.doe@example.com", 2, "Politics"],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'arsse_feeds' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'url' => "str",
|
||||||
|
'title' => "str",
|
||||||
|
'username' => "str",
|
||||||
|
'password' => "str",
|
||||||
|
'next_fetch' => "datetime",
|
||||||
|
],
|
||||||
|
'rows' => [] // filled in the series setup
|
||||||
|
],
|
||||||
|
'arsse_subscriptions' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'owner' => "str",
|
||||||
|
'feed' => "int",
|
||||||
|
'title' => "str",
|
||||||
|
'folder' => "int",
|
||||||
|
'pinned' => "bool",
|
||||||
|
'order_type' => "int",
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
[1,"john.doe@example.com",2,null,null,1,2],
|
||||||
|
[2,"jane.doe@example.com",2,null,null,0,0],
|
||||||
|
[3,"john.doe@example.com",3,"Ook",2,0,1],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'arsse_articles' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'feed' => "int",
|
||||||
|
'url_title_hash' => "str",
|
||||||
|
'url_content_hash' => "str",
|
||||||
|
'title_content_hash' => "str",
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
[1,2,"","",""],
|
||||||
|
[2,2,"","",""],
|
||||||
|
[3,2,"","",""],
|
||||||
|
[4,2,"","",""],
|
||||||
|
[5,2,"","",""],
|
||||||
|
[6,3,"","",""],
|
||||||
|
[7,3,"","",""],
|
||||||
|
[8,3,"","",""],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'arsse_marks' => [
|
||||||
|
'columns' => [
|
||||||
|
'id' => "int",
|
||||||
|
'article' => "int",
|
||||||
|
'owner' => "str",
|
||||||
|
'read' => "bool",
|
||||||
|
'starred' => "bool",
|
||||||
|
],
|
||||||
|
'rows' => [
|
||||||
|
[1,1,"jane.doe@example.com",1,0],
|
||||||
|
[2,2,"jane.doe@example.com",1,0],
|
||||||
|
[3,3,"jane.doe@example.com",1,0],
|
||||||
|
[4,4,"jane.doe@example.com",1,0],
|
||||||
|
[5,5,"jane.doe@example.com",1,0],
|
||||||
|
[6,6,"jane.doe@example.com",1,0],
|
||||||
|
[7,7,"jane.doe@example.com",1,0],
|
||||||
|
[8,8,"jane.doe@example.com",1,0],
|
||||||
|
[9, 1,"john.doe@example.com",1,0],
|
||||||
|
[10,7,"john.doe@example.com",1,0],
|
||||||
|
[11,8,"john.doe@example.com",0,0],
|
||||||
|
]
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
function setUpSeries() {
|
function setUpSeries() {
|
||||||
$this->data = [
|
$this->data['arsse_feeds']['rows'] = [
|
||||||
'arsse_users' => [
|
[1,"http://example.com/feed1", "Ook", "", "",strtotime("now")],
|
||||||
'columns' => [
|
[2,"http://example.com/feed2", "Eek", "", "",strtotime("now - 1 hour")],
|
||||||
'id' => 'str',
|
[3,"http://example.com/feed3", "Ack", "", "",strtotime("now + 1 hour")],
|
||||||
'password' => 'str',
|
|
||||||
'name' => 'str',
|
|
||||||
'rights' => 'int',
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
["admin@example.net", '$2y$10$PbcG2ZR3Z8TuPzM7aHTF8.v61dtCjzjK78gdZJcp4UePE8T9jEgBW', "Hard Lip Herbert", UserDriver::RIGHTS_GLOBAL_ADMIN], // password is hash of "secret"
|
|
||||||
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'arsse_folders' => [
|
|
||||||
'columns' => [
|
|
||||||
'id' => "int",
|
|
||||||
'owner' => "str",
|
|
||||||
'parent' => "int",
|
|
||||||
'name' => "str",
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
[1, "john.doe@example.com", null, "Technology"],
|
|
||||||
[2, "john.doe@example.com", 1, "Software"],
|
|
||||||
[3, "john.doe@example.com", 1, "Rocketry"],
|
|
||||||
[4, "jane.doe@example.com", null, "Politics"],
|
|
||||||
[5, "john.doe@example.com", null, "Politics"],
|
|
||||||
[6, "john.doe@example.com", 2, "Politics"],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'arsse_feeds' => [
|
|
||||||
'columns' => [
|
|
||||||
'id' => "int",
|
|
||||||
'url' => "str",
|
|
||||||
'title' => "str",
|
|
||||||
'username' => "str",
|
|
||||||
'password' => "str",
|
|
||||||
'next_fetch' => "datetime",
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
[1,"http://example.com/feed1", "Ook", "", "",strtotime("now")],
|
|
||||||
[2,"http://example.com/feed2", "Eek", "", "",strtotime("now - 1 hour")],
|
|
||||||
[3,"http://example.com/feed3", "Ack", "", "",strtotime("now + 1 hour")],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'arsse_subscriptions' => [
|
|
||||||
'columns' => [
|
|
||||||
'id' => "int",
|
|
||||||
'owner' => "str",
|
|
||||||
'feed' => "int",
|
|
||||||
'title' => "str",
|
|
||||||
'folder' => "int",
|
|
||||||
'pinned' => "bool",
|
|
||||||
'order_type' => "int",
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
[1,"john.doe@example.com",2,null,null,1,2],
|
|
||||||
[2,"jane.doe@example.com",2,null,null,0,0],
|
|
||||||
[3,"john.doe@example.com",3,"Ook",2,0,1],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'arsse_articles' => [
|
|
||||||
'columns' => [
|
|
||||||
'id' => "int",
|
|
||||||
'feed' => "int",
|
|
||||||
'url_title_hash' => "str",
|
|
||||||
'url_content_hash' => "str",
|
|
||||||
'title_content_hash' => "str",
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
[1,2,"","",""],
|
|
||||||
[2,2,"","",""],
|
|
||||||
[3,2,"","",""],
|
|
||||||
[4,2,"","",""],
|
|
||||||
[5,2,"","",""],
|
|
||||||
[6,3,"","",""],
|
|
||||||
[7,3,"","",""],
|
|
||||||
[8,3,"","",""],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
'arsse_marks' => [
|
|
||||||
'columns' => [
|
|
||||||
'id' => "int",
|
|
||||||
'article' => "int",
|
|
||||||
'owner' => "str",
|
|
||||||
'read' => "bool",
|
|
||||||
'starred' => "bool",
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
[1,1,"jane.doe@example.com",1,0],
|
|
||||||
[2,2,"jane.doe@example.com",1,0],
|
|
||||||
[3,3,"jane.doe@example.com",1,0],
|
|
||||||
[4,4,"jane.doe@example.com",1,0],
|
|
||||||
[5,5,"jane.doe@example.com",1,0],
|
|
||||||
[6,6,"jane.doe@example.com",1,0],
|
|
||||||
[7,7,"jane.doe@example.com",1,0],
|
|
||||||
[8,8,"jane.doe@example.com",1,0],
|
|
||||||
[9, 1,"john.doe@example.com",1,0],
|
|
||||||
[10,7,"john.doe@example.com",1,0],
|
|
||||||
[11,8,"john.doe@example.com",0,0],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
$this->primeDatabase($this->data);
|
|
||||||
// initialize a partial mock of the Database object to later manipulate the feedUpdate method
|
// initialize a partial mock of the Database object to later manipulate the feedUpdate method
|
||||||
Data::$db = Phake::PartialMock(Database::class, $this->drv);
|
Data::$db = Phake::PartialMock(Database::class, $this->drv);
|
||||||
$this->user = "john.doe@example.com";
|
$this->user = "john.doe@example.com";
|
||||||
|
|
|
@ -6,24 +6,21 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
|
||||||
use Phake;
|
use Phake;
|
||||||
|
|
||||||
trait SeriesUser {
|
trait SeriesUser {
|
||||||
function setUpSeries() {
|
protected $data = [
|
||||||
$this->data = [
|
'arsse_users' => [
|
||||||
'arsse_users' => [
|
'columns' => [
|
||||||
'columns' => [
|
'id' => 'str',
|
||||||
'id' => 'str',
|
'password' => 'str',
|
||||||
'password' => 'str',
|
'name' => 'str',
|
||||||
'name' => 'str',
|
'rights' => 'int',
|
||||||
'rights' => 'int',
|
|
||||||
],
|
|
||||||
'rows' => [
|
|
||||||
["admin@example.net", '$2y$10$PbcG2ZR3Z8TuPzM7aHTF8.v61dtCjzjK78gdZJcp4UePE8T9jEgBW', "Hard Lip Herbert", UserDriver::RIGHTS_GLOBAL_ADMIN], // password is hash of "secret"
|
|
||||||
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
];
|
'rows' => [
|
||||||
$this->primeDatabase($this->data);
|
["admin@example.net", '$2y$10$PbcG2ZR3Z8TuPzM7aHTF8.v61dtCjzjK78gdZJcp4UePE8T9jEgBW', "Hard Lip Herbert", UserDriver::RIGHTS_GLOBAL_ADMIN], // password is hash of "secret"
|
||||||
}
|
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
|
||||||
|
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
function testCheckThatAUserExists() {
|
function testCheckThatAUserExists() {
|
||||||
$this->assertTrue(Data::$db->userExists("jane.doe@example.com"));
|
$this->assertTrue(Data::$db->userExists("jane.doe@example.com"));
|
||||||
|
|
|
@ -11,7 +11,6 @@ use Phake;
|
||||||
|
|
||||||
trait Setup {
|
trait Setup {
|
||||||
protected $drv;
|
protected $drv;
|
||||||
protected $data = [];
|
|
||||||
|
|
||||||
function setUp() {
|
function setUp() {
|
||||||
// establish a clean baseline
|
// establish a clean baseline
|
||||||
|
@ -28,6 +27,8 @@ trait Setup {
|
||||||
Phake::when(Data::$user)->authorize->thenReturn(true);
|
Phake::when(Data::$user)->authorize->thenReturn(true);
|
||||||
// call the additional setup method if it exists
|
// call the additional setup method if it exists
|
||||||
if(method_exists($this, "setUpSeries")) $this->setUpSeries();
|
if(method_exists($this, "setUpSeries")) $this->setUpSeries();
|
||||||
|
// prime the database with series data
|
||||||
|
if(isset($this->data)) $this->primeDatabase($this->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
function tearDown() {
|
||||||
|
|
Loading…
Reference in a new issue