Skip to content

Commit c892597

Browse files
committed
Make tests compatible with PHPUnit 9
1 parent 07e67c0 commit c892597

File tree

2 files changed

+18
-32
lines changed

2 files changed

+18
-32
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@
2727
"ext-mbstring": "May require the mbstring PHP extension"
2828
},
2929
"require-dev": {
30-
"phpunit/phpunit": "8.*"
30+
"phpunit/phpunit": "8.*|9.*"
3131
}
3232
}

tests/Text_LanguageDetectTest.php

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -42,41 +42,33 @@ function test_get_data_locPearPath()
4242
);
4343
}
4444

45-
/**
46-
* @expectedException Text_LanguageDetect_Exception
47-
* @expectedExceptionMessage Language database does not exist:
48-
*/
4945
function test_readdbNonexistingFile()
5046
{
47+
$this->expectException('Text_LanguageDetect_Exception');
48+
$this->expectExceptionMessage('Language database does not exist:');
5149
$this->xproxy->_readdb('thisfiledoesnotexist');
5250
}
5351

54-
/**
55-
* @expectedException Text_LanguageDetect_Exception
56-
* @expectedExceptionMessage Language database is not readable:
57-
*/
5852
function test_readdbUnreadableFile()
5953
{
54+
$this->expectException('Text_LanguageDetect_Exception');
55+
$this->expectExceptionMessage('Language database is not readable:');
6056
$name = tempnam(sys_get_temp_dir(), 'unittest-Text_LanguageDetect-');
6157
chmod($name, 0000);
6258
$this->xproxy->_readdb($name);
6359
}
6460

65-
/**
66-
* @expectedException Text_LanguageDetect_Exception
67-
* @expectedExceptionMessage Language database has no elements.
68-
*/
6961
function test_checkTrigramEmpty()
7062
{
63+
$this->expectException('Text_LanguageDetect_Exception');
64+
$this->expectExceptionMessage('Language database has no elements.');
7165
$this->xproxy->_checkTrigram(array());
7266
}
7367

74-
/**
75-
* @expectedException Text_LanguageDetect_Exception
76-
* @expectedExceptionMessage Language database is not an array
77-
*/
7868
function test_checkTrigramNoArray()
7969
{
70+
$this->expectException('Text_LanguageDetect_Exception');
71+
$this->expectExceptionMessage('Language database is not an array');
8072
$this->xproxy->_checkTrigram('foo');
8173
}
8274

@@ -1401,12 +1393,10 @@ function testLanguageExistsArrayNameMode2()
14011393
$this->assertFalse($this->x->languageExists(array('en', 'doesnotexist')));
14021394
}
14031395

1404-
/**
1405-
* @expectedException Text_LanguageDetect_Exception
1406-
* @expectedExceptionMessage Unsupported parameter type passed to languageExists()
1407-
*/
14081396
function testLanguageExistsUnsupportedType()
14091397
{
1398+
$this->expectException('Text_LanguageDetect_Exception');
1399+
$this->expectExceptionMessage('Unsupported parameter type passed to languageExists()');
14101400
$this->x->languageExists(1.23);
14111401
}
14121402

@@ -1428,7 +1418,7 @@ function testGetLanguagesNameMode2()
14281418
function testDetect()
14291419
{
14301420
$scores = $this->x->detect('Das ist ein kleiner Text für euch alle');
1431-
$this->assertInternalType('array', $scores);
1421+
$this->assertIsArray($scores);
14321422
$this->assertGreaterThan(5, count($scores));
14331423

14341424
reset($scores);
@@ -1459,15 +1449,15 @@ function testDetectNameMode2Limit()
14591449
function testDetectSimple()
14601450
{
14611451
$lang = $this->x->detectSimple('Das ist ein kleiner Text für euch alle');
1462-
$this->assertInternalType('string', $lang);
1452+
$this->assertIsString($lang);
14631453
$this->assertEquals('german', $lang, 'text is german');
14641454
}
14651455

14661456
function testDetectSimpleNameMode2()
14671457
{
14681458
$this->x->setNameMode(2);
14691459
$lang = $this->x->detectSimple('Das ist ein kleiner Text für euch alle');
1470-
$this->assertInternalType('string', $lang);
1460+
$this->assertIsString($lang);
14711461
$this->assertEquals('de', $lang, 'text is german');
14721462
}
14731463

@@ -1687,21 +1677,17 @@ function test_block_detection()
16871677
}
16881678
}
16891679

1690-
/**
1691-
* @expectedException Text_LanguageDetect_Exception
1692-
* @expectedExceptionMessage Pass a single char only to this method
1693-
*/
16941680
function testUnicodeBlockNameParamString()
16951681
{
1682+
$this->expectException('Text_LanguageDetect_Exception');
1683+
$this->expectExceptionMessage('Pass a single char only to this method');
16961684
$this->x->unicodeBlockName('foo bar baz');
16971685
}
16981686

1699-
/**
1700-
* @expectedException Text_LanguageDetect_Exception
1701-
* @expectedExceptionMessage Input must be of type string or int
1702-
*/
17031687
function testUnicodeBlockNameUnsupportedParamType()
17041688
{
1689+
$this->expectException('Text_LanguageDetect_Exception');
1690+
$this->expectExceptionMessage('Input must be of type string or int');
17051691
$this->x->unicodeBlockName(1.23);
17061692
}
17071693

0 commit comments

Comments
 (0)