Browse Source

Relegate bootstrap.php to testing; fixes #117

microsub
J. King 7 years ago
parent
commit
1b72d45adf
  1. 7
      arsse.php
  2. 10
      bootstrap.php
  3. 1
      build.xml
  4. 2
      lib/Arsse.php
  5. 2
      lib/CLI.php
  6. 4
      lib/Feed.php
  7. 4
      lib/REST/NextCloudNews/V1_2.php
  8. 4
      tests/REST/NextCloudNews/TestNCNV1_2.php
  9. 8
      tests/bootstrap.php
  10. 2
      tests/phpunit.xml
  11. 2
      tests/server.php

7
arsse.php

@ -1,7 +1,12 @@
<?php <?php
namespace JKingWeb\Arsse; namespace JKingWeb\Arsse;
require_once __DIR__.DIRECTORY_SEPARATOR."bootstrap.php"; const BASE = __DIR__.DIRECTORY_SEPARATOR;
const NS_BASE = __NAMESPACE__."\\";
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
ignore_user_abort(true);
if (\PHP_SAPI=="cli") { if (\PHP_SAPI=="cli") {
// initialize the CLI; this automatically handles --help and --version // initialize the CLI; this automatically handles --help and --version

10
bootstrap.php

@ -1,10 +0,0 @@
<?php
declare(strict_types=1);
namespace JKingWeb\Arsse;
const BASE = __DIR__.DIRECTORY_SEPARATOR;
const NS_BASE = __NAMESPACE__."\\";
const VERSION = "0.1.1";
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
ignore_user_abort(true);

1
build.xml

@ -10,7 +10,6 @@
<include name="dist/**"/> <include name="dist/**"/>
<include name="composer.*"/> <include name="composer.*"/>
<include name="arsse.php"/> <include name="arsse.php"/>
<include name="bootstrap.php"/>
<include name="CHANGELOG"/> <include name="CHANGELOG"/>
<include name="LICENSE"/> <include name="LICENSE"/>
<include name="README.md"/> <include name="README.md"/>

2
lib/Arsse.php

@ -3,6 +3,8 @@ declare(strict_types=1);
namespace JKingWeb\Arsse; namespace JKingWeb\Arsse;
class Arsse { class Arsse {
const VERSION = "0.1.1";
/** @var Lang */ /** @var Lang */
public static $lang; public static $lang;
/** @var Conf */ /** @var Conf */

2
lib/CLI.php

@ -27,7 +27,7 @@ USAGE_TEXT;
$this->args = \Docopt::handle($this->usage(), [ $this->args = \Docopt::handle($this->usage(), [
'argv' => $argv, 'argv' => $argv,
'help' => true, 'help' => true,
'version' => VERSION, 'version' => Arsse::VERSION,
]); ]);
} }

4
lib/Feed.php

@ -20,11 +20,11 @@ class Feed {
public $nextFetch; public $nextFetch;
public $newItems = []; public $newItems = [];
public $changedItems = []; public $changedItems = [];
public function __construct(int $feedID = null, string $url, string $lastModified = '', string $etag = '', string $username = '', string $password = '', bool $scrape = false, bool $discover = false) { public function __construct(int $feedID = null, string $url, string $lastModified = '', string $etag = '', string $username = '', string $password = '', bool $scrape = false, bool $discover = false) {
// set the configuration // set the configuration
$userAgent = Arsse::$conf->fetchUserAgentString ?? sprintf('Arsse/%s (%s %s; %s; https://code.jkingweb.ca/jking/arsse) PicoFeed (https://github.com/fguillot/picoFeed)', $userAgent = Arsse::$conf->fetchUserAgentString ?? sprintf('Arsse/%s (%s %s; %s; https://code.jkingweb.ca/jking/arsse) PicoFeed (https://github.com/fguillot/picoFeed)',
VERSION, // Arsse version Arsse::VERSION, // Arsse version
php_uname('s'), // OS php_uname('s'), // OS
php_uname('r'), // OS version php_uname('r'), // OS version
php_uname('m') // platform architecture php_uname('m') // platform architecture

4
lib/REST/NextCloudNews/V1_2.php

@ -691,14 +691,14 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
protected function serverVersion(array $url, array $data): Response { protected function serverVersion(array $url, array $data): Response {
return new Response(200, [ return new Response(200, [
'version' => self::VERSION, 'version' => self::VERSION,
'arsse_version' => \JKingWeb\Arsse\VERSION, 'arsse_version' => Arsse::VERSION,
]); ]);
} }
protected function serverStatus(array $url, array $data): Response { protected function serverStatus(array $url, array $data): Response {
return new Response(200, [ return new Response(200, [
'version' => self::VERSION, 'version' => self::VERSION,
'arsse_version' => \JKingWeb\Arsse\VERSION, 'arsse_version' => Arsse::VERSION,
'warnings' => [ 'warnings' => [
'improperlyConfiguredCron' => !Service::hasCheckedIn(), 'improperlyConfiguredCron' => !Service::hasCheckedIn(),
] ]

4
tests/REST/NextCloudNews/TestNCNV1_2.php

@ -458,7 +458,7 @@ class TestNCNV1_2 extends Test\AbstractTest {
public function testRetrieveServerVersion() { public function testRetrieveServerVersion() {
$exp = new Response(200, [ $exp = new Response(200, [
'arsse_version' => \JKingWeb\Arsse\VERSION, 'arsse_version' => Arsse::VERSION,
'version' => REST\NextCloudNews\V1_2::VERSION, 'version' => REST\NextCloudNews\V1_2::VERSION,
]); ]);
$this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/version"))); $this->assertEquals($exp, $this->h->dispatch(new Request("GET", "/version")));
@ -842,7 +842,7 @@ class TestNCNV1_2 extends Test\AbstractTest {
Phake::when(Arsse::$db)->metaGet("service_last_checkin")->thenReturn(Date::transform($valid, "sql"))->thenReturn(Date::transform($invalid, "sql")); Phake::when(Arsse::$db)->metaGet("service_last_checkin")->thenReturn(Date::transform($valid, "sql"))->thenReturn(Date::transform($invalid, "sql"));
$arr1 = $arr2 = [ $arr1 = $arr2 = [
'version' => REST\NextCloudNews\V1_2::VERSION, 'version' => REST\NextCloudNews\V1_2::VERSION,
'arsse_version' => VERSION, 'arsse_version' => Arsse::VERSION,
'warnings' => [ 'warnings' => [
'improperlyConfiguredCron' => false, 'improperlyConfiguredCron' => false,
] ]

8
tests/bootstrap.php

@ -0,0 +1,8 @@
<?php
declare(strict_types=1);
namespace JKingWeb\Arsse;
const NS_BASE = __NAMESPACE__."\\";
define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR);
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";

2
tests/phpunit.xml

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<phpunit <phpunit
colors="true" colors="true"
bootstrap="../bootstrap.php" bootstrap="bootstrap.php"
convertErrorsToExceptions="false" convertErrorsToExceptions="false"
convertNoticesToExceptions="false" convertNoticesToExceptions="false"
convertWarningsToExceptions="false" convertWarningsToExceptions="false"

2
tests/server.php

@ -2,7 +2,7 @@
declare(strict_types=1); declare(strict_types=1);
namespace JKingWeb\Arsse; namespace JKingWeb\Arsse;
require_once __DIR__."/../bootstrap.php"; require_once __DIR__."/bootstrap.php";
/* /*

Loading…
Cancel
Save