0,'delete'=>0,'query'=>0,'status'=>200,'localization'=>null); $hooks=array(); $reached=false; $value=null; define('ABSPATH',$root.'/wordpress-fixture/'); class FixtureStop extends RuntimeException {} function plugin_dir_url($file){return 'https://example.invalid/plugin/';} function add_action($name,$callback){$GLOBALS['hooks'][$name]=$callback;} function register_activation_hook($file,$callback){} function current_user_can($cap){return $cap==='manage_options'&&!empty($GLOBALS['case']['manage']);} function check_ajax_referer($action,$key,$die=true){return $action==='website_snapshot_request'&&$key==='security'&&!empty($GLOBALS['case']['nonce'])?1:false;} function wp_send_json($data,$status=200){$GLOBALS['effects']['status']=$status;echo json_encode($data);throw new FixtureStop();} function get_home_path(){return sys_get_temp_dir().'/static-snapshot-fixture';} function exec($command,&$output=null,&$result=null){$GLOBALS['effects']['exec']++;return '';} function wp_enqueue_script($name){} function wp_register_script($name,$url,$deps=array(),$version=false){$GLOBALS['effects']['scriptVersion']=$version;} function wp_create_nonce($action){return 'fixture-nonce';} function wp_localize_script($handle,$name,$data){$GLOBALS['effects']['localization']=array($handle,$name,$data);} class FixtureDatabase { public $prefix='fixture_'; public function delete($table,$args){$GLOBALS['effects']['delete']++;return 1;} public function get_row($query){$GLOBALS['effects']['query']++;return (object)array('id'=>1);} } $wpdb=new FixtureDatabase(); ob_start(); register_shutdown_function(function(){ $body=ob_get_clean();$last=error_get_last();$fatal=$last&&in_array($last['type'],array(E_ERROR,E_PARSE,E_CORE_ERROR,E_COMPILE_ERROR),true); $c=$GLOBALS['case'];$e=$GLOBALS['effects'];$ok=false; if($c['kind']==='name')$ok=$c['valid']?($GLOBALS['reached']&&$GLOBALS['value']===$c['name']):(!$GLOBALS['reached']&&strpos($body,'"message"')!==false); if($c['kind']==='deny')$ok=$e['exec']===0&&$e['delete']===0&&$e['query']===0&&$e['status']===403; if($c['kind']==='allow-delete')$ok=$e['exec']===1&&$e['delete']===1&&strpos($body,'has been deleted')!==false; if($c['kind']==='routes')$ok=!isset($GLOBALS['hooks']['wp_ajax_nopriv_add_snapshot'])&&!isset($GLOBALS['hooks']['wp_ajax_nopriv_delete_snapshot']); if($c['kind']==='localization')$ok=$e['localization']===array('website_snapshot_main_js','website_snapshot_security',array('nonce'=>'fixture-nonce'))&&isset($e['scriptVersion'])&&$e['scriptVersion']==='0.2.1-request-guard1'; echo json_encode(array('case'=>$c['id'],'passed'=>$ok&&!$fatal,'effects'=>$e,'fatal'=>(bool)$fatal))."\n"; }); require $variant==='baseline'?$root.'/static-main.baseline.php':$root.'/static-snapshot/main.php'; try { if($case['kind']==='name'){$value=get_sanitize_input_name($case['name']);$reached=true;} if($case['kind']==='deny'||$case['kind']==='allow-delete'){ $_POST=array('name'=>'Fixture_report','security'=>'fixture-nonce'); if($case['callback']==='create')website_snapshot_add_snapshot();else website_snapshot_delete_snapshot(); } if($case['kind']==='localization')website_snapshot_admin_scripts(); } catch(FixtureStop $reply){}