Skip to content

Commit

Permalink
Test enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Jul 11, 2018
1 parent 4ae43ce commit 3a0cc51
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 22 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
@@ -1,12 +1,10 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm
- nightly

Expand Down
10 changes: 7 additions & 3 deletions composer.json
Expand Up @@ -10,15 +10,19 @@
}
],
"require": {
"php": "^5.3|^7.0",
"php": ">=5.6",
"ext-gmp": "*"
},
"require-dev": {
"phpunit/phpunit": "^4.1|^5.2"
"phpunit/phpunit": "^5.7 || ^6.5"
},
"autoload": {
"psr-4": {
"Thunder\\Numbase\\": "src/",
"Thunder\\Numbase\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Thunder\\Numbase\\Tests\\": "tests/"
}
}
Expand Down
16 changes: 9 additions & 7 deletions tests/ConverterTest.php
Expand Up @@ -5,11 +5,13 @@
use Thunder\Numbase\Converter\GmpConverter;
use Thunder\Numbase\Converter\GmpStrvalConverter;
use Thunder\Numbase\Symbols\Base62Symbols;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class ConverterTest extends \PHPUnit_Framework_TestCase
final class ConverterTest extends TestCase
{
public function testGmpConverter()
{
Expand All @@ -30,21 +32,21 @@ public function testGmpStrvalDigits()
public function testGmpStrvalExceptionOnInvalidSourceBase()
{
$converter = new GmpStrvalConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('10', 1, 10);
}

public function testGmpStrvalExceptionOnInvalidTargetBase()
{
$converter = new GmpStrvalConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('10', 10, 63);
}

public function testGmpStrvalExceptionOnEmptyNumber()
{
$converter = new GmpStrvalConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('', 10, 20);
}

Expand All @@ -60,21 +62,21 @@ public function testBaseConvertDigits()
public function testBaseConvertExceptionOnInvalidSourceBase()
{
$converter = new BaseConvertConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('10', 40, 10);
}

public function testBaseConvertExceptionOnInvalidTargetBase()
{
$converter = new BaseConvertConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('10', 10, 40);
}

public function testBaseConvertExceptionOnEmptyNumber()
{
$converter = new BaseConvertConverter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$converter->convert('', 10, 20);
}
}
6 changes: 4 additions & 2 deletions tests/FormatterTest.php
Expand Up @@ -5,11 +5,13 @@
use Thunder\Numbase\Formatter\FallbackFormatter;
use Thunder\Numbase\Formatter\StrictFormatter;
use Thunder\Numbase\Symbols\Base62Symbols;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class FormatterTest extends \PHPUnit_Framework_TestCase
final class FormatterTest extends TestCase
{
public function testFormatters()
{
Expand All @@ -31,7 +33,7 @@ public function testFormatters()
public function testExceptionInvalidSymbolStrictFormatter()
{
$formatter = new StrictFormatter(new Base62Symbols());
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$formatter->format(array(100), false);
}
}
10 changes: 6 additions & 4 deletions tests/NumbaseTest.php
Expand Up @@ -7,11 +7,13 @@
use Thunder\Numbase\Symbols\ArraySymbols;
use Thunder\Numbase\Symbols\Base62Symbols;
use Thunder\Numbase\Symbols\StringSymbols;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class NumbaseTest extends \PHPUnit_Framework_TestCase
final class NumbaseTest extends TestCase
{
/**
* @dataProvider provideNumbase
Expand Down Expand Up @@ -90,21 +92,21 @@ public function testOtherFormatters()
public function testExceptionOnInvalidSourceBase()
{
$numbase = Numbase::createDefault();
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$numbase->convert(10, 1, 16);
}

public function testExceptionOnInvalidTargetBase()
{
$numbase = Numbase::createDefault();
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$numbase->convert(10, 10, -20);
}

public function testExceptionOnEmptyNumber()
{
$numbase = Numbase::createDefault();
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$numbase->convert('', 10, 10);
}
}
8 changes: 5 additions & 3 deletions tests/SymbolsTest.php
Expand Up @@ -5,11 +5,13 @@
use Thunder\Numbase\Symbols\Base10Symbols;
use Thunder\Numbase\Symbols\Base62Symbols;
use Thunder\Numbase\Symbols\StringSymbols;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;

/**
* @author Tomasz Kowalczyk <tomasz@kowalczyk.cc>
*/
final class SymbolsTest extends \PHPUnit_Framework_TestCase
final class SymbolsTest extends TestCase
{
public function testBase62Symbols()
{
Expand Down Expand Up @@ -62,14 +64,14 @@ public function testStringSymbols()
public function testExceptionMissingSymbol()
{
$symbols = new Base62Symbols();
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$symbols->getSymbol('#');
}

public function testExceptionMissingValue()
{
$symbols = new Base62Symbols();
$this->setExpectedException('InvalidArgumentException');
$this->expectException(InvalidArgumentException::class);
$symbols->getValue('#');
}
}

0 comments on commit 3a0cc51

Please sign in to comment.