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

Adapt the rest of the test series

This commit is contained in:
J. King 2018-11-25 00:03:56 -05:00
parent dccd4caede
commit a75fad53ca
10 changed files with 456 additions and 404 deletions

View file

@ -16,7 +16,16 @@ use JKingWeb\Arsse\Test\DatabaseInformation;
use Phake; use Phake;
abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest{ abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest{
use SeriesMiscellany;
use SeriesMeta;
use SeriesUser;
use SeriesSession;
use SeriesFolder;
use SeriesFeed;
use SeriesSubscription;
use SeriesArticle; use SeriesArticle;
use SeriesLabel;
use SeriesCleanup;
/** @var \JKingWeb\Arsse\Test\DatabaseInformation */ /** @var \JKingWeb\Arsse\Test\DatabaseInformation */
protected static $dbInfo; protected static $dbInfo;
@ -62,6 +71,7 @@ abstract class Base extends \JKingWeb\Arsse\Test\AbstractTest{
// get the name of the test's test series // get the name of the test's test series
$this->series = $this->findTraitofTest($this->getName()); $this->series = $this->findTraitofTest($this->getName());
static::clearData(); static::clearData();
static::setConf();
if (strlen(static::$failureReason)) { if (strlen(static::$failureReason)) {
$this->markTestSkipped(static::$failureReason); $this->markTestSkipped(static::$failureReason);
} }

View file

@ -10,7 +10,7 @@ use JKingWeb\Arsse\Arsse;
use Phake; use Phake;
trait SeriesCleanup { trait SeriesCleanup {
public function setUpSeries() { protected function setUpSeriesCleanup() {
// set up the configuration // set up the configuration
Arsse::$conf->import([ Arsse::$conf->import([
'userSessionTimeout' => "PT1H", 'userSessionTimeout' => "PT1H",
@ -135,6 +135,10 @@ trait SeriesCleanup {
]; ];
} }
protected function tearDownSeriesCleanup() {
unset($this->data);
}
public function testCleanUpOrphanedFeeds() { public function testCleanUpOrphanedFeeds() {
Arsse::$db->feedCleanup(); Arsse::$db->feedCleanup();
$now = gmdate("Y-m-d H:i:s"); $now = gmdate("Y-m-d H:i:s");

View file

@ -12,26 +12,7 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
use Phake; use Phake;
trait SeriesFeed { trait SeriesFeed {
protected $matches = [ protected function setUpSeriesFeed() {
[
'id' => 4,
'edited' => '2000-01-04 00:00:00',
'guid' => '804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180',
'url_title_hash' => 'f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8',
'url_content_hash' => 'f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3',
'title_content_hash' => 'ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',
],
[
'id' => 5,
'edited' => '2000-01-05 00:00:00',
'guid' => 'db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41',
'url_title_hash' => 'd40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022',
'url_content_hash' => '834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900',
'title_content_hash' => '43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba',
],
];
public function setUpSeries() {
// set up the test data // set up the test data
$past = gmdate("Y-m-d H:i:s", strtotime("now - 1 minute")); $past = gmdate("Y-m-d H:i:s", strtotime("now - 1 minute"));
$future = gmdate("Y-m-d H:i:s", strtotime("now + 1 minute")); $future = gmdate("Y-m-d H:i:s", strtotime("now + 1 minute"));
@ -163,6 +144,28 @@ trait SeriesFeed {
] ]
], ],
]; ];
$this->matches = [
[
'id' => 4,
'edited' => '2000-01-04 00:00:00',
'guid' => '804e517d623390e71497982c77cf6823180342ebcd2e7d5e32da1e55b09dd180',
'url_title_hash' => 'f3615c7f16336d3ea242d35cf3fc17dbc4ee3afb78376bf49da2dd7a5a25dec8',
'url_content_hash' => 'f11c2b4046f207579aeb9c69a8c20ca5461cef49756ccfa5ba5e2344266da3b3',
'title_content_hash' => 'ab2da63276acce431250b18d3d49b988b226a99c7faadf275c90b751aee05be9',
],
[
'id' => 5,
'edited' => '2000-01-05 00:00:00',
'guid' => 'db3e736c2c492f5def5c5da33ddcbea1824040e9ced2142069276b0a6e291a41',
'url_title_hash' => 'd40da96e39eea6c55948ccbe9b3d275b5f931298288dbe953990c5f496097022',
'url_content_hash' => '834240f84501b5341d375414718204ec421561f3825d34c22bf9182203e42900',
'title_content_hash' => '43b970ac6ec5f8a9647b2c7e4eed8b1d7f62e154a95eed748b0294c1256764ba',
],
];
}
protected function tearDownSeriesFeed() {
unset($this->data, $this->matches);
} }
public function testListLatestItems() { public function testListLatestItems() {

View file

@ -10,7 +10,8 @@ use JKingWeb\Arsse\Arsse;
use Phake; use Phake;
trait SeriesFolder { trait SeriesFolder {
protected $data = [ protected function setUpSeriesFolder() {
$this->data = [
'arsse_users' => [ 'arsse_users' => [
'columns' => [ 'columns' => [
'id' => 'str', 'id' => 'str',
@ -49,6 +50,11 @@ trait SeriesFolder {
] ]
], ],
]; ];
}
protected function tearDownSeriesFolder() {
unset($this->data);
}
public function testAddARootFolder() { public function testAddARootFolder() {
$user = "john.doe@example.com"; $user = "john.doe@example.com";

View file

@ -12,7 +12,8 @@ use JKingWeb\Arsse\Misc\Date;
use Phake; use Phake;
trait SeriesLabel { trait SeriesLabel {
protected $data = [ protected function setUpSeriesLabel() {
$this->data = [
'arsse_users' => [ 'arsse_users' => [
'columns' => [ 'columns' => [
'id' => 'str', 'id' => 'str',
@ -240,13 +241,15 @@ trait SeriesLabel {
], ],
], ],
]; ];
public function setUpSeries() {
$this->checkLabels = ['arsse_labels' => ["id","owner","name"]]; $this->checkLabels = ['arsse_labels' => ["id","owner","name"]];
$this->checkMembers = ['arsse_label_members' => ["label","article","subscription","assigned"]]; $this->checkMembers = ['arsse_label_members' => ["label","article","subscription","assigned"]];
$this->user = "john.doe@example.com"; $this->user = "john.doe@example.com";
} }
protected function tearDownSeriesLabel() {
unset($this->data, $this->checkLabels, $this->checkMembers, $this->user);
}
public function testAddALabel() { public function testAddALabel() {
$user = "john.doe@example.com"; $user = "john.doe@example.com";
$labelID = $this->nextID("arsse_labels"); $labelID = $this->nextID("arsse_labels");

View file

@ -10,7 +10,8 @@ use JKingWeb\Arsse\Test\Database;
use JKingWeb\Arsse\Arsse; use JKingWeb\Arsse\Arsse;
trait SeriesMeta { trait SeriesMeta {
protected $dataBare = [ protected function setUpSeriesMeta() {
$dataBare = [
'arsse_meta' => [ 'arsse_meta' => [
'columns' => [ 'columns' => [
'key' => 'str', 'key' => 'str',
@ -22,14 +23,16 @@ trait SeriesMeta {
], ],
], ],
]; ];
public function setUpSeries() {
// the schema_version key is a special case, and to avoid jumping through hoops for every test we deal with it now // the schema_version key is a special case, and to avoid jumping through hoops for every test we deal with it now
$this->data = $this->dataBare; $this->data = $dataBare;
// as far as tests are concerned the schema version is part of the expectations primed into the database // as far as tests are concerned the schema version is part of the expectations primed into the database
array_unshift($this->data['arsse_meta']['rows'], ['schema_version', "".Database::SCHEMA_VERSION]); array_unshift($this->data['arsse_meta']['rows'], ['schema_version', "".Database::SCHEMA_VERSION]);
// but it's already been inserted by the driver, so we prime without it // but it's already been inserted by the driver, so we prime without it
$this->primeDatabase($this->dataBare); $this->primeDatabase($dataBare);
}
protected function tearDownSeriesMeta() {
unset($this->data);
} }
public function testAddANewValue() { public function testAddANewValue() {

View file

@ -10,6 +10,15 @@ use JKingWeb\Arsse\Arsse;
use JKingWeb\Arsse\Database; use JKingWeb\Arsse\Database;
trait SeriesMiscellany { trait SeriesMiscellany {
protected function setUpSeriesMiscellany() {
static::setConf([
'dbDriver' => static::$dbInfo->driverClass,
]);
}
protected function tearDownSeriesMiscellany() {
}
public function testListDrivers() { public function testListDrivers() {
$exp = [ $exp = [
'JKingWeb\\Arsse\\Db\\SQLite3\\Driver' => Arsse::$lang->msg("Driver.Db.SQLite3.Name"), 'JKingWeb\\Arsse\\Db\\SQLite3\\Driver' => Arsse::$lang->msg("Driver.Db.SQLite3.Name"),

View file

@ -11,9 +11,9 @@ use JKingWeb\Arsse\Misc\Date;
use Phake; use Phake;
trait SeriesSession { trait SeriesSession {
public function setUpSeries() { protected function setUpSeriesSession() {
// set up the configuration // set up the configuration
Arsse::$conf->import([ static::setConf([
'userSessionTimeout' => "PT1H", 'userSessionTimeout' => "PT1H",
'userSessionLifetime' => "PT24H", 'userSessionLifetime' => "PT24H",
]); ]);
@ -51,6 +51,10 @@ trait SeriesSession {
]; ];
} }
protected function tearDownSeriesSession() {
unset($this->data);
}
public function testResumeAValidSession() { public function testResumeAValidSession() {
$exp1 = [ $exp1 = [
'id' => "80fa94c1a11f11e78667001e673b2560", 'id' => "80fa94c1a11f11e78667001e673b2560",

View file

@ -12,7 +12,9 @@ use JKingWeb\Arsse\Feed\Exception as FeedException;
use Phake; use Phake;
trait SeriesSubscription { trait SeriesSubscription {
protected $data = [
public function setUpSeriesSubscription() {
$this->data = [
'arsse_users' => [ 'arsse_users' => [
'columns' => [ 'columns' => [
'id' => 'str', 'id' => 'str',
@ -106,18 +108,20 @@ trait SeriesSubscription {
] ]
], ],
]; ];
public function setUpSeries() {
$this->data['arsse_feeds']['rows'] = [ $this->data['arsse_feeds']['rows'] = [
[1,"http://example.com/feed1", "Ook", "", "",strtotime("now"),''], [1,"http://example.com/feed1", "Ook", "", "",strtotime("now"),''],
[2,"http://example.com/feed2", "eek", "", "",strtotime("now - 1 hour"),'http://example.com/favicon.ico'], [2,"http://example.com/feed2", "eek", "", "",strtotime("now - 1 hour"),'http://example.com/favicon.ico'],
[3,"http://example.com/feed3", "Ack", "", "",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
Arsse::$db = Phake::partialMock(Database::class, $this->drv); Arsse::$db = Phake::partialMock(Database::class, static::$drv);
$this->user = "john.doe@example.com"; $this->user = "john.doe@example.com";
} }
protected function tearDownSeriesSubscription() {
unset($this->data, $this->user);
}
public function testAddASubscriptionToAnExistingFeed() { public function testAddASubscriptionToAnExistingFeed() {
$url = "http://example.com/feed1"; $url = "http://example.com/feed1";
$subID = $this->nextID("arsse_subscriptions"); $subID = $this->nextID("arsse_subscriptions");

View file

@ -11,7 +11,8 @@ use JKingWeb\Arsse\User\Driver as UserDriver;
use Phake; use Phake;
trait SeriesUser { trait SeriesUser {
protected $data = [ protected function setUpSeriesUser() {
$this->data = [
'arsse_users' => [ 'arsse_users' => [
'columns' => [ 'columns' => [
'id' => 'str', 'id' => 'str',
@ -26,6 +27,11 @@ trait SeriesUser {
], ],
], ],
]; ];
}
protected function tearDownSeriesUser() {
unset($this->data);
}
public function testCheckThatAUserExists() { public function testCheckThatAUserExists() {
$this->assertTrue(Arsse::$db->userExists("jane.doe@example.com")); $this->assertTrue(Arsse::$db->userExists("jane.doe@example.com"));