Example #1
0
 /**
  * @see Envato_Market_Admin::maybe_deferred_download()
  */
 function test_maybe_deferred_download()
 {
     $options = envato_market()->get_options();
     update_option(envato_market()->get_option_name(), array('items' => array(array('name' => 'Envato Market', 'token' => 'TOKEN12345', 'id' => 12345, 'type' => 'plugin', 'authorized' => 'success'))));
     $mock = $this->getMockBuilder('Envato_Market_API')->setMethods(array('download'))->disableOriginalConstructor()->getMock();
     $mock->expects($this->any())->method('download')->will($this->returnValue('http://sample.org/?download=it'));
     $ref = new ReflectionProperty('Envato_Market_API', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, $mock);
     $options = array('package' => 'http://sample.org/?deferred_download=1&item_id=12345');
     $expected = array('package' => 'http://sample.org/?download=it');
     $this->assertEquals($expected, $this->admin->maybe_deferred_download($options));
     $ref = new ReflectionProperty('Envato_Market_API', '_instance');
     $ref->setAccessible(true);
     $ref->setValue(null, null);
     update_option(envato_market()->get_option_name(), $options);
 }