Example #1
0
 /**
  * @see Envato_Market_Github::update_plugins()
  */
 function test_update_plugins()
 {
     $transient = new stdClass();
     $api = new stdClass();
     $api->name = 'Envato Market';
     $api->slug = 'envato-market';
     $api->version = '10.0.0';
     $api->download_link = 'https://envato.github.io/wp-envato-market/dist/envato-market.zip';
     $this->assertEquals($transient, $this->github->update_plugins($transient));
     $mock = $this->getMockBuilder('Envato_Market_Github')->setMethods(array('api_check', 'state'))->disableOriginalConstructor()->getMock();
     $mock->expects($this->any())->method('api_check')->will($this->returnValue($api));
     $mock->expects($this->any())->method('state')->will($this->returnValue('activated'));
     // Replace private _instance reference with mock object
     $ref = new ReflectionProperty('Envato_Market_Github', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, $mock);
     $this->assertEquals($api, $mock->api_check());
     $this->assertEquals('activated', $mock->state());
     $transient = $mock->update_plugins($transient);
     $this->assertObjectHasAttribute('slug', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('plugin', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('new_version', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('url', $transient->response['envato-market/envato-market.php']);
     $this->assertObjectHasAttribute('package', $transient->response['envato-market/envato-market.php']);
     $this->assertEquals('10.0.0', $transient->response['envato-market/envato-market.php']->new_version);
     $ref = new ReflectionProperty('Envato_Market_Github', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, null);
 }