From b8772fd168b1e0ee71968d1022d5a732db9102eb Mon Sep 17 00:00:00 2001 From: Donatello-za Date: Wed, 26 Jun 2024 14:29:59 +0200 Subject: [PATCH] v1.0.19 Release - Updated PHPUnit to v11.2. - Migrated all tests to PHPUnit v11.2. - Test environment will now require PHP 8.3 or later while the rest of the library will still run under PHP 5.4 or later. - Added Swedish language. --- .gitignore | 2 + README.md | 5 +- composer.json | 4 +- lang/sv_SE.pattern | 1 + lang/sv_SE.php | 413 +++++++++++++++++++++++++++++++++ phpunit.xml | 21 +- tests/LangParseOptionsTest.php | 10 +- tests/RakePlusTest.php | 378 +++++++++++++++--------------- tests/bootstrap.php | 4 +- tests/lang_ar_AE_Test.php | 13 +- tests/lang_ckb_IQ_Test.php | 13 +- tests/lang_es_AR_Test.php | 14 +- tests/lang_fr_FR_Test.php | 13 +- tests/lang_sv_SE_Test.php | 36 +++ 14 files changed, 681 insertions(+), 246 deletions(-) create mode 100644 lang/sv_SE.pattern create mode 100644 lang/sv_SE.php create mode 100644 tests/lang_sv_SE_Test.php diff --git a/.gitignore b/.gitignore index 530aed0..d1ccfab 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,8 @@ Homestead.json _ide_helper.php composer.lock composer.phar +.phpunit.result.cache +packages.txt # Compiled source # ################### diff --git a/README.md b/README.md index 1878446..a74cab8 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,14 @@ This particular package intends to include the following benefits over the origi * Turkish/Türkçe (tr_TR) * Persian/Farsi/فارسی (fa_IR) * Dutch/Nederlands (nl_NL) +* Swedish/svenska (sv_SE) > If your language is not listed here it can be added, please see the section called **[How to add additional languages](#how-to-add-additional-languages)** at the bottom of the page. ## Version -v1.0.18 +v1.0.19 ## Special Thanks @@ -541,6 +542,8 @@ site: [stopwords_en_US](./console/stopwords_en_US.txt) ## To run tests +Unit testing is performed using PHPUnit v11.2 running on PHP v8.3.0+. + `./vendor/bin/phpunit tests` ## License diff --git a/composer.json b/composer.json index 63828d4..b54ee57 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,8 @@ "ext-mbstring": "*" }, "require-dev": { - "php": ">=5.5.0", - "phpunit/phpunit": "~4.0|~5.0" + "php": ">8.3.0", + "phpunit/phpunit": "^11.2" }, "autoload": { "psr-4": { diff --git a/lang/sv_SE.pattern b/lang/sv_SE.pattern new file mode 100644 index 0000000..682e310 --- /dev/null +++ b/lang/sv_SE.pattern @@ -0,0 +1 @@ +/\bövre\b|\böverst\b|\bövermorgon\b|\böver\b|\bäven\b|\bär\b|\bännu\b|\bän\b|\båttonde\b|\båttionde\b|\båttio\b|\båtta\b|\båtminstone\b|\båt\b|\bvärre\b|\bvänstra\b|\bvänster\b|\bvårt\b|\bvåra\b|\bvår\b|\bvill\b|\bvilket\b|\bvilken\b|\bvilkas\b|\bvilka\b|\bviktigt\b|\bviktigast\b|\bviktigare\b|\bviktig\b|\bvidare\b|\bvid\b|\bvi\b|\bverkligen\b|\bvems\b|\bvem\b|\bvart\b|\bvarsågod\b|\bvars\b|\bvarken\b|\bvarje\b|\bvarit\b|\bvarifrån\b|\bvarför\b|\bvara\b|\bvar\b|\bvad\b|\bute\b|\butanför\b|\butan\b|\but\b|\bursäkt\b|\bur\b|\bupp\b|\bunder\b|\btvåhundra\b|\btvå\b|\btrettonde\b|\btretton\b|\btrettionde\b|\btrettio\b|\btredje\b|\btre\b|\btolv\b|\btolfte\b|\btjungo\b|\btjugotvå\b|\btjugotre\b|\btjugonde\b|\btjugoett\b|\btjugoen\b|\btjugo\b|\btionde\b|\btio\b|\btillsammans\b|\btills\b|\btill\b|\btidigt\b|\btidigast\b|\btidigare\b|\btidig\b|\btack\b|\bsämst\b|\bsämre\b|\bsäger\b|\bsäga\b|\bsådant\b|\bsådana\b|\bsådan\b|\bså\b|\bstörst\b|\bstörre\b|\bstort\b|\bstora\b|\bstor\b|\bsom\b|\bsnart\b|\bsmått\b|\bsmå\b|\bslutligen\b|\bskulle\b|\bskall\b|\bska\b|\bsjätte\b|\bsjälv\b|\bsjuttonde\b|\bsjutton\b|\bsjuttionde\b|\bsjuttio\b|\bsjunde\b|\bsju\b|\bsitta\b|\bsitt\b|\bsiste\b|\bsista\b|\bsist\b|\bsina\b|\bsin\b|\bsig\b|\bsextonde\b|\bsexton\b|\bsextionde\b|\bsextio\b|\bsex\b|\bsent\b|\bsenast\b|\bsenare\b|\bsedan\b|\bsamma\b|\bsagt\b|\bsade\b|\brätt\b|\bredan\b|\brakt\b|\bpå\b|\boss\b|\bom\b|\bolikt\b|\bolika\b|\boftast\b|\bofta\b|\bockså\b|\boch\b|\bnödvändigtvis\b|\bnödvändigt\b|\bnödvändiga\b|\bnödvändig\b|\bnästa\b|\bnär\b|\bnågra\b|\bnågot\b|\bnågonting\b|\bnågon\b|\bnummer\b|\bnu\b|\bnr\b|\bnoll\b|\bnog\b|\bnittonde\b|\bnitton\b|\bnittionde\b|\bnittio\b|\bnionde\b|\bnio\b|\bni\b|\bner\b|\bnej\b|\bnedre\b|\bnedersta\b|\bnederst\b|\bned\b|\bmöjligtvis\b|\bmöjligt\b|\bmöjligen\b|\bmöjlig\b|\bmåste\b|\bmånga\b|\bmycket\b|\bmot\b|\bmittemot\b|\bmitt\b|\bminst\b|\bmindre\b|\bmina\b|\bmin\b|\bmig\b|\bmest\b|\bmera\b|\bmer\b|\bmen\b|\bmellan\b|\bmed\b|\bman\b|\blättast\b|\blättare\b|\blätt\b|\blängst\b|\blängre\b|\blänge\b|\blångt\b|\blångsamt\b|\blångsammast\b|\blångsammare\b|\blångsam\b|\blitet\b|\bliten\b|\blite\b|\blilla\b|\blikställda\b|\blikställd\b|\blika\b|\bligger\b|\bligga\b|\blegat\b|\bkvar\b|\bkunnat\b|\bkunna\b|\bkunde\b|\bkr\b|\bkommit\b|\bkommer\b|\bkomma\b|\bkom\b|\bknappast\b|\bkanske\b|\bkan\b|\bjämfört\b|\bju\b|\bjag\b|\bja\b|\binuti\b|\binte\b|\binom\b|\binne\b|\binnan\b|\binget\b|\bingenting\b|\bingen\b|\binga\b|\binför\b|\bin\b|\bimorgon\b|\bigår\b|\bigen\b|\bidag\b|\bicke\b|\bibland\b|\bi(?!(-|'))\b|\bhögst\b|\bhögre\b|\bhöger\b|\bhög\b|\bhär\b|\bhur\b|\bhundraett\b|\bhundraen\b|\bhundra\b|\bhonom\b|\bhon\b|\bhit\b|\bhennes\b|\bhenne\b|\bhelt\b|\bhelst\b|\bhellre\b|\bheller\b|\bhar\b|\bhans\b|\bhan\b|\bhaft\b|\bhade\b|\bha\b|\bgöra\b|\bgör\b|\bgärna\b|\bgällt\b|\bgäller\b|\bgälla\b|\bgått\b|\bgår\b|\bgå\b|\bgott\b|\bgodast\b|\bgodare\b|\bgoda\b|\bgod\b|\bgjort\b|\bgjorde\b|\bgick\b|\bgenom\b|\bgenast\b|\bförsta\b|\bförra\b|\bförlåt\b|\bföre\b|\bför\b|\bföljande\b|\bfått\b|\bfår\b|\bfå\b|\bfyrtionde\b|\bfyrtio\b|\bfyra\b|\bfrån\b|\bframför\b|\bfram\b|\bflesta\b|\bflera\b|\bfler\b|\bfjärde\b|\bfjortonde\b|\bfjorton\b|\bfinns\b|\bfinnas\b|\bfin\b|\bfick\b|\bfemtonde\b|\bfemton\b|\bfemtionde\b|\bfemtio\b|\bfemte\b|\bfem\b|\bfanns\b|\bettusen\b|\bett\b|\bert\b|\bera\b|\ber\b|\benligt\b|\benkla\b|\benkelt\b|\benkel\b|\ben\b|\belva\b|\beller\b|\belfte\b|\bej\b|\beftersom\b|\befter\b|\bdärför\b|\bdär\b|\bdå\b|\bdu\b|\bdock\b|\bditt\b|\bdit\b|\bdina\b|\bdin\b|\bdig\b|\bdetta\b|\bdet\b|\bdessa\b|\bdess\b|\bderas\b|\bdenna\b|\bden\b|\bdem\b|\bdelen\b|\bdel\b|\bde\b|\bdagen\b|\bdagarna\b|\bdagar\b|\bdag\b|\bbättre\b|\bbäst\b|\bbådas\b|\bbåda\b|\bbra\b|\bborta\b|\bbort\b|\bblivit\b|\bblir\b|\bbli\b|\bblev\b|\bbland\b|\bbeslutit\b|\bbeslutat\b|\bbeslut\b|\bbehövt\b|\bbehövde\b|\bbehövas\b|\bbehöva\b|\bbara\b|\bbakom\b|\bav\b|\batt\b|\bartonn\b|\bartonde\b|\bannat\b|\bannan\b|\bandras\b|\bandra\b|\balltså\b|\balltid\b|\ballt\b|\ballas\b|\balla\b|\baldrig\b|\badjö\b|\badertonde\b|\baderton\b/i diff --git a/lang/sv_SE.php b/lang/sv_SE.php new file mode 100644 index 0000000..0608a9c --- /dev/null +++ b/lang/sv_SE.php @@ -0,0 +1,413 @@ + - - - - src - - src/autoload.php - - - + + + + src + + + src/autoload.php + + diff --git a/tests/LangParseOptionsTest.php b/tests/LangParseOptionsTest.php index 5f28374..d69e3eb 100644 --- a/tests/LangParseOptionsTest.php +++ b/tests/LangParseOptionsTest.php @@ -1,12 +1,12 @@ -assertInstanceOf(RakePlus::class, $rake, 'RakePlus::create() returned invalid instance'); } - /** - * @expectedException RuntimeException - */ public function testEmptyLanguage() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", ""); } - /** - * @expectedException RuntimeException - */ public function testInvalidLanguage() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", "blah"); } - /** - * @expectedException InvalidArgumentException - */ public function testNullLanguage() { + $this->expectException(InvalidArgumentException::class); RakePlus::create("Hello World", null); } - /** - * @expectedException RuntimeException - */ public function testInvalidLangReturnStringFile() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", __DIR__ . '/test_string_lang.php'); } - /** - * @expectedException RuntimeException - */ public function testInvalidLangReturnEmptyArrayFile() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", __DIR__ . '/test_empty_array_lang.php'); } - /** - * @expectedException RuntimeException - */ public function testEmptyLanguageArray() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", []); } - /** - * @expectedException RuntimeException - */ public function testNonExistingPatternFile() { + $this->expectException(RuntimeException::class); RakePlus::create("Hello World", 'file_does_not_exist.pattern'); } @@ -110,13 +96,13 @@ public function testSortByScoreInstance() public function testPhrasesGetType() { $phrases = RakePlus::create("Hello World")->get(); - $this->assertInternalType('array', $phrases, 'RakePlus::create()->get() array expected'); + $this->assertIsArray($phrases, 'RakePlus::create()->get() array expected'); } public function testScoresGetType() { $scores = RakePlus::create("Hello World")->scores(); - $this->assertInternalType('array', $scores, 'RakePlus::create()->scores() array expected'); + $this->assertIsArray($scores, 'RakePlus::create()->scores() array expected'); } public function testLanguage() @@ -128,7 +114,7 @@ public function testLanguage() public function testLanguageFile() { $language_file = RakePlus::create("Hello World")->languageFile(); - $this->assertContains("/lang/en_US.pattern", $language_file); + $this->assertStringContainsString("/lang/en_US.pattern", $language_file); } public function testArrayProvider() @@ -139,7 +125,8 @@ public function testArrayProvider() "of minimal generating sets of solutions for all types of systems are given."; $stopwords = StopwordArray::create(['of', 'a', 'and', 'set', 'are', 'for']); - RakePlus::create($text, $stopwords); + $phrases = RakePlus::create($text, $stopwords)->get(); + $this->assertCount(17, $phrases); } public function testNonMbPhrases() @@ -151,7 +138,8 @@ public function testNonMbPhrases() "for components of a minimal set of solutions and algorithms of construction " . "of minimal generating sets of solutions for all types of systems are given."; - RakePlus::create($text)->get(); + $phrases = RakePlus::create($text)->get(); + $this->assertCount(16, $phrases); } public function testGetMinLength() @@ -160,11 +148,9 @@ public function testGetMinLength() $this->assertEquals(20, $rake->getMinLength()); } - /** - * @expectedException InvalidArgumentException - */ public function testSetInvalidMinLength() { + $this->expectException(InvalidArgumentException::class); RakePlus::create("Hello World")->setMinLength(-1); } @@ -365,22 +351,22 @@ public function testScoreValuesAsc() $this->assertCount(16, $scores); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['types'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['types']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testScoreValuesDesc() @@ -394,22 +380,22 @@ public function testScoreValuesDesc() $this->assertCount(16, $scores); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['types'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['types']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testArrayStopwords() @@ -421,23 +407,23 @@ public function testArrayStopwords() $scores = RakePlus::create($text, ['of', 'a', 'and', 'set', 'are', 'for'])->sortByScore()->scores(); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['given'], 1); - $this->assertEquals($scores['minimal'], 2); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['all types'], 4); - $this->assertEquals($scores['minimal generating sets'], 8); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(1, $scores['given']); + $this->assertEquals(2, $scores['minimal']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4, $scores['all types']); + $this->assertEquals(8, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testArrayStopwordsNonMb() @@ -452,23 +438,23 @@ public function testArrayStopwordsNonMb() $stopwords = StopwordArray::create(['of', 'a', 'and', 'set', 'are', 'for']); $scores = RakePlus::create($text, $stopwords)->sortByScore()->scores(); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['given'], 1); - $this->assertEquals($scores['minimal'], 2); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['all types'], 4); - $this->assertEquals($scores['minimal generating sets'], 8); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(1, $scores['given']); + $this->assertEquals(2, $scores['minimal']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4, $scores['all types']); + $this->assertEquals(8, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); $this->assertEquals(['of', 'a', 'and', 'set', 'are', 'for'], $stopwords->stopwords()); } @@ -482,22 +468,22 @@ public function testPHPStopwords() $scores = RakePlus::create($text, __DIR__ . '/test_en_US.php')->sortByScore()->scores(); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['types'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['types']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testStopWordArrayInstance() @@ -510,23 +496,23 @@ public function testStopWordArrayInstance() $stopwords = StopwordArray::create(['of', 'a', 'and', 'set', 'are', 'for']); $scores = RakePlus::create($text, $stopwords)->sortByScore()->scores(); - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['given'], 1); - $this->assertEquals($scores['minimal'], 2); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['all types'], 4); - $this->assertEquals($scores['minimal generating sets'], 8); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(1, $scores['given']); + $this->assertEquals(2, $scores['minimal']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4, $scores['all types']); + $this->assertEquals(8, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); $this->assertEquals(['of', 'a', 'and', 'set', 'are', 'for'], $stopwords->stopwords()); } @@ -541,26 +527,26 @@ public function testStopWordPHPInstance() $stopwords = StopwordsPHP::createFromLanguage('en_US'); $scores = RakePlus::create($text, $stopwords)->sortByScore()->scores(); - $this->assertContains("/lang/en_US.php", $stopwords->filename()); - - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['types'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); - - $this->assertInternalType('array', $stopwords->stopwords()); + $this->assertStringContainsString("/lang/en_US.php", $stopwords->filename()); + + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['types']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); + + $this->assertIsArray($stopwords->stopwords()); $this->assertGreaterThan(0, count($stopwords->stopwords())); } @@ -574,24 +560,24 @@ public function testStopWordPatternFileInstance() $stopwords = StopwordsPatternFile::createFromLanguage('en_US'); $scores = RakePlus::create($text, $stopwords)->sortByScore()->scores(); - $this->assertContains("/lang/en_US.pattern", $stopwords->filename()); - - $this->assertEquals($scores['criteria'], 1); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['system'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['solutions'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['types'], 1); - $this->assertEquals($scores['systems'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertStringContainsString("/lang/en_US.pattern", $stopwords->filename()); + + $this->assertEquals(1, $scores['criteria']); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['system']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['solutions']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(1, $scores['types']); + $this->assertEquals(1, $scores['systems']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testFilterNumerics() @@ -601,12 +587,12 @@ public function testFilterNumerics() $rake = RakePlus::create($text, 'en_US', 0, false); $scores = $rake->scores(); - $this->assertEquals(false, $rake->getFilterNumerics()); + $this->assertFalse($rake->getFilterNumerics()); $this->assertCount(3, $scores); - $this->assertEquals($scores['6462'], 0); - $this->assertEquals($scores['wa 12643'], 1); - $this->assertEquals($scores['crest suite 413 lake carlietown'], 16); + $this->assertEquals(0, $scores['6462']); + $this->assertEquals(1, $scores['wa 12643']); + $this->assertEquals(16, $scores['crest suite 413 lake carlietown']); } public function testDonNotFilterNumerics() @@ -616,8 +602,8 @@ public function testDonNotFilterNumerics() $this->assertCount(2, $scores); - $this->assertEquals($scores['wa 12643'], 1); - $this->assertEquals($scores['crest suite 413 lake carlietown'], 16); + $this->assertEquals(1, $scores['wa 12643']); + $this->assertEquals(16, $scores['crest suite 413 lake carlietown']); } public function testMinLengthScores() @@ -631,17 +617,17 @@ public function testMinLengthScores() $this->assertCount(11, $scores); - $this->assertEquals($scores['compatibility'], 1); - $this->assertEquals($scores['considered'], 1); - $this->assertEquals($scores['components'], 1); - $this->assertEquals($scores['algorithms'], 1); - $this->assertEquals($scores['construction'], 1); - $this->assertEquals($scores['strict inequations'], 4); - $this->assertEquals($scores['nonstrict inequations'], 4); - $this->assertEquals($scores['upper bounds'], 4); - $this->assertEquals($scores['minimal set'], 4.5); - $this->assertEquals($scores['minimal generating sets'], 8.5); - $this->assertEquals($scores['linear diophantine equations'], 9); + $this->assertEquals(1, $scores['compatibility']); + $this->assertEquals(1, $scores['considered']); + $this->assertEquals(1, $scores['components']); + $this->assertEquals(1, $scores['algorithms']); + $this->assertEquals(1, $scores['construction']); + $this->assertEquals(4, $scores['strict inequations']); + $this->assertEquals(4, $scores['nonstrict inequations']); + $this->assertEquals(4, $scores['upper bounds']); + $this->assertEquals(4.5, $scores['minimal set']); + $this->assertEquals(8.5, $scores['minimal generating sets']); + $this->assertEquals(9, $scores['linear diophantine equations']); } public function testKeywords() @@ -695,7 +681,7 @@ public function testKeywordsWithNumbers() $this->assertContains('12643', $keywords); foreach ($keywords as $keyword) { - $this->assertInternalType('string', $keyword); + $this->assertIsString($keyword); } } @@ -772,11 +758,9 @@ public function testWithOwnParseOptions() $this->assertContains('time', $phrases); } - /** - * @expectedException InvalidArgumentException - */ public function testWithInvalidParseOptions() { + $this->expectException(InvalidArgumentException::class); $text = "It's of great importance that you're testing this properly. We'll make sure that there's no " . "could've, would've, should've situations this time around."; RakePlus::create($text, 'en_US', 0, false, new stdClass())->get(); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index e6dee48..0680fdd 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,9 @@ namespace DonatelloZa\RakePlus; -function extension_loaded($name) +use RakePlusTest; + +function extension_loaded($name): bool { if ($name === 'mbstring') { return RakePlusTest::$mb_support; diff --git a/tests/lang_ar_AE_Test.php b/tests/lang_ar_AE_Test.php index 6a1a3c3..763fa1a 100644 --- a/tests/lang_ar_AE_Test.php +++ b/tests/lang_ar_AE_Test.php @@ -1,14 +1,13 @@ -assertContains('12643', $keywords); foreach ($keywords as $keyword) { - $this->assertInternalType('string', $keyword); + $this->assertIsString($keyword); } } diff --git a/tests/lang_fr_FR_Test.php b/tests/lang_fr_FR_Test.php index 8c8adac..56f7165 100644 --- a/tests/lang_fr_FR_Test.php +++ b/tests/lang_fr_FR_Test.php @@ -1,14 +1,13 @@ -get(); + + $this->assertCount(33, $phrases); + + $this->assertContains('mytologiska varelser', $phrases); + $this->assertContains('sägs skydda gårdar', $phrases); + $this->assertContains('förförisk kvinnlig varelse', $phrases); + $this->assertContains('fördärv', $phrases); + $this->assertContains('svensk folklore', $phrases); + $this->assertContains('landets rika kulturarv', $phrases); + } +} \ No newline at end of file