Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid static methods when registering Properties (#36)
- Loading branch information
Showing
11 changed files
with
126 additions
and
130 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace SG\Tests; | ||
|
||
use SG\PropertyRegistrationHelper; | ||
use SMW\DIProperty; | ||
|
||
/** | ||
* @covers \SG\PropertyRegistrationHelper | ||
* @group semantic-glossary | ||
* | ||
* @license GNU GPL v2+ | ||
* @since 1.0 | ||
* | ||
* @author mwjames | ||
*/ | ||
class PropertyRegistrationHelperTest extends \PHPUnit_Framework_TestCase { | ||
|
||
public function testCanConstruct() { | ||
|
||
$propertyRegistry = | ||
$this->getMockBuilder( '\SMW\PropertyRegistry' ) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$propertyRegistrationHelper = new PropertyRegistrationHelper( $propertyRegistry ); | ||
|
||
$this->assertInstanceOf( | ||
'\SG\PropertyRegistrationHelper', | ||
$propertyRegistrationHelper | ||
); | ||
} | ||
|
||
public function testRegisterProperties() { | ||
|
||
$propertyRegistry = | ||
$this->getMockBuilder( '\SMW\PropertyRegistry' ) | ||
->disableOriginalConstructor() | ||
->getMock(); | ||
|
||
$propertyRegistry | ||
->expects( $this->exactly( 4 ) ) | ||
->method( 'registerProperty' ); | ||
|
||
$propertyRegistry | ||
->expects( $this->exactly( 4 ) ) | ||
->method( 'registerPropertyAlias' ); | ||
|
||
|
||
$propertyRegistrationHelper = new PropertyRegistrationHelper( $propertyRegistry ); | ||
|
||
$this->assertTrue( | ||
$propertyRegistrationHelper->registerProperties() | ||
); | ||
} | ||
|
||
/** | ||
* @dataProvider propertyDefinitionDataProvider | ||
* | ||
* @param string $id | ||
* @param string $label | ||
*/ | ||
public function testRegisteredPropertyById( $id, $label ) { | ||
|
||
$property = new DIProperty( $id ); | ||
|
||
$this->assertInstanceOf( '\SMW\DIProperty', $property ); | ||
$this->assertEquals( $label, $property->getLabel() ); | ||
$this->assertTrue( $property->isShown() ); | ||
} | ||
|
||
/** | ||
* @return string[][] | ||
*/ | ||
public function propertyDefinitionDataProvider() { | ||
|
||
$provider = array(); | ||
|
||
$provider[] = array( PropertyRegistrationHelper::SG_TERM, SG_PROP_GLT ); | ||
$provider[] = array( PropertyRegistrationHelper::SG_DEFINITION, SG_PROP_GLD ); | ||
$provider[] = array( PropertyRegistrationHelper::SG_LINK, SG_PROP_GLL ); | ||
$provider[] = array( PropertyRegistrationHelper::SG_STYLE, SG_PROP_GLS ); | ||
|
||
return $provider; | ||
} | ||
|
||
} |
Oops, something went wrong.