ConfigurationTest

The Yoast SEO ConfigurationTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/yoast/whip/tests/ConfigurationTest.php  
  1. class ConfigurationTest extends PHPUnit_Framework_TestCase { 
  2. /** 
  3. * @expectedException Whip_InvalidType 
  4. */ 
  5. public function testItThrowsAnErrorIfAFaultyConfigurationIsPassed() { 
  6. $configuration = new Whip_Configuration( 'Invalid configuration' ); 
  7.  
  8. public function testItReturnsANegativeNumberIfRequirementCannotBeFound() { 
  9. $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); 
  10. $requirement = $this->getMockBuilder( 'Whip_Requirement' ) 
  11. ->setMethods( array( 'component' ) ) 
  12. ->getMock(); 
  13.  
  14. $requirement 
  15. ->expects( $this->any() ) 
  16. ->method( 'component' ) 
  17. ->will( $this->returnValue( 'mysql' ) ); 
  18.  
  19. $this->assertEquals( -1, $configuration->configuredVersion( $requirement ) ); 
  20.  
  21. public function testItReturnsAnEntryIfRequirementIsFound() { 
  22. $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); 
  23. $requirement = $this->getMockBuilder( 'Whip_Requirement' ) 
  24. ->setMethods( array( 'component' ) ) 
  25. ->getMock(); 
  26.  
  27. $requirement 
  28. ->expects( $this->any() ) 
  29. ->method( 'component' ) 
  30. ->will( $this->returnValue( 'php' ) ); 
  31.  
  32. $this->assertEquals( '5.6', $configuration->configuredVersion( $requirement ) ); 
  33.  
  34. public function testIfRequirementIsConfigured() { 
  35. $configuration = new Whip_Configuration( array( 'php' => '5.6' ) ); 
  36. $requirement = $this->getMockBuilder( 'Whip_Requirement' ) 
  37. ->setMethods( array( 'component' ) ) 
  38. ->getMock(); 
  39.  
  40. $requirement 
  41. ->expects( $this->any() ) 
  42. ->method( 'component' ) 
  43. ->will( $this->returnValue( 'php' ) ); 
  44.  
  45. $falseRequirement = $this->getMockBuilder( 'Whip_Requirement' ) 
  46. ->setMethods( array( 'component' ) ) 
  47. ->getMock(); 
  48.  
  49. $falseRequirement 
  50. ->expects( $this->any() ) 
  51. ->method( 'component' ) 
  52. ->will( $this->returnValue( 'mysql' ) ); 
  53.  
  54. $this->assertTrue( $configuration->hasRequirementConfigured( $requirement ) ); 
  55. $this->assertFalse( $configuration->hasRequirementConfigured( $falseRequirement ) );