public function set_up()
 {
     parent::set_up();
     $this->after_compress_called = false;
     $after_compress_called =& $this->after_compress_called;
     $callback = function ($compressor) use(&$after_compress_called) {
         $after_compress_called = true;
     };
     $this->compressor = Tiny_Compress::create('api1234', $callback);
 }
 public function update_api_key()
 {
     $key = $_POST['key'];
     if (empty($key)) {
         /* Always save if key is blank, so the key can be deleted. */
         $status = (object) array('ok' => true, 'message' => null);
     } else {
         $status = Tiny_Compress::create($key)->get_status();
     }
     if ($status->ok) {
         update_option(self::get_prefixed_name('api_key_pending'), false);
         update_option(self::get_prefixed_name('api_key'), $key);
     }
     $status->message = __($status->message, 'tiny-compress-images');
     echo json_encode($status);
     exit;
 }
 public function test_should_throw_error_when_curl_and_fopen_unavailable()
 {
     $this->setExpectedException('Tiny_Exception');
     Tiny_Compress::create('api1234');
 }