Skip to content

Commit

Permalink
Test enhancement (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k authored and hoshomoh committed May 23, 2018
1 parent 74a7e2f commit 6cd5913
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- nightly

matrix:
allow_failures:
- php: nightly

install:
- composer install --no-interaction
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
],
"minimum-stability": "dev",
"require": {
"php": ">=5.6"
"php": ">=5.6",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "^5.7"
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.0"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion tests/src/CsvValidatorParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@


use Oshomo\CsvUtils\Tests\src\UppercaseRule;
use PHPUnit\Framework\TestCase;

class CsvValidatorParserTest extends \PHPUnit_Framework_TestCase
class CsvValidatorParserTest extends TestCase
{
public function testWhenCustomRuleIsPassed()
{
Expand Down
51 changes: 50 additions & 1 deletion tests/src/CsvValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
use Oshomo\CsvUtils\Converter\JsonConverter;
use Oshomo\CsvUtils\Converter\XmlConverter;
use Oshomo\CsvUtils\Tests\src\UppercaseRule;
use PHPUnit\Framework\TestCase;

class CsvValidatorTest extends \PHPUnit_Framework_TestCase
class CsvValidatorTest extends TestCase
{
/**
* Test Assets Folder Path
Expand Down Expand Up @@ -272,6 +273,54 @@ public function testValidatorXmlWriter()
);
}

public function testValidatorCsvOnEmptyRule()
{
$file = $this->testAssets . "/valid_test.csv";

$expectedArray = [
'message' => 'CSV is valid.',
'data' => [
[
'name' => 'Well Health Hotels',
'address' => 'Inga N. P.O. Box 567',
'stars' => '3',
'contact' => 'Kasper Zen',
'uri' => 'http://well.org'
]
]
];

$validator = new Validator($file, ',', [
"stars" => ['']
]);

$this->assertSame($expectedArray, $validator->validate());
}

public function testValidatorCsvIsValid()
{
$file = $this->testAssets . "/valid_test.csv";

$validator = new Validator($file, ',', [
"stars" => ["between:3,10"]
]);

$expectedArray = [
'message' => 'CSV is valid.',
'data' => [
[
'name' => 'Well Health Hotels',
'address' => 'Inga N. P.O. Box 567',
'stars' => '3',
'contact' => 'Kasper Zen',
'uri' => 'http://well.org'
]
]
];

$this->assertSame($expectedArray, $validator->validate());
}

public function testValidatorXmlWriterWithRecordElementParameter()
{
$file = $this->testAssets . "/valid_test.csv";
Expand Down

0 comments on commit 6cd5913

Please sign in to comment.