Include Vendor

This commit is contained in:
Mathieu Lagace
2018-06-27 20:31:54 -04:00
parent d0807a7cf5
commit 5fa3c85b97
6624 changed files with 728653 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
<?php
namespace Faker\Test\Provider\zh_TW;
use Faker\Generator;
use Faker\Provider\zh_TW\Company;
class CompanyTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Generator
*/
private $faker;
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Company($faker));
$this->faker = $faker;
}
public function testVAT()
{
$this->assertEquals(8, floor(log10($this->faker->VAT) + 1));
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Faker\Test\Provider\zh_TW;
use Faker\Generator;
use Faker\Provider\zh_TW\Person;
class PersonTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Generator
*/
private $faker;
public function setUp()
{
$faker = new Generator();
$faker->addProvider(new Person($faker));
$this->faker = $faker;
}
/**
* @see https://zh.wikipedia.org/wiki/%E4%B8%AD%E8%8F%AF%E6%B0%91%E5%9C%8B%E5%9C%8B%E6%B0%91%E8%BA%AB%E5%88%86%E8%AD%89
*/
public function testPersonalIdentityNumber()
{
$id = $this->faker->personalIdentityNumber;
$firstChar = substr($id, 0, 1);
$codesString = Person::$idBirthplaceCode[$firstChar] . substr($id, 1);
// After transfer the first alphabet word into 2 digit number, there should be totally 11 numbers
$this->assertRegExp("/^[0-9]{11}$/", $codesString);
$total = 0;
$codesArray = str_split($codesString);
foreach ($codesArray as $key => $code) {
$total += $code * Person::$idDigitValidator[$key];
}
// Validate
$this->assertEquals(0, ($total % 10));
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace Faker\Test\Provider\zh_TW;
class TextTest extends \PHPUnit_Framework_TestCase
{
private $textClass;
public function setUp()
{
$this->textClass = new \ReflectionClass('Faker\Provider\zh_TW\Text');
}
protected function getMethod($name) {
$method = $this->textClass->getMethod($name);
$method->setAccessible(true);
return $method;
}
/** @test */
function testItShouldExplodeTheStringToArray()
{
$this->assertSame(
array('中', '文', '測', '試', '真', '有', '趣'),
$this->getMethod('explode')->invokeArgs(null, array('中文測試真有趣'))
);
$this->assertSame(
array('標', '點', '', '符', '號', ''),
$this->getMethod('explode')->invokeArgs(null, array('標點,符號!'))
);
}
/** @test */
function testItShouldReturnTheStringLength()
{
$this->assertContains(
$this->getMethod('strlen')->invokeArgs(null, array('中文測試真有趣')),
array(7, 21)
);
}
/** @test */
function testItShouldReturnTheCharacterIsValidStartOrNot()
{
$this->assertTrue($this->getMethod('validStart')->invokeArgs(null, array('中')));
$this->assertTrue($this->getMethod('validStart')->invokeArgs(null, array('2')));
$this->assertTrue($this->getMethod('validStart')->invokeArgs(null, array('Hello')));
$this->assertFalse($this->getMethod('validStart')->invokeArgs(null, array('。')));
$this->assertFalse($this->getMethod('validStart')->invokeArgs(null, array('')));
}
/** @test */
function testItShouldAppendEndPunctToTheEndOfString()
{
$this->assertSame(
'中文測試真有趣。',
$this->getMethod('appendEnd')->invokeArgs(null, array('中文測試真有趣'))
);
$this->assertSame(
'中文測試真有趣。',
$this->getMethod('appendEnd')->invokeArgs(null, array('中文測試真有趣,'))
);
$this->assertSame(
'中文測試真有趣!',
$this->getMethod('appendEnd')->invokeArgs(null, array('中文測試真有趣!'))
);
}
}