Update dependencies and ensure Hitler is dead
Hitler's category was changed from "1945 deaths" to "1945 suicides", resulting in Death Notifier not detecting that Hitler was dead (or even a person). Death Notifier now recognises the "<year> suicides" category.
This commit is contained in:
parent
e024bc4cf8
commit
7b86673590
|
@ -1,7 +1,7 @@
|
|||
const path = require("path");
|
||||
|
||||
module.exports = grunt => {
|
||||
const testTarget = grunt.option("test-target") || ".";
|
||||
const testFilter = grunt.option("test-filter") || "'' .";
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: grunt.file.readJSON("package.json"),
|
||||
|
@ -71,7 +71,7 @@ module.exports = grunt => {
|
|||
exec: "composer.phar install --no-dev"
|
||||
},
|
||||
phpunit: {
|
||||
exec: `cd dist/ && chmod +x .vendor/bin/phpunit && .vendor/bin/phpunit --testdox ${testTarget}`
|
||||
exec: `cd dist/ && chmod +x .vendor/bin/phpunit && .vendor/bin/phpunit --filter ${testFilter}`
|
||||
},
|
||||
stan: {
|
||||
exec: "vendor/bin/phpstan analyse -l 8 src/main src/test"
|
||||
|
|
23
README.md
23
README.md
|
@ -45,7 +45,10 @@ composer.phar update
|
|||
npm install
|
||||
```
|
||||
|
||||
### Static analysis
|
||||
### Static analysis and tests
|
||||
Note that PHPUnit suppresses output from `print`.
|
||||
Instead, you can use `fwrite(STDERR, print_r("my message", TRUE));`.
|
||||
|
||||
* Run static analysis
|
||||
```shell
|
||||
npm run analyze
|
||||
|
@ -54,10 +57,24 @@ npm install
|
|||
```shell
|
||||
npm run test
|
||||
```
|
||||
* Run all tests in package
|
||||
* Run only select tests
|
||||
```shell
|
||||
npm run test -- --test-target=com/fwdekker/deathnotifier/wikipedia/
|
||||
npm run test -- --test-filter="test-name file-name"
|
||||
```
|
||||
Note that a `test-name` of `''` and a `file-name` of `.` matches all tests.
|
||||
|
||||
* Run all tests in package
|
||||
```shell
|
||||
npm run test -- --test-filter="'' com/fwdekker/deathnotifier/wikipedia/"
|
||||
```
|
||||
* Run all tests in class
|
||||
```shell
|
||||
npm run test -- --test-filter="'' com/fwdekker/deathnotifier/wikipedia/WikipediaTest.php"
|
||||
```
|
||||
* Run only specific test
|
||||
```shell
|
||||
npm run test -- --test-filter="test_query_detects_dead_person ."
|
||||
```
|
||||
* Run static analysis and tests
|
||||
```shell
|
||||
npm run check
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "fwdekker/death-notifier",
|
||||
"description": "Get notified when a famous person dies.",
|
||||
"version": "1.1.1", "_comment_version": "Also update version in `package.json`!",
|
||||
"version": "1.1.2", "_comment_version": "Also update version in `package.json`!",
|
||||
"type": "project",
|
||||
"license": "MIT",
|
||||
"homepage": "https://git.fwdekker.com/tools/death-notifier",
|
||||
|
@ -19,12 +19,12 @@
|
|||
"composer/semver": "^3.3",
|
||||
"ext-curl": "*",
|
||||
"ext-pdo": "*",
|
||||
"monolog/monolog": "^3.3",
|
||||
"monolog/monolog": "^3.4",
|
||||
"phpmailer/phpmailer": "^6.8"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
"phpstan/phpstan": "^1.10.32",
|
||||
"phpunit/phpunit": "^10.3.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "death-notifier",
|
||||
"version": "1.1.1", "_comment_version": "Also update version in `composer.json`!",
|
||||
"version": "1.1.2", "_comment_version": "Also update version in `composer.json`!",
|
||||
"description": "Get notified when a famous person dies.",
|
||||
"author": "Florine W. Dekker",
|
||||
"browser": "dist/bundle.js",
|
||||
|
|
|
@ -265,7 +265,8 @@ class UserList
|
|||
public function set_password(string $uuid, string $password): void
|
||||
{
|
||||
$stmt = $this->database->conn->prepare("UPDATE users
|
||||
SET password=:password, password_last_change=unixepoch(),
|
||||
SET password=:password,
|
||||
password_last_change=unixepoch(),
|
||||
password_reset_token=null
|
||||
WHERE uuid=:uuid;");
|
||||
$stmt->bindValue(":uuid", $uuid);
|
||||
|
|
|
@ -262,7 +262,7 @@ class Wikipedia
|
|||
return null;
|
||||
|
||||
$category_titles = array_column($article["categories"], "title");
|
||||
$dead_regex = "/^Category:([0-9]{1,4}s? (BC |AD )?deaths|Year of death (missing|unknown))$/";
|
||||
$dead_regex = "/^Category:([0-9]{1,4}s? (BC |AD )?(deaths|suicides)|Year of death (missing|unknown))$/";
|
||||
|
||||
if (!empty(array_filter($category_titles, fn($it) => preg_match($dead_regex, $it))))
|
||||
return PersonStatus::Dead;
|
||||
|
|
|
@ -44,9 +44,9 @@ class EqualsCliPasswordRuleTest extends TestCase
|
|||
* Returns the test cases.
|
||||
*
|
||||
* @return array<string, array{string|null, string|null, class-string<Throwable>|null, string|null}> the test cases
|
||||
* @see RuleTest::test_check()
|
||||
* @see RuleTestTemplate::test_check()
|
||||
*/
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$hash = "\$2y\$04\$fwXTw7Rjzw0EpU094u4agOBaBNqtCHGc4TMoxfbPrxuqO5tpYyRka"; # Hash of "password"
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ use InvalidArgumentException;
|
|||
/**
|
||||
* Unit tests for {@see EqualsRule}.
|
||||
*/
|
||||
class EqualsRuleTest extends RuleTest
|
||||
class EqualsRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
$value = InvalidValueException::class;
|
||||
|
|
|
@ -8,9 +8,9 @@ use InvalidArgumentException;
|
|||
/**
|
||||
* Unit tests for {@see HasStringLengthRule}.
|
||||
*/
|
||||
class HasStringLengthRuleTest extends RuleTest
|
||||
class HasStringLengthRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
$value = InvalidValueException::class;
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace com\fwdekker\deathnotifier\validation;
|
|||
/**
|
||||
* Unit tests for {@see IsBooleanRule}.
|
||||
*/
|
||||
class IsBooleanRuleTest extends RuleTest
|
||||
class IsBooleanRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace com\fwdekker\deathnotifier\validation;
|
|||
/**
|
||||
* Unit tests for {@see IsEmailRule}.
|
||||
*/
|
||||
class IsEmailRuleTest extends RuleTest
|
||||
class IsEmailRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
$value = InvalidValueException::class;
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace com\fwdekker\deathnotifier\validation;
|
|||
/**
|
||||
* Unit tests for {@see IsNotBlankRule}.
|
||||
*/
|
||||
class IsNotBlankRuleTest extends RuleTest
|
||||
class IsNotBlankRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
$value = InvalidValueException::class;
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace com\fwdekker\deathnotifier\validation;
|
|||
/**
|
||||
* Unit tests for {@see IsStringRule}.
|
||||
*/
|
||||
class IsStringRuleTest extends RuleTest
|
||||
class IsStringRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@ namespace com\fwdekker\deathnotifier\validation;
|
|||
/**
|
||||
* Unit tests for {@see IsValidCsrfTokenRule}.
|
||||
*/
|
||||
class IsValidCsrfTokenRuleTest extends RuleTest
|
||||
class IsValidCsrfTokenRuleTest extends RuleTestTemplate
|
||||
{
|
||||
public function check_provider(): array
|
||||
public static function check_provider(): array
|
||||
{
|
||||
$type = InvalidTypeException::class;
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ use Throwable;
|
|||
/**
|
||||
* Unit tests for {@see Rule} implementations.
|
||||
*/
|
||||
abstract class RuleTest extends TestCase
|
||||
abstract class RuleTestTemplate extends TestCase
|
||||
{
|
||||
/**
|
||||
* Tests the output of {@see Rule::check()}.
|
||||
|
@ -40,7 +40,7 @@ abstract class RuleTest extends TestCase
|
|||
* Returns the test cases.
|
||||
*
|
||||
* @return array<string, array{Rule, mixed|null, class-string<Throwable>|null, string|null}> the test cases
|
||||
* @see RuleTest::test_check()
|
||||
* @see RuleTestTemplate::test_check()
|
||||
*/
|
||||
abstract public function check_provider(): array;
|
||||
abstract public static function check_provider(): array;
|
||||
}
|
|
@ -135,6 +135,13 @@ class WikipediaTest extends TestCase
|
|||
}
|
||||
|
||||
public function test_query_detects_dead_person(): void
|
||||
{
|
||||
$output = $this->wikipedia->query_people_info(["Sophie (musician)"], resolve_moves: false);
|
||||
|
||||
self::assertEquals(PersonStatus::Dead, $output->results["Sophie (musician)"]["status"]);
|
||||
}
|
||||
|
||||
public function test_query_detects_suicide_person(): void
|
||||
{
|
||||
$output = $this->wikipedia->query_people_info(["Adolf Hitler"], resolve_moves: false);
|
||||
|
||||
|
@ -150,8 +157,8 @@ class WikipediaTest extends TestCase
|
|||
|
||||
public function test_query_detects_possibly_living_person(): void
|
||||
{
|
||||
$output = $this->wikipedia->query_people_info(["Judge Edward Aaron"], resolve_moves: false);
|
||||
$output = $this->wikipedia->query_people_info(["Angela Anderes"], resolve_moves: false);
|
||||
|
||||
self::assertEquals(PersonStatus::PossiblyAlive, $output->results["Judge Edward Aaron"]["status"]);
|
||||
self::assertEquals(PersonStatus::PossiblyAlive, $output->results["Angela Anderes"]["status"]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue