Browse Source

More test re-organization

microsub
J. King 7 years ago
parent
commit
7e458dddbc
  1. 1
      tests/lib/Database/SeriesFeed.php
  2. 79
      tests/lib/Database/SeriesFolder.php
  3. 196
      tests/lib/Database/SeriesSubscription.php
  4. 31
      tests/lib/Database/SeriesUser.php
  5. 3
      tests/lib/Database/Setup.php

1
tests/lib/Database/SeriesFeed.php

@ -139,7 +139,6 @@ trait SeriesFeed {
]
],
];
$this->primeDatabase($this->data);
}
function testListLatestItems() {

79
tests/lib/Database/SeriesFolder.php

@ -6,49 +6,46 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
use Phake;
trait SeriesFolder {
function setUpSeries() {
$this->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],
],
protected $data = [
'arsse_users' => [
'columns' => [
'id' => 'str',
'password' => 'str',
'name' => 'str',
'rights' => 'int',
],
'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"],
]
'rows' => [
["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
],
];
$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() {
$user = "john.doe@example.com";

196
tests/lib/Database/SeriesSubscription.php

@ -8,111 +8,111 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
use Phake;
trait SeriesSubscription {
function setUpSeries() {
$this->data = [
'arsse_users' => [
'columns' => [
'id' => 'str',
'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],
],
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_folders' => [
'columns' => [
'id' => "int",
'owner' => "str",
'parent' => "int",
'name' => "str",
],
'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")],
]
'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",
],
'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],
]
'rows' => [] // filled in the series setup
],
'arsse_subscriptions' => [
'columns' => [
'id' => "int",
'owner' => "str",
'feed' => "int",
'title' => "str",
'folder' => "int",
'pinned' => "bool",
'order_type' => "int",
],
'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,"","",""],
]
'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",
],
'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],
]
'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() {
$this->data['arsse_feeds']['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")],
];
$this->primeDatabase($this->data);
// initialize a partial mock of the Database object to later manipulate the feedUpdate method
Data::$db = Phake::PartialMock(Database::class, $this->drv);
$this->user = "john.doe@example.com";

31
tests/lib/Database/SeriesUser.php

@ -6,24 +6,21 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
use Phake;
trait SeriesUser {
function setUpSeries() {
$this->data = [
'arsse_users' => [
'columns' => [
'id' => 'str',
'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],
],
protected $data = [
'arsse_users' => [
'columns' => [
'id' => 'str',
'password' => 'str',
'name' => 'str',
'rights' => 'int',
],
];
$this->primeDatabase($this->data);
}
'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],
],
],
];
function testCheckThatAUserExists() {
$this->assertTrue(Data::$db->userExists("jane.doe@example.com"));

3
tests/lib/Database/Setup.php

@ -11,7 +11,6 @@ use Phake;
trait Setup {
protected $drv;
protected $data = [];
function setUp() {
// establish a clean baseline
@ -28,6 +27,8 @@ trait Setup {
Phake::when(Data::$user)->authorize->thenReturn(true);
// call the additional setup method if it exists
if(method_exists($this, "setUpSeries")) $this->setUpSeries();
// prime the database with series data
if(isset($this->data)) $this->primeDatabase($this->data);
}
function tearDown() {

Loading…
Cancel
Save