mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 21:22:40 +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() {
|
||||
|
|
|
@ -6,8 +6,7 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
|
|||
use Phake;
|
||||
|
||||
trait SeriesFolder {
|
||||
function setUpSeries() {
|
||||
$this->data = [
|
||||
protected $data = [
|
||||
'arsse_users' => [
|
||||
'columns' => [
|
||||
'id' => 'str',
|
||||
|
@ -47,8 +46,6 @@ trait SeriesFolder {
|
|||
]
|
||||
],
|
||||
];
|
||||
$this->primeDatabase($this->data);
|
||||
}
|
||||
|
||||
function testAddARootFolder() {
|
||||
$user = "john.doe@example.com";
|
||||
|
|
|
@ -8,8 +8,7 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
|
|||
use Phake;
|
||||
|
||||
trait SeriesSubscription {
|
||||
function setUpSeries() {
|
||||
$this->data = [
|
||||
protected $data = [
|
||||
'arsse_users' => [
|
||||
'columns' => [
|
||||
'id' => 'str',
|
||||
|
@ -18,7 +17,6 @@ trait SeriesSubscription {
|
|||
'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],
|
||||
],
|
||||
|
@ -48,11 +46,7 @@ trait SeriesSubscription {
|
|||
'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' => [] // filled in the series setup
|
||||
],
|
||||
'arsse_subscriptions' => [
|
||||
'columns' => [
|
||||
|
@ -112,7 +106,13 @@ trait SeriesSubscription {
|
|||
]
|
||||
],
|
||||
];
|
||||
$this->primeDatabase($this->data);
|
||||
|
||||
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")],
|
||||
];
|
||||
// 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";
|
||||
|
|
|
@ -6,8 +6,7 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
|
|||
use Phake;
|
||||
|
||||
trait SeriesUser {
|
||||
function setUpSeries() {
|
||||
$this->data = [
|
||||
protected $data = [
|
||||
'arsse_users' => [
|
||||
'columns' => [
|
||||
'id' => 'str',
|
||||
|
@ -22,8 +21,6 @@ trait SeriesUser {
|
|||
],
|
||||
],
|
||||
];
|
||||
$this->primeDatabase($this->data);
|
||||
}
|
||||
|
||||
function testCheckThatAUserExists() {
|
||||
$this->assertTrue(Data::$db->userExists("jane.doe@example.com"));
|
||||
|
|
|
@ -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…
Reference in a new issue