Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Commit

Permalink
Refactoring tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carusogabriel committed Dec 3, 2017
1 parent aa72da4 commit c1a2177
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions test/Faker/DefaultGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ class DefaultGeneratorTest extends TestCase
public function testGeneratorReturnsNullByDefault()
{
$generator = new DefaultGenerator;
$this->assertSame(null, $generator->value);
$this->assertNull($generator->value);
}

public function testGeneratorReturnsDefaultValueForAnyPropertyGet()
{
$generator = new DefaultGenerator(123);
$this->assertSame(123, $generator->foo);
$this->assertNotSame(null, $generator->bar);
$this->assertNotNull($generator->bar);
}

public function testGeneratorReturnsDefaultValueForAnyMethodCall()
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function testGetFormatterReturnsCallable()
$generator = new Generator;
$provider = new FooProvider();
$generator->addProvider($provider);
$this->assertTrue(is_callable($generator->getFormatter('fooFormatter')));
$this->assertInternalType('callable', $generator->getFormatter('fooFormatter'));
}

public function testGetFormatterReturnsCorrectFormatter()
Expand Down
32 changes: 16 additions & 16 deletions test/Faker/Provider/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ class BaseTest extends TestCase
{
public function testRandomDigitReturnsInteger()
{
$this->assertTrue(is_integer(BaseProvider::randomDigit()));
$this->assertInternalType('integer', BaseProvider::randomDigit());
}

public function testRandomDigitReturnsDigit()
{
$this->assertTrue(BaseProvider::randomDigit() >= 0);
$this->assertTrue(BaseProvider::randomDigit() < 10);
$this->assertGreaterThanOrEqual(0, BaseProvider::randomDigit());
$this->assertLessThan(10, BaseProvider::randomDigit());
}

public function testRandomDigitNotNullReturnsNotNullDigit()
{
$this->assertTrue(BaseProvider::randomDigitNotNull() > 0);
$this->assertTrue(BaseProvider::randomDigitNotNull() < 10);
$this->assertGreaterThan(0, BaseProvider::randomDigitNotNull());
$this->assertLessThan(10, BaseProvider::randomDigitNotNull());
}


public function testRandomDigitNotReturnsValidDigit()
{
for ($i = 0; $i <= 9; $i++) {
$this->assertTrue(BaseProvider::randomDigitNot($i) >= 0);
$this->assertTrue(BaseProvider::randomDigitNot($i) < 10);
$this->assertTrue(BaseProvider::randomDigitNot($i) !== $i);
$this->assertGreaterThanOrEqual(0, BaseProvider::randomDigitNot($i));
$this->assertLessThan(10, BaseProvider::randomDigitNot($i));
$this->assertNotSame(BaseProvider::randomDigitNot($i), $i);
}
}

Expand All @@ -52,14 +52,14 @@ public function testRandomNumberThrowsExceptionWhenCalledWithATooHighNumberOfDig

public function testRandomNumberReturnsInteger()
{
$this->assertTrue(is_integer(BaseProvider::randomNumber()));
$this->assertTrue(is_integer(BaseProvider::randomNumber(5, false)));
$this->assertInternalType('integer', BaseProvider::randomNumber());
$this->assertInternalType('integer', BaseProvider::randomNumber(5, false));
}

public function testRandomNumberReturnsDigit()
{
$this->assertTrue(BaseProvider::randomNumber(3) >= 0);
$this->assertTrue(BaseProvider::randomNumber(3) < 1000);
$this->assertGreaterThanOrEqual(0, BaseProvider::randomNumber(3));
$this->assertLessThan(1000, BaseProvider::randomNumber(3));
}

public function testRandomNumberAcceptsStrictParamToEnforceNumberSize()
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testRandomFloat()

public function testRandomLetterReturnsString()
{
$this->assertTrue(is_string(BaseProvider::randomLetter()));
$this->assertInternalType('string', BaseProvider::randomLetter());
}

public function testRandomLetterReturnsSingleLetter()
Expand All @@ -110,12 +110,12 @@ public function testRandomLetterReturnsSingleLetter()
public function testRandomLetterReturnsLowercaseLetter()
{
$lowercaseLetters = 'abcdefghijklmnopqrstuvwxyz';
$this->assertTrue(strpos($lowercaseLetters, BaseProvider::randomLetter()) !== false);
$this->assertNotFalse(strpos($lowercaseLetters, BaseProvider::randomLetter()));
}

public function testRandomAsciiReturnsString()
{
$this->assertTrue(is_string(BaseProvider::randomAscii()));
$this->assertInternalType('string', BaseProvider::randomAscii());
}

public function testRandomAsciiReturnsSingleCharacter()
Expand All @@ -126,7 +126,7 @@ public function testRandomAsciiReturnsSingleCharacter()
public function testRandomAsciiReturnsAsciiCharacter()
{
$lowercaseLetters = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~';
$this->assertTrue(strpos($lowercaseLetters, BaseProvider::randomAscii()) !== false);
$this->assertNotFalse(strpos($lowercaseLetters, BaseProvider::randomAscii()));
}

public function testRandomElementReturnsNullWhenArrayEmpty()
Expand Down
4 changes: 2 additions & 2 deletions test/Faker/Provider/DateTimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ public function testUnixTime()
{
$timestamp = DateTimeProvider::unixTime();
$this->assertInternalType('int', $timestamp);
$this->assertTrue($timestamp >= 0);
$this->assertTrue($timestamp <= time());
$this->assertGreaterThanOrEqual(0, $timestamp);
$this->assertLessThanOrEqual(time(), $timestamp);
}

public function testDateTime()
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function loadLocalProviders($locale)

public function testCreditCardTypeReturnsValidVendorName()
{
$this->assertTrue(in_array($this->faker->creditCardType, array('Visa', 'MasterCard', 'American Express', 'Discover Card')));
$this->assertContains($this->faker->creditCardType, array('Visa', 'MasterCard', 'American Express', 'Discover Card'));
}

public function creditCardNumberProvider()
Expand Down
2 changes: 1 addition & 1 deletion test/Faker/Provider/kk_KZ/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ public function testIndividualIdentificationNumberIsValid()
$individualIdentificationNumber = $this->faker->individualIdentificationNumber($birthDate);
$controlDigit = Person::checkSum($individualIdentificationNumber);

$this->assertTrue($controlDigit === (int)substr($individualIdentificationNumber, 11, 1));
$this->assertSame($controlDigit, (int)substr($individualIdentificationNumber, 11, 1));
}
}
4 changes: 2 additions & 2 deletions test/Faker/Provider/nl_BE/PersonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public function setUp()
public function testRrnIsValid()
{
$rrn = $this->faker->rrn();

$this->assertEquals(11, strlen($rrn));

$ctrlNumber = substr($rrn, 9, 2);
$calcCtrl = 97 - (substr($rrn, 0, 9) % 97);
$altcalcCtrl = 97 - ((2 . substr($rrn, 0, 9)) % 97);
$this->assertTrue(in_array($ctrlNumber, array($calcCtrl, $altcalcCtrl)));
$this->assertContains($ctrlNumber, array($calcCtrl, $altcalcCtrl));

$middle = substr($rrn, 6, 3);
$this->assertGreaterThan(1, $middle);
Expand Down

0 comments on commit c1a2177

Please sign in to comment.