/vendor/yoast/license-manager/tests/test-class-yoast-license-manager.php

  1. <?php 
  2.  
  3. include( dirname( __FILE__ ) . '../../class-product.php' ); 
  4. include( dirname( __FILE__ ) . '../../class-license-manager.php' ); 
  5.  
  6. class MI_Product_Double extends MI_Product { 
  7.  
  8. /** 
  9. * Construct the real Product class with our fake data 
  10. */ 
  11. public function __construct() { 
  12. parent::__construct( get_site_url(), 'test-product', 'slug-test-product', '1.0.0' ); 
  13.  
  14.  
  15. class MI_License_Manager_Double extends MI_License_Manager { 
  16.  
  17. public $product; 
  18.  
  19. public function __construct() { 
  20. $this->product = new MI_Product_Double(); 
  21.  
  22. parent::__construct( $this->product ); 
  23.  
  24. public function specific_hooks() { 
  25. return $this->specific_hooks(); 
  26.  
  27. public function setup_auto_updater() { 
  28. return $this->setup_auto_updater(); 
  29.  
  30. /** 
  31. * Wrapper for get_curl_version() 
  32. * 
  33. * @return mixed 
  34. */ 
  35. public function double_get_curl_version() { 
  36. return $this->get_curl_version(); 
  37.  
  38.  
  39. class Test_MI_License_Manager extends Yst_License_Manager_UnitTestCase { 
  40.  
  41. private $class; 
  42.  
  43. public function setUp() { 
  44. $this->class = new MI_License_Manager_Double(); 
  45.  
  46. /** 
  47. * Make sure the API url is correct in the product 
  48. * 
  49. * @covers MI_License_Manager::get_api_url() 
  50. */ 
  51. public function test_get_api_url() { 
  52. $this->assertEquals( $this->class->product->get_api_url(), get_site_url() ); 
  53.  
  54. /** 
  55. * Make sure the API url is correct in the product 
  56. * 
  57. * @covers MI_License_Manager::get_curl_version() 
  58. */ 
  59. public function test_get_curl_version_WITH_curl_installed_on_test_server() { 
  60. $curl_result = $this->class->double_get_curl_version(); 
  61.  
  62. if( function_exists('curl_version') ) { 
  63. $curl_version = curl_version(); 
  64.  
  65. $this->assertEquals( $curl_result, $curl_version['version'] ); 
  66. else{ 
  67. $this->assertFalse( $curl_result ); 
  68.  
.