]> _ Git - couzy.git/blob
a04ec003011435545c07c03ba49ba1972fa08ce0
[couzy.git] /
1 <?php
2
3 include( dirname( __FILE__ ) . '../../class-product.php' );
4 include( dirname( __FILE__ ) . '../../class-license-manager.php' );
5
6 class Yoast_Product_Double extends Yoast_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 }
16
17 class Yoast_License_Manager_Double extends Yoast_License_Manager {
18
19         public $product;
20
21         public function __construct() {
22                 $this->product = new Yoast_Product_Double();
23
24                 parent::__construct( $this->product );
25         }
26
27         public function specific_hooks() {
28                 return $this->specific_hooks();
29         }
30
31         public function setup_auto_updater() {
32                 return $this->setup_auto_updater();
33         }
34
35         /**
36          * Wrapper for get_curl_version()
37          *
38          * @return mixed
39          */
40         public function double_get_curl_version(){
41                 return $this->get_curl_version();
42         }
43
44 }
45
46 class Test_Yoast_License_Manager extends Yst_License_Manager_UnitTestCase {
47
48         private $class;
49
50         public function setUp() {
51                 $this->class = new Yoast_License_Manager_Double();
52         }
53
54         /**
55          * Make sure the API url is correct in the product
56          *
57          * @covers Yoast_License_Manager::get_api_url()
58          */
59         public function test_get_api_url(){
60                 $this->assertEquals( $this->class->product->get_api_url(), get_site_url() );
61         }
62
63         /**
64          * Make sure the API url is correct in the product
65          *
66          * @covers Yoast_License_Manager::get_curl_version()
67          */
68         public function test_get_curl_version_WITH_curl_installed_on_test_server(){
69                 $curl_result = $this->class->double_get_curl_version();
70
71                 if( function_exists('curl_version') ){
72                         $curl_version = curl_version();
73
74                         $this->assertEquals( $curl_result, $curl_version['version'] );
75                 }
76                 else{
77                         $this->assertFalse( $curl_result );
78                 }
79         }
80
81 }