/** * Check authorization fails when download is empty */ function test_authorize_items_themes_error_no_download() { $contents = file_get_contents(TESTS_DATA_DIR . '/themes.json'); $json = json_decode($contents, true); $mock = $this->getMockBuilder('Envato_Market_API')->setMethods(array('request', 'download'))->disableOriginalConstructor()->getMock(); $mock->expects($this->any())->method('request')->will($this->returnValue($json)); $mock->expects($this->any())->method('download')->will($this->returnValue(false)); // Replace private _instance reference with mock object $ref = new ReflectionProperty('Envato_Market_API', '_instance'); $ref->setAccessible(true); $ref->setValue(null, $mock); $this->assertEquals('error', $this->admin->authorize_items('themes')); $ref = new ReflectionProperty('Envato_Market_API', '_instance'); $ref->setAccessible(true); $ref->setValue(null, null); }