From e286e2a1b7e7dc1db43df39f3dfbf033ad83ab61 Mon Sep 17 00:00:00 2001 From: GlazerMann Date: Fri, 27 Dec 2024 17:12:24 -0600 Subject: [PATCH] White space and better loggin --- tests/phpunit/constantsTest.php | 55 +++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/tests/phpunit/constantsTest.php b/tests/phpunit/constantsTest.php index 190fce2228..ffd17b45c9 100644 --- a/tests/phpunit/constantsTest.php +++ b/tests/phpunit/constantsTest.php @@ -56,6 +56,7 @@ public function testConstantsDefined(): void { } public function testConstantsOoops(): void { // Did we forget to upper/lower case one of them? + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging for ($i = 0; $i < count(JOURNAL_ACRONYMS); $i++) { $this->assertNotEquals(trim(JOURNAL_ACRONYMS[$i]), trim(UCFIRST_JOURNAL_ACRONYMS[$i])); } @@ -65,6 +66,7 @@ public function testConstantsOoops(): void { // Did we forget to upper/lower cas } public function testForDisasters(): void { // Did we get things out of order and cause a disaster? + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $this->assertSame('BJPsych', title_capitalization('Bjpsych', true)); $this->assertSame('HortScience', title_capitalization('Hortscience', true)); $this->assertSame('TheMarker', title_capitalization('Themarker', true)); @@ -78,6 +80,7 @@ public function testForDisasters(): void { // Did we get things out of order and } public function testImplicitConstants(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging // Consonants $this->assertSame('X', title_capitalization('x', true)); $this->assertSame('Xz', title_capitalization('xz', true)); @@ -96,6 +99,7 @@ public function testImplicitConstants(): void { } public function testAllLowerCase(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $big_array = array_merge(HAS_NO_VOLUME, BAD_ACCEPTED_MANUSCRIPT_TITLES, BAD_AUTHORS, PUBLISHER_ENDINGS, BAD_TITLES, IN_PRESS_ALIASES, NON_PUBLISHERS, JOURNAL_IS_BOOK_SERIES, HAS_NO_ISSUE, WORKS_ARE_PUBLISHERS, PREFER_VOLUMES, @@ -106,6 +110,7 @@ public function testAllLowerCase(): void { } public function testMinimized(): void { // See is_book_series() function + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $big_array = JOURNAL_IS_BOOK_SERIES; foreach ($big_array as $actual) { $simple = trim(str_replace(['-', '.', ' ', ' ', '[[', ']]'], [' ', ' ', ' ', ' ', ' ', ' '], $actual)); @@ -115,6 +120,7 @@ public function testMinimized(): void { // See is_book_series() function } public function testAllFreeOfUTF(): void { // If this fails, then we have to switch everything to MB_ (BAD_AUTHORS, HAS_NO_ISSUE already has UTF-8) + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $big_array = array_merge(HAS_NO_VOLUME, BAD_ACCEPTED_MANUSCRIPT_TITLES, PUBLISHER_ENDINGS, BAD_TITLES, IN_PRESS_ALIASES, NON_PUBLISHERS, JOURNAL_IS_BOOK_SERIES, WORKS_ARE_PUBLISHERS, PREFER_VOLUMES, @@ -129,6 +135,7 @@ public function testAllFreeOfUTF(): void { // If this fails, then we have to swi } public function testNoSpacesOnEnds(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $big_array = array_merge(HAS_NO_VOLUME, BAD_ACCEPTED_MANUSCRIPT_TITLES, BAD_AUTHORS, PUBLISHER_ENDINGS, BAD_TITLES, IN_PRESS_ALIASES, NON_PUBLISHERS, JOURNAL_IS_BOOK_SERIES, HAS_NO_ISSUE, WORKS_ARE_PUBLISHERS, PREFER_VOLUMES, @@ -141,6 +148,7 @@ public function testNoSpacesOnEnds(): void { } public function testAtoZ(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $leader = true; $start_alpha = '/* The following will be automatically updated to alphabetical order */'; $end_alpha = '/* The above will be automatically updated to alphabetical order */'; @@ -193,6 +201,7 @@ public function testAtoZ(): void { } public function testWhiteList(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $we_failed = false; $our_original_whitelist = PARAMETER_LIST; $our_whitelist = array_unique($our_original_whitelist); @@ -252,6 +261,7 @@ public function testWhiteList(): void { } public function testWhiteListNotBlacklisted(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $whitelist = array_merge(DEAD_PARAMETERS, PARAMETER_LIST); $orig = ''; $new = ''; @@ -289,6 +299,7 @@ public function testWhiteListNotBlacklisted(): void { } public function testDead(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $overlap = array_intersect(DEAD_PARAMETERS, PARAMETER_LIST); if (empty($overlap)) { $this->assertTrue(true); @@ -301,6 +312,7 @@ public function testDead(): void { } public function testMagazinesAndNot(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $overlap = array_intersect(ARE_MAGAZINES, ARE_MANY_THINGS); if (empty($overlap)) { $this->assertTrue(true); @@ -331,6 +343,7 @@ public function testMagazinesAndNot(): void { } public function testAuthorsFlat() { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $failed = false; $test_flat = []; foreach (AUTHOR_PARAMETERS as $array) { @@ -374,6 +387,7 @@ public function testAuthorsFlat() { } public function testNonJournalList() { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $flat = NON_JOURNAL_WEBSITES; sort($flat); $failed = false; @@ -409,6 +423,7 @@ public function testNonJournalList() { } public function testNonJournalListIsNotBad() { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $failed = false; foreach (CANONICAL_PUBLISHER_URLS as $journal) { $journal = $journal . '/'; @@ -450,6 +465,7 @@ public function testNonJournalListIsNotBad() { } public function testItalicsOrder(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $in_order = true; $spaces_at = 99999999; $max_spaces = 0; @@ -497,6 +513,7 @@ public function testItalicsOrder(): void { } public function testItalicsNoDuplicates(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $italics = explode("|", ITALICS_LIST); sort($italics); $last = "123412341234"; @@ -514,6 +531,7 @@ public function testItalicsNoDuplicates(): void { } public function testCamelNoDuplicates(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $italics = CAMEL_CASE; sort($italics); $last = "123412341234"; @@ -532,31 +550,37 @@ public function testCamelNoDuplicates(): void { public function testItalicsEscaped1(): void { - $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); - $this->assertSame(0 , substr_count($italics, '(')); + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging + $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); + $this->assertSame(0 , substr_count($italics, '(')); } public function testItalicsEscaped2(): void { - $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); - $this->assertSame(0 , substr_count($italics, ')')); + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging + $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); + $this->assertSame(0 , substr_count($italics, ')')); } public function testItalicsEscaped3(): void { - $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); - $this->assertSame(0 , substr_count($italics, '\\')); + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging + $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); + $this->assertSame(0 , substr_count($italics, '\\')); } public function testItalicsEscaped4(): void { - $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); - $this->assertSame(0 , substr_count($italics, '.')); + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging + $italics = str_replace(['\\(', '\\)', '\\.'], '', ITALICS_LIST); + $this->assertSame(0 , substr_count($italics, '.')); } - public function testItalicsNoSpaces(): void { + public function testItalicsNoSpaces(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $italics = explode("|", ITALICS_LIST); foreach ($italics as $item) { $this->assertNotEquals(' ', substr($item, 0, 1)); $this->assertNotEquals(' ', substr($item, -1)); } - } + } - public function testItalicsHardCode(): void { + public function testItalicsHardCode(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $this->assertSame(count(ITALICS_HARDCODE_IN), count(ITALICS_HARDCODE_OUT)); for ($i = 0; $i < count(ITALICS_HARDCODE_OUT); $i++) { $this->assertSame(0, substr_count("'''", ITALICS_HARDCODE_IN[$i])); @@ -565,9 +589,9 @@ public function testItalicsHardCode(): void { $out = str_replace(["'", " ", ':', ',', '.'], ['', '', '', '', ''], ITALICS_HARDCODE_OUT[$i]); $this->assertSame($in, $out); // Same once spaces and single quotes are removed } - } + } - public function testConversionsGood(): void { + public function testConversionsGood(): void { WikipediaBot::make_ch(); $page = new TestPage(); $errors = ""; @@ -598,6 +622,7 @@ public function testConversionsGood(): void { } public function testFreeDOI(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging foreach (DOI_FREE_PREFIX as $prefix) { $this->assertTrue($prefix != ''); if (strpos($prefix, '/') === false) { @@ -607,6 +632,7 @@ public function testFreeDOI(): void { } public function testISBNlist(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $last = -1; foreach (ISBN_HYPHEN_POS as $k => $v) { $k = (int) $k; @@ -620,18 +646,21 @@ public function testISBNlist(): void { } public function testForISBNListUpdates(): void { // https://en.wikipedia.org/w/index.php?title=Module:Format_ISBN/data&action=history + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $wikipedia_response = WikipediaBot::GetAPage('Module:Format_ISBN/data'); $this->assertSame(1, substr_count($wikipedia_response, 'RangeMessage timestamp:')); $this->assertSame(1, substr_count($wikipedia_response, ISBN_TIME_STAMP_USED)); } public function testCurlLimit(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $ch = curl_init(); $this->assertSame(1, curl_limit_page_size($ch, 1, 134217729)); $this->assertSame(0, curl_limit_page_size($ch, 1, 134217728)); } public function testDoubleMap(): void { + $pg = new TestPage(); unset($pg); // Fill page name with test name for debugging $errors = ''; $all_maps = array_merge(COMMON_MISTAKES, COMMON_MISTAKES_TOOL); $okay_to_be_bad = ['coauthors', 'deadurl', 'lay-date', 'lay-source', 'lay-url', 'month', 'authors']; // We upgrade dead paramters to better dead parameters