Skip to content

Commit

Permalink
Make use of the …::class feature
Browse files Browse the repository at this point in the history
  • Loading branch information
thiemowmde committed Sep 28, 2017
1 parent e0182d6 commit f36bfd0
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions tests/DataValues/MonolingualTextValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DataValues\Tests;

use DataValues\IllegalValueException;
use DataValues\MonolingualTextValue;

/**
Expand All @@ -23,7 +24,7 @@ class MonolingualTextValueTest extends DataValueTest {
* @return string
*/
public function getClass() {
return 'DataValues\MonolingualTextValue';
return MonolingualTextValue::class;
}

public function validConstructorArgumentsProvider() {
Expand Down Expand Up @@ -58,7 +59,7 @@ public function testNewFromArray() {
* @dataProvider invalidArrayProvider
*/
public function testNewFromArrayWithInvalidArray( array $array ) {
$this->setExpectedException( 'DataValues\IllegalValueException' );
$this->setExpectedException( IllegalValueException::class );
MonolingualTextValue::newFromArray( $array );
}

Expand Down
7 changes: 4 additions & 3 deletions tests/DataValues/MultilingualTextValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DataValues\Tests;

use DataValues\IllegalValueException;
use DataValues\MonolingualTextValue;
use DataValues\MultilingualTextValue;

Expand All @@ -24,7 +25,7 @@ class MultilingualTextValueTest extends DataValueTest {
* @return string
*/
public function getClass() {
return 'DataValues\MultilingualTextValue';
return MultilingualTextValue::class;
}

public function validConstructorArgumentsProvider() {
Expand Down Expand Up @@ -90,7 +91,7 @@ public function testNewFromArray() {
* @dataProvider invalidArrayProvider
*/
public function testNewFromArrayWithInvalidArray( array $array ) {
$this->setExpectedException( 'DataValues\IllegalValueException' );
$this->setExpectedException( IllegalValueException::class );
MultilingualTextValue::newFromArray( $array );
}

Expand Down Expand Up @@ -131,7 +132,7 @@ public function testGetTexts( MultilingualTextValue $texts, array $arguments ) {
$actual = $texts->getTexts();

$this->assertInternalType( 'array', $actual );
$this->assertContainsOnlyInstancesOf( '\DataValues\MonolingualTextValue', $actual );
$this->assertContainsOnlyInstancesOf( MonolingualTextValue::class, $actual );
$this->assertEquals( $arguments[0], array_values( $actual ) );
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ValueFormatters/StringFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ValueFormatters\Test;

use DataValues\StringValue;
use InvalidArgumentException;
use ValueFormatters\FormatterOptions;
use ValueFormatters\StringFormatter;

Expand Down Expand Up @@ -46,7 +47,7 @@ public function validProvider() {
*/
public function testInvalidFormat( $value ) {
$formatter = new StringFormatter();
$this->setExpectedException( 'InvalidArgumentException' );
$this->setExpectedException( InvalidArgumentException::class );
$formatter->format( $value );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ValueParsers/DispatchingValueParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class DispatchingValueParserTest extends PHPUnit_Framework_TestCase {
* @return ValueParser
*/
private function getParser( PHPUnit_Framework_MockObject_Matcher_Invocation $invocation ) {
$mock = $this->getMock( 'ValueParsers\ValueParser' );
$mock = $this->getMock( ValueParser::class );

$mock->expects( $invocation )
->method( 'parse' )
Expand Down Expand Up @@ -81,7 +81,7 @@ public function testParseThrowsException() {
'format'
);

$this->setExpectedException( 'ValueParsers\ParseException' );
$this->setExpectedException( ParseException::class );
$parser->parse( 'invalid' );
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ValueParsers/Normalizers/NullStringNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ValueParsers\Normalizers\Test;

use DataValues\StringValue;
use InvalidArgumentException;
use PHPUnit_Framework_TestCase;
use ValueParsers\Normalizers\NullStringNormalizer;

Expand Down Expand Up @@ -38,7 +39,7 @@ public function stringProvider() {
*/
public function testNormalizeException( $value ) {
$normalizer = new NullStringNormalizer();
$this->setExpectedException( 'InvalidArgumentException' );
$this->setExpectedException( InvalidArgumentException::class );
$normalizer->normalize( $value );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/ValueParsers/StringParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class StringParserTest extends \PHPUnit_Framework_TestCase {

public function provideParse() {
$normalizer = $this->getMock( 'ValueParsers\Normalizers\StringNormalizer' );
$normalizer = $this->getMock( StringNormalizer::class );
$normalizer->expects( $this->once() )
->method( 'normalize' )
->will( $this->returnCallback( function( $value ) {
Expand All @@ -39,7 +39,7 @@ public function testParse( $input, StringNormalizer $normalizer = null, DataValu
$parser = new StringParser( $normalizer );
$value = $parser->parse( $input );

$this->assertInstanceOf( 'DataValues\StringValue', $value );
$this->assertInstanceOf( StringValue::class, $value );
$this->assertEquals( $expected->toArray(), $value->toArray() );
}

Expand Down
3 changes: 2 additions & 1 deletion tests/ValueParsers/ValueParserTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Comparable;
use DataValues\DataValue;
use PHPUnit_Framework_TestCase;
use ValueParsers\ParseException;
use ValueParsers\ValueParser;

/**
Expand Down Expand Up @@ -89,7 +90,7 @@ public function testParseWithInvalidInputs( $value, ValueParser $parser = null )
$parser = $this->getInstance();
}

$this->setExpectedException( 'ValueParsers\ParseException' );
$this->setExpectedException( ParseException::class );
$parser->parse( $value );
}

Expand Down

0 comments on commit f36bfd0

Please sign in to comment.