Browse Source

More test re-organization

microsub
J. King 7 years ago
parent
commit
7e458dddbc
  1. 1
      tests/lib/Database/SeriesFeed.php
  2. 5
      tests/lib/Database/SeriesFolder.php
  3. 18
      tests/lib/Database/SeriesSubscription.php
  4. 5
      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() {

5
tests/lib/Database/SeriesFolder.php

@ -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";

18
tests/lib/Database/SeriesSubscription.php

@ -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";

5
tests/lib/Database/SeriesUser.php

@ -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"));

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