Skip to content

Commit

Permalink
chore: improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tintnaingwinn committed Jun 17, 2023
1 parent 6fef071 commit c106974
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 29 deletions.
14 changes: 2 additions & 12 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,26 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Ageekdev Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<source>
<include>
<directory suffix=".php">src/</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
</source>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
Expand Down
8 changes: 4 additions & 4 deletions tests/DataTestHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@

trait DataTestHelper
{
protected function myanmarNumber(): string
public function myanmarNumber(): string
{
return '၁၂၃၄၅၆၇၈၉၀';
}

protected function englishNumber(): string
public function englishNumber(): string
{
return 1234567890;
}

protected function thaiNumber(): string
public function thaiNumber(): string
{
return '๑๒๓๔๕๖๗๘๙๐';
}

protected function myanmarShanNumber(): string
public function myanmarShanNumber(): string
{
return '႑႒႓႔႕႖႗႘႙႐';
}
Expand Down
12 changes: 8 additions & 4 deletions tests/HelperTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?php

it('convert english to myanmar', function () {
$this->assertSame($this->myanmarNumber(), num_convert($this->englishNumber(), 'mm', 'en'));
expect(num_convert($this->englishNumber(), 'mm', 'en'))
->toEqual($this->myanmarNumber());
});

it('convert to myanmar ', function () {
$this->assertSame($this->myanmarNumber(), num_to_mm($this->englishNumber()));
expect(num_to_mm($this->englishNumber()))
->toEqual($this->myanmarNumber());
});

it('convert to thai', function () {
$this->assertSame($this->thaiNumber(), num_to_th($this->englishNumber()));
expect(num_to_th($this->englishNumber()))
->toEqual($this->thaiNumber());
});

it('convert to english', function () {
$this->assertSame($this->englishNumber(), num_to_eng($this->thaiNumber()));
expect(num_to_eng($this->thaiNumber()))
->toEqual($this->englishNumber());
});
16 changes: 11 additions & 5 deletions tests/NumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@
use Illuminate\Support\Facades\Config;

it('convert english to myanmar', function () {
$this->assertSame($this->myanmarNumber(), Num::convert($this->englishNumber(), 'mm', 'en'));
expect(Num::convert($this->englishNumber(), 'mm', 'en'))
->toEqual($this->myanmarNumber());
});

it('convert to myanmar ', function () {
$this->assertSame($this->myanmarNumber(), Num::toMyanmar($this->englishNumber()));
expect(Num::toMyanmar($this->englishNumber()))
->toEqual($this->myanmarNumber());
});

it('convert to thai', function () {
$this->assertSame($this->thaiNumber(), Num::toThai($this->englishNumber()));
expect(Num::toThai($this->englishNumber()))
->toEqual($this->thaiNumber());
});

it('convert to english', function () {
$this->assertSame($this->englishNumber(), Num::toEnglish($this->thaiNumber()));
expect(Num::toEnglish($this->thaiNumber()))
->toEqual($this->englishNumber());
});

it('throws $to invalid argument exception', function () {
Expand All @@ -29,5 +33,7 @@

it('convert to myanmar shan', function () {
Config::set('num.zeros.shan', '');
$this->assertSame($this->myanmarShanNumber(), Num::convert($this->englishNumber(), 'shan'));

expect(Num::convert($this->englishNumber(), 'shan'))
->toEqual($this->myanmarShanNumber());
});
3 changes: 2 additions & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use AgeekDev\Num\Tests\DataTestHelper;
use AgeekDev\Num\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
uses(TestCase::class, DataTestHelper::class)->in(__DIR__);
3 changes: 0 additions & 3 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@

abstract class TestCase extends Orchestra
{
use DataTestHelper;

/**
* @param \Illuminate\Foundation\Application $app
* @return array
*/
protected function getPackageProviders($app): array
{
Expand Down

0 comments on commit c106974

Please sign in to comment.