1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2025-01-09 01:12:41 +00:00

More test re-organization

This commit is contained in:
J. King 2017-06-18 12:48:29 -04:00
parent 845b47e656
commit 7e458dddbc
5 changed files with 157 additions and 163 deletions

View file

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

View file

@ -6,8 +6,7 @@ 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',
@ -47,8 +46,6 @@ trait SeriesFolder {
] ]
], ],
]; ];
$this->primeDatabase($this->data);
}
function testAddARootFolder() { function testAddARootFolder() {
$user = "john.doe@example.com"; $user = "john.doe@example.com";

View file

@ -8,8 +8,7 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
use Phake; use Phake;
trait SeriesSubscription { trait SeriesSubscription {
function setUpSeries() { protected $data = [
$this->data = [
'arsse_users' => [ 'arsse_users' => [
'columns' => [ 'columns' => [
'id' => 'str', 'id' => 'str',
@ -18,7 +17,6 @@ trait SeriesSubscription {
'rights' => 'int', 'rights' => 'int',
], ],
'rows' => [ '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], ["jane.doe@example.com", "", "Jane Doe", UserDriver::RIGHTS_NONE],
["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE], ["john.doe@example.com", "", "John Doe", UserDriver::RIGHTS_NONE],
], ],
@ -48,11 +46,7 @@ trait SeriesSubscription {
'password' => "str", 'password' => "str",
'next_fetch' => "datetime", 'next_fetch' => "datetime",
], ],
'rows' => [ 'rows' => [] // filled in the series setup
[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' => [ 'arsse_subscriptions' => [
'columns' => [ '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 // 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";

View file

@ -6,8 +6,7 @@ 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',
@ -22,8 +21,6 @@ trait SeriesUser {
], ],
], ],
]; ];
$this->primeDatabase($this->data);
}
function testCheckThatAUserExists() { function testCheckThatAUserExists() {
$this->assertTrue(Data::$db->userExists("jane.doe@example.com")); $this->assertTrue(Data::$db->userExists("jane.doe@example.com"));

View file

@ -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() {