configuration.php 1.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345
  1. <?php
  2. /**
  3. * DO NOT EDIT: This file is automatically generated by configGenerator.php
  4. */
  5. class configurationTest extends PHPUnit_Framework_TestCase
  6. {
  7. private static $pasteid = '5e9bc25c89fb3bf9';
  8. private static $paste = array(
  9. 'data' => '{"iv":"EN39/wd5Nk8HAiSG2K5AsQ","v":1,"iter":1000,"ks":128,"ts":64,"mode":"ccm","adata":"","cipher":"aes","salt":"QKN1DBXe5PI","ct":"8hA83xDdXjD7K2qfmw5NdA"}',
  10. 'meta' => array(
  11. 'postdate' => 1344803344,
  12. 'opendiscussion' => true,
  13. ),
  14. );
  15. private $_model;
  16. private $_conf;
  17. public function setUp()
  18. {
  19. /* Setup Routine */
  20. $this->_conf = PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini';
  21. if (!is_file($this->_conf . '.bak') && is_file($this->_conf))
  22. rename($this->_conf, $this->_conf . '.bak');
  23. $this->_model = zerobin_data::getInstance(array('dir' => PATH . 'data'));
  24. serversalt::setPath(PATH . 'data');
  25. $this->reset();
  26. }
  27. public function tearDown()
  28. {
  29. /* Tear Down Routine */
  30. rename($this->_conf . '.bak', $this->_conf);
  31. }
  32. public function reset($configuration = array())
  33. {
  34. $_POST = array();
  35. $_GET = array();
  36. $_SERVER = array();
  37. if ($this->_model->exists(self::$pasteid))
  38. $this->_model->delete(self::$pasteid);
  39. helper::createIniFile($this->_conf, $configuration);
  40. }
  41. /**
  42. * @runInSeparateProcess
  43. */
  44. public function testView0()
  45. {
  46. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  47. ob_start();
  48. new zerobin;
  49. $content = ob_get_contents();
  50. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  51. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  52. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  53. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  54. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  55. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  56. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  57. }
  58. /**
  59. * @runInSeparateProcess
  60. */
  61. public function testRead0()
  62. {
  63. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  64. $this->_model->create(self::$pasteid, self::$paste);
  65. $_SERVER['QUERY_STRING'] = self::$pasteid;
  66. ob_start();
  67. new zerobin;
  68. $content = ob_get_contents();
  69. $this->assertTag(
  70. array(
  71. 'id' => 'cipherdata',
  72. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  73. ),
  74. $content,
  75. 'outputs data correctly'
  76. );
  77. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  78. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  79. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  80. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  81. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  82. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  83. }
  84. /**
  85. * @runInSeparateProcess
  86. */
  87. public function testDelete0()
  88. {
  89. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  90. $this->_model->create(self::$pasteid, self::$paste);
  91. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  92. $_GET['pasteid'] = self::$pasteid;
  93. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  94. ob_start();
  95. new zerobin;
  96. $content = ob_get_contents();
  97. $this->assertTag(
  98. array(
  99. 'id' => 'status',
  100. 'content' => 'Paste was properly deleted'
  101. ),
  102. $content,
  103. 'outputs deleted status correctly'
  104. );
  105. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  106. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  107. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  108. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  109. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  110. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  111. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  112. }
  113. /**
  114. * @runInSeparateProcess
  115. */
  116. public function testView1()
  117. {
  118. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  119. ob_start();
  120. new zerobin;
  121. $content = ob_get_contents();
  122. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  123. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  124. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  125. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  126. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  127. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  128. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  129. }
  130. /**
  131. * @runInSeparateProcess
  132. */
  133. public function testRead1()
  134. {
  135. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  136. $this->_model->create(self::$pasteid, self::$paste);
  137. $_SERVER['QUERY_STRING'] = self::$pasteid;
  138. ob_start();
  139. new zerobin;
  140. $content = ob_get_contents();
  141. $this->assertTag(
  142. array(
  143. 'id' => 'cipherdata',
  144. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  145. ),
  146. $content,
  147. 'outputs data correctly'
  148. );
  149. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  150. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  151. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  152. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  153. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  154. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  155. }
  156. /**
  157. * @runInSeparateProcess
  158. */
  159. public function testDelete1()
  160. {
  161. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  162. $this->_model->create(self::$pasteid, self::$paste);
  163. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  164. $_GET['pasteid'] = self::$pasteid;
  165. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  166. ob_start();
  167. new zerobin;
  168. $content = ob_get_contents();
  169. $this->assertTag(
  170. array(
  171. 'id' => 'status',
  172. 'content' => 'Paste was properly deleted'
  173. ),
  174. $content,
  175. 'outputs deleted status correctly'
  176. );
  177. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  178. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  179. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  180. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  181. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  182. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  183. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  184. }
  185. /**
  186. * @runInSeparateProcess
  187. */
  188. public function testView2()
  189. {
  190. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  191. ob_start();
  192. new zerobin;
  193. $content = ob_get_contents();
  194. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  195. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  196. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  197. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  198. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  199. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  200. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  201. }
  202. /**
  203. * @runInSeparateProcess
  204. */
  205. public function testRead2()
  206. {
  207. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  208. $this->_model->create(self::$pasteid, self::$paste);
  209. $_SERVER['QUERY_STRING'] = self::$pasteid;
  210. ob_start();
  211. new zerobin;
  212. $content = ob_get_contents();
  213. $this->assertTag(
  214. array(
  215. 'id' => 'cipherdata',
  216. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  217. ),
  218. $content,
  219. 'outputs data correctly'
  220. );
  221. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  222. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  223. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  224. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  225. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  226. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  227. }
  228. /**
  229. * @runInSeparateProcess
  230. */
  231. public function testDelete2()
  232. {
  233. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  234. $this->_model->create(self::$pasteid, self::$paste);
  235. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  236. $_GET['pasteid'] = self::$pasteid;
  237. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  238. ob_start();
  239. new zerobin;
  240. $content = ob_get_contents();
  241. $this->assertTag(
  242. array(
  243. 'id' => 'status',
  244. 'content' => 'Paste was properly deleted'
  245. ),
  246. $content,
  247. 'outputs deleted status correctly'
  248. );
  249. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  250. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  251. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  252. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  253. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  254. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  255. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  256. }
  257. /**
  258. * @runInSeparateProcess
  259. */
  260. public function testView3()
  261. {
  262. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  263. ob_start();
  264. new zerobin;
  265. $content = ob_get_contents();
  266. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  267. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  268. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  269. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  270. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  271. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  272. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  273. }
  274. /**
  275. * @runInSeparateProcess
  276. */
  277. public function testRead3()
  278. {
  279. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  280. $this->_model->create(self::$pasteid, self::$paste);
  281. $_SERVER['QUERY_STRING'] = self::$pasteid;
  282. ob_start();
  283. new zerobin;
  284. $content = ob_get_contents();
  285. $this->assertTag(
  286. array(
  287. 'id' => 'cipherdata',
  288. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  289. ),
  290. $content,
  291. 'outputs data correctly'
  292. );
  293. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  294. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  295. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  296. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  297. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  298. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  299. }
  300. /**
  301. * @runInSeparateProcess
  302. */
  303. public function testDelete3()
  304. {
  305. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  306. $this->_model->create(self::$pasteid, self::$paste);
  307. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  308. $_GET['pasteid'] = self::$pasteid;
  309. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  310. ob_start();
  311. new zerobin;
  312. $content = ob_get_contents();
  313. $this->assertTag(
  314. array(
  315. 'id' => 'status',
  316. 'content' => 'Paste was properly deleted'
  317. ),
  318. $content,
  319. 'outputs deleted status correctly'
  320. );
  321. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  322. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  323. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  324. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  325. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  326. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  327. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  328. }
  329. /**
  330. * @runInSeparateProcess
  331. */
  332. public function testView4()
  333. {
  334. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  335. ob_start();
  336. new zerobin;
  337. $content = ob_get_contents();
  338. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  339. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  340. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  341. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  342. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  343. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  344. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  345. }
  346. /**
  347. * @runInSeparateProcess
  348. */
  349. public function testRead4()
  350. {
  351. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  352. $this->_model->create(self::$pasteid, self::$paste);
  353. $_SERVER['QUERY_STRING'] = self::$pasteid;
  354. ob_start();
  355. new zerobin;
  356. $content = ob_get_contents();
  357. $this->assertTag(
  358. array(
  359. 'id' => 'cipherdata',
  360. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  361. ),
  362. $content,
  363. 'outputs data correctly'
  364. );
  365. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  366. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  367. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  368. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  369. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  370. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  371. }
  372. /**
  373. * @runInSeparateProcess
  374. */
  375. public function testDelete4()
  376. {
  377. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  378. $this->_model->create(self::$pasteid, self::$paste);
  379. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  380. $_GET['pasteid'] = self::$pasteid;
  381. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  382. ob_start();
  383. new zerobin;
  384. $content = ob_get_contents();
  385. $this->assertTag(
  386. array(
  387. 'id' => 'status',
  388. 'content' => 'Paste was properly deleted'
  389. ),
  390. $content,
  391. 'outputs deleted status correctly'
  392. );
  393. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  394. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  395. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  396. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  397. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  398. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  399. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  400. }
  401. /**
  402. * @runInSeparateProcess
  403. */
  404. public function testView5()
  405. {
  406. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  407. ob_start();
  408. new zerobin;
  409. $content = ob_get_contents();
  410. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  411. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  412. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  413. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  414. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  415. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  416. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  417. }
  418. /**
  419. * @runInSeparateProcess
  420. */
  421. public function testRead5()
  422. {
  423. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  424. $this->_model->create(self::$pasteid, self::$paste);
  425. $_SERVER['QUERY_STRING'] = self::$pasteid;
  426. ob_start();
  427. new zerobin;
  428. $content = ob_get_contents();
  429. $this->assertTag(
  430. array(
  431. 'id' => 'cipherdata',
  432. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  433. ),
  434. $content,
  435. 'outputs data correctly'
  436. );
  437. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  438. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  439. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  440. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  441. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  442. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  443. }
  444. /**
  445. * @runInSeparateProcess
  446. */
  447. public function testDelete5()
  448. {
  449. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  450. $this->_model->create(self::$pasteid, self::$paste);
  451. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  452. $_GET['pasteid'] = self::$pasteid;
  453. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  454. ob_start();
  455. new zerobin;
  456. $content = ob_get_contents();
  457. $this->assertTag(
  458. array(
  459. 'id' => 'status',
  460. 'content' => 'Paste was properly deleted'
  461. ),
  462. $content,
  463. 'outputs deleted status correctly'
  464. );
  465. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  466. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  467. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  468. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  469. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  470. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  471. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  472. }
  473. /**
  474. * @runInSeparateProcess
  475. */
  476. public function testView6()
  477. {
  478. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  479. ob_start();
  480. new zerobin;
  481. $content = ob_get_contents();
  482. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  483. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  484. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  485. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  486. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  487. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  488. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  489. }
  490. /**
  491. * @runInSeparateProcess
  492. */
  493. public function testRead6()
  494. {
  495. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  496. $this->_model->create(self::$pasteid, self::$paste);
  497. $_SERVER['QUERY_STRING'] = self::$pasteid;
  498. ob_start();
  499. new zerobin;
  500. $content = ob_get_contents();
  501. $this->assertTag(
  502. array(
  503. 'id' => 'cipherdata',
  504. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  505. ),
  506. $content,
  507. 'outputs data correctly'
  508. );
  509. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  510. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  511. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  512. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  513. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  514. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  515. }
  516. /**
  517. * @runInSeparateProcess
  518. */
  519. public function testDelete6()
  520. {
  521. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  522. $this->_model->create(self::$pasteid, self::$paste);
  523. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  524. $_GET['pasteid'] = self::$pasteid;
  525. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  526. ob_start();
  527. new zerobin;
  528. $content = ob_get_contents();
  529. $this->assertTag(
  530. array(
  531. 'id' => 'status',
  532. 'content' => 'Paste was properly deleted'
  533. ),
  534. $content,
  535. 'outputs deleted status correctly'
  536. );
  537. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  538. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  539. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  540. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  541. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  542. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  543. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  544. }
  545. /**
  546. * @runInSeparateProcess
  547. */
  548. public function testView7()
  549. {
  550. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  551. ob_start();
  552. new zerobin;
  553. $content = ob_get_contents();
  554. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  555. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  556. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  557. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  558. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  559. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  560. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  561. }
  562. /**
  563. * @runInSeparateProcess
  564. */
  565. public function testRead7()
  566. {
  567. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  568. $this->_model->create(self::$pasteid, self::$paste);
  569. $_SERVER['QUERY_STRING'] = self::$pasteid;
  570. ob_start();
  571. new zerobin;
  572. $content = ob_get_contents();
  573. $this->assertTag(
  574. array(
  575. 'id' => 'cipherdata',
  576. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  577. ),
  578. $content,
  579. 'outputs data correctly'
  580. );
  581. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  583. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  584. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  585. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  586. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  587. }
  588. /**
  589. * @runInSeparateProcess
  590. */
  591. public function testDelete7()
  592. {
  593. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  594. $this->_model->create(self::$pasteid, self::$paste);
  595. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  596. $_GET['pasteid'] = self::$pasteid;
  597. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  598. ob_start();
  599. new zerobin;
  600. $content = ob_get_contents();
  601. $this->assertTag(
  602. array(
  603. 'id' => 'status',
  604. 'content' => 'Paste was properly deleted'
  605. ),
  606. $content,
  607. 'outputs deleted status correctly'
  608. );
  609. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  610. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  611. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  612. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  613. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  614. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  615. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  616. }
  617. /**
  618. * @runInSeparateProcess
  619. */
  620. public function testView8()
  621. {
  622. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  623. ob_start();
  624. new zerobin;
  625. $content = ob_get_contents();
  626. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  627. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  628. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  629. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  630. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  631. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  632. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  633. }
  634. /**
  635. * @runInSeparateProcess
  636. */
  637. public function testRead8()
  638. {
  639. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  640. $this->_model->create(self::$pasteid, self::$paste);
  641. $_SERVER['QUERY_STRING'] = self::$pasteid;
  642. ob_start();
  643. new zerobin;
  644. $content = ob_get_contents();
  645. $this->assertTag(
  646. array(
  647. 'id' => 'cipherdata',
  648. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  649. ),
  650. $content,
  651. 'outputs data correctly'
  652. );
  653. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  654. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  655. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  656. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  657. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  658. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  659. }
  660. /**
  661. * @runInSeparateProcess
  662. */
  663. public function testDelete8()
  664. {
  665. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  666. $this->_model->create(self::$pasteid, self::$paste);
  667. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  668. $_GET['pasteid'] = self::$pasteid;
  669. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  670. ob_start();
  671. new zerobin;
  672. $content = ob_get_contents();
  673. $this->assertTag(
  674. array(
  675. 'id' => 'status',
  676. 'content' => 'Paste was properly deleted'
  677. ),
  678. $content,
  679. 'outputs deleted status correctly'
  680. );
  681. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  682. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  683. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  684. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  685. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  686. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  687. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  688. }
  689. /**
  690. * @runInSeparateProcess
  691. */
  692. public function testView9()
  693. {
  694. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  695. ob_start();
  696. new zerobin;
  697. $content = ob_get_contents();
  698. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  699. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  700. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  701. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  702. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  703. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  704. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  705. }
  706. /**
  707. * @runInSeparateProcess
  708. */
  709. public function testRead9()
  710. {
  711. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  712. $this->_model->create(self::$pasteid, self::$paste);
  713. $_SERVER['QUERY_STRING'] = self::$pasteid;
  714. ob_start();
  715. new zerobin;
  716. $content = ob_get_contents();
  717. $this->assertTag(
  718. array(
  719. 'id' => 'cipherdata',
  720. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  721. ),
  722. $content,
  723. 'outputs data correctly'
  724. );
  725. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  726. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  727. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  728. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  729. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  730. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  731. }
  732. /**
  733. * @runInSeparateProcess
  734. */
  735. public function testDelete9()
  736. {
  737. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  738. $this->_model->create(self::$pasteid, self::$paste);
  739. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  740. $_GET['pasteid'] = self::$pasteid;
  741. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  742. ob_start();
  743. new zerobin;
  744. $content = ob_get_contents();
  745. $this->assertTag(
  746. array(
  747. 'id' => 'status',
  748. 'content' => 'Paste was properly deleted'
  749. ),
  750. $content,
  751. 'outputs deleted status correctly'
  752. );
  753. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  754. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  755. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  756. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  757. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  758. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  759. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  760. }
  761. /**
  762. * @runInSeparateProcess
  763. */
  764. public function testView10()
  765. {
  766. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  767. ob_start();
  768. new zerobin;
  769. $content = ob_get_contents();
  770. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  771. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  772. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  773. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  774. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  775. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  776. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  777. }
  778. /**
  779. * @runInSeparateProcess
  780. */
  781. public function testRead10()
  782. {
  783. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  784. $this->_model->create(self::$pasteid, self::$paste);
  785. $_SERVER['QUERY_STRING'] = self::$pasteid;
  786. ob_start();
  787. new zerobin;
  788. $content = ob_get_contents();
  789. $this->assertTag(
  790. array(
  791. 'id' => 'cipherdata',
  792. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  793. ),
  794. $content,
  795. 'outputs data correctly'
  796. );
  797. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  798. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  799. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  800. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  801. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  802. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  803. }
  804. /**
  805. * @runInSeparateProcess
  806. */
  807. public function testDelete10()
  808. {
  809. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  810. $this->_model->create(self::$pasteid, self::$paste);
  811. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  812. $_GET['pasteid'] = self::$pasteid;
  813. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  814. ob_start();
  815. new zerobin;
  816. $content = ob_get_contents();
  817. $this->assertTag(
  818. array(
  819. 'id' => 'status',
  820. 'content' => 'Paste was properly deleted'
  821. ),
  822. $content,
  823. 'outputs deleted status correctly'
  824. );
  825. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  826. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  827. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  828. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  829. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  830. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  831. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  832. }
  833. /**
  834. * @runInSeparateProcess
  835. */
  836. public function testView11()
  837. {
  838. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  839. ob_start();
  840. new zerobin;
  841. $content = ob_get_contents();
  842. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  843. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  844. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  845. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  846. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  847. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  848. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  849. }
  850. /**
  851. * @runInSeparateProcess
  852. */
  853. public function testRead11()
  854. {
  855. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  856. $this->_model->create(self::$pasteid, self::$paste);
  857. $_SERVER['QUERY_STRING'] = self::$pasteid;
  858. ob_start();
  859. new zerobin;
  860. $content = ob_get_contents();
  861. $this->assertTag(
  862. array(
  863. 'id' => 'cipherdata',
  864. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  865. ),
  866. $content,
  867. 'outputs data correctly'
  868. );
  869. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  870. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  871. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  872. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  873. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  874. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  875. }
  876. /**
  877. * @runInSeparateProcess
  878. */
  879. public function testDelete11()
  880. {
  881. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  882. $this->_model->create(self::$pasteid, self::$paste);
  883. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  884. $_GET['pasteid'] = self::$pasteid;
  885. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  886. ob_start();
  887. new zerobin;
  888. $content = ob_get_contents();
  889. $this->assertTag(
  890. array(
  891. 'id' => 'status',
  892. 'content' => 'Paste was properly deleted'
  893. ),
  894. $content,
  895. 'outputs deleted status correctly'
  896. );
  897. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  898. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  899. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  900. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  901. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  902. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  903. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  904. }
  905. /**
  906. * @runInSeparateProcess
  907. */
  908. public function testView12()
  909. {
  910. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  911. ob_start();
  912. new zerobin;
  913. $content = ob_get_contents();
  914. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  915. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  916. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  917. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  918. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  919. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  920. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  921. }
  922. /**
  923. * @runInSeparateProcess
  924. */
  925. public function testRead12()
  926. {
  927. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  928. $this->_model->create(self::$pasteid, self::$paste);
  929. $_SERVER['QUERY_STRING'] = self::$pasteid;
  930. ob_start();
  931. new zerobin;
  932. $content = ob_get_contents();
  933. $this->assertTag(
  934. array(
  935. 'id' => 'cipherdata',
  936. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  937. ),
  938. $content,
  939. 'outputs data correctly'
  940. );
  941. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  942. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  943. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  944. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  945. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  946. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  947. }
  948. /**
  949. * @runInSeparateProcess
  950. */
  951. public function testDelete12()
  952. {
  953. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  954. $this->_model->create(self::$pasteid, self::$paste);
  955. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  956. $_GET['pasteid'] = self::$pasteid;
  957. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  958. ob_start();
  959. new zerobin;
  960. $content = ob_get_contents();
  961. $this->assertTag(
  962. array(
  963. 'id' => 'status',
  964. 'content' => 'Paste was properly deleted'
  965. ),
  966. $content,
  967. 'outputs deleted status correctly'
  968. );
  969. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  970. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  971. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  972. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  973. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  974. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  975. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  976. }
  977. /**
  978. * @runInSeparateProcess
  979. */
  980. public function testView13()
  981. {
  982. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  983. ob_start();
  984. new zerobin;
  985. $content = ob_get_contents();
  986. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  987. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  988. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  989. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  990. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  991. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  992. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  993. }
  994. /**
  995. * @runInSeparateProcess
  996. */
  997. public function testRead13()
  998. {
  999. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1000. $this->_model->create(self::$pasteid, self::$paste);
  1001. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1002. ob_start();
  1003. new zerobin;
  1004. $content = ob_get_contents();
  1005. $this->assertTag(
  1006. array(
  1007. 'id' => 'cipherdata',
  1008. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1009. ),
  1010. $content,
  1011. 'outputs data correctly'
  1012. );
  1013. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1014. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1015. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1016. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1017. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1018. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1019. }
  1020. /**
  1021. * @runInSeparateProcess
  1022. */
  1023. public function testDelete13()
  1024. {
  1025. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1026. $this->_model->create(self::$pasteid, self::$paste);
  1027. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1028. $_GET['pasteid'] = self::$pasteid;
  1029. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1030. ob_start();
  1031. new zerobin;
  1032. $content = ob_get_contents();
  1033. $this->assertTag(
  1034. array(
  1035. 'id' => 'status',
  1036. 'content' => 'Paste was properly deleted'
  1037. ),
  1038. $content,
  1039. 'outputs deleted status correctly'
  1040. );
  1041. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1042. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1043. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1044. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1045. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1046. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1047. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1048. }
  1049. /**
  1050. * @runInSeparateProcess
  1051. */
  1052. public function testView14()
  1053. {
  1054. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1055. ob_start();
  1056. new zerobin;
  1057. $content = ob_get_contents();
  1058. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1059. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1060. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1061. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1062. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1063. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1064. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1065. }
  1066. /**
  1067. * @runInSeparateProcess
  1068. */
  1069. public function testRead14()
  1070. {
  1071. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1072. $this->_model->create(self::$pasteid, self::$paste);
  1073. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1074. ob_start();
  1075. new zerobin;
  1076. $content = ob_get_contents();
  1077. $this->assertTag(
  1078. array(
  1079. 'id' => 'cipherdata',
  1080. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1081. ),
  1082. $content,
  1083. 'outputs data correctly'
  1084. );
  1085. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1086. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1087. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1088. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1089. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1090. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1091. }
  1092. /**
  1093. * @runInSeparateProcess
  1094. */
  1095. public function testDelete14()
  1096. {
  1097. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1098. $this->_model->create(self::$pasteid, self::$paste);
  1099. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1100. $_GET['pasteid'] = self::$pasteid;
  1101. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1102. ob_start();
  1103. new zerobin;
  1104. $content = ob_get_contents();
  1105. $this->assertTag(
  1106. array(
  1107. 'id' => 'status',
  1108. 'content' => 'Paste was properly deleted'
  1109. ),
  1110. $content,
  1111. 'outputs deleted status correctly'
  1112. );
  1113. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1114. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1115. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1116. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1117. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1118. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1119. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1120. }
  1121. /**
  1122. * @runInSeparateProcess
  1123. */
  1124. public function testView15()
  1125. {
  1126. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1127. ob_start();
  1128. new zerobin;
  1129. $content = ob_get_contents();
  1130. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1131. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1132. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1133. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1134. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1135. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1136. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1137. }
  1138. /**
  1139. * @runInSeparateProcess
  1140. */
  1141. public function testRead15()
  1142. {
  1143. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1144. $this->_model->create(self::$pasteid, self::$paste);
  1145. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1146. ob_start();
  1147. new zerobin;
  1148. $content = ob_get_contents();
  1149. $this->assertTag(
  1150. array(
  1151. 'id' => 'cipherdata',
  1152. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1153. ),
  1154. $content,
  1155. 'outputs data correctly'
  1156. );
  1157. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1158. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1159. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1160. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1161. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1162. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1163. }
  1164. /**
  1165. * @runInSeparateProcess
  1166. */
  1167. public function testDelete15()
  1168. {
  1169. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1170. $this->_model->create(self::$pasteid, self::$paste);
  1171. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1172. $_GET['pasteid'] = self::$pasteid;
  1173. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1174. ob_start();
  1175. new zerobin;
  1176. $content = ob_get_contents();
  1177. $this->assertTag(
  1178. array(
  1179. 'id' => 'status',
  1180. 'content' => 'Paste was properly deleted'
  1181. ),
  1182. $content,
  1183. 'outputs deleted status correctly'
  1184. );
  1185. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1186. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1187. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1188. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1189. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1190. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  1191. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  1192. }
  1193. /**
  1194. * @runInSeparateProcess
  1195. */
  1196. public function testView16()
  1197. {
  1198. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1199. ob_start();
  1200. new zerobin;
  1201. $content = ob_get_contents();
  1202. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1203. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1204. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1205. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1206. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1207. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1208. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1209. }
  1210. /**
  1211. * @runInSeparateProcess
  1212. */
  1213. public function testRead16()
  1214. {
  1215. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1216. $this->_model->create(self::$pasteid, self::$paste);
  1217. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1218. ob_start();
  1219. new zerobin;
  1220. $content = ob_get_contents();
  1221. $this->assertTag(
  1222. array(
  1223. 'id' => 'cipherdata',
  1224. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1225. ),
  1226. $content,
  1227. 'outputs data correctly'
  1228. );
  1229. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1230. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1231. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1232. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1233. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1234. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1235. }
  1236. /**
  1237. * @runInSeparateProcess
  1238. */
  1239. public function testDelete16()
  1240. {
  1241. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1242. $this->_model->create(self::$pasteid, self::$paste);
  1243. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1244. $_GET['pasteid'] = self::$pasteid;
  1245. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1246. ob_start();
  1247. new zerobin;
  1248. $content = ob_get_contents();
  1249. $this->assertTag(
  1250. array(
  1251. 'id' => 'status',
  1252. 'content' => 'Paste was properly deleted'
  1253. ),
  1254. $content,
  1255. 'outputs deleted status correctly'
  1256. );
  1257. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1258. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1259. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1260. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1261. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1262. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1263. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1264. }
  1265. /**
  1266. * @runInSeparateProcess
  1267. */
  1268. public function testView17()
  1269. {
  1270. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1271. ob_start();
  1272. new zerobin;
  1273. $content = ob_get_contents();
  1274. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1275. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1276. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1277. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1278. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1279. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1280. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1281. }
  1282. /**
  1283. * @runInSeparateProcess
  1284. */
  1285. public function testRead17()
  1286. {
  1287. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1288. $this->_model->create(self::$pasteid, self::$paste);
  1289. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1290. ob_start();
  1291. new zerobin;
  1292. $content = ob_get_contents();
  1293. $this->assertTag(
  1294. array(
  1295. 'id' => 'cipherdata',
  1296. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1297. ),
  1298. $content,
  1299. 'outputs data correctly'
  1300. );
  1301. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1302. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1303. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1304. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1305. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1306. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1307. }
  1308. /**
  1309. * @runInSeparateProcess
  1310. */
  1311. public function testDelete17()
  1312. {
  1313. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1314. $this->_model->create(self::$pasteid, self::$paste);
  1315. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1316. $_GET['pasteid'] = self::$pasteid;
  1317. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1318. ob_start();
  1319. new zerobin;
  1320. $content = ob_get_contents();
  1321. $this->assertTag(
  1322. array(
  1323. 'id' => 'status',
  1324. 'content' => 'Paste was properly deleted'
  1325. ),
  1326. $content,
  1327. 'outputs deleted status correctly'
  1328. );
  1329. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1330. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1331. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1332. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1333. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1334. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1335. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1336. }
  1337. /**
  1338. * @runInSeparateProcess
  1339. */
  1340. public function testView18()
  1341. {
  1342. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1343. ob_start();
  1344. new zerobin;
  1345. $content = ob_get_contents();
  1346. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1347. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1348. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1349. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1350. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1351. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1352. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1353. }
  1354. /**
  1355. * @runInSeparateProcess
  1356. */
  1357. public function testRead18()
  1358. {
  1359. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1360. $this->_model->create(self::$pasteid, self::$paste);
  1361. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1362. ob_start();
  1363. new zerobin;
  1364. $content = ob_get_contents();
  1365. $this->assertTag(
  1366. array(
  1367. 'id' => 'cipherdata',
  1368. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1369. ),
  1370. $content,
  1371. 'outputs data correctly'
  1372. );
  1373. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1374. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1375. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1376. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1377. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1378. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1379. }
  1380. /**
  1381. * @runInSeparateProcess
  1382. */
  1383. public function testDelete18()
  1384. {
  1385. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1386. $this->_model->create(self::$pasteid, self::$paste);
  1387. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1388. $_GET['pasteid'] = self::$pasteid;
  1389. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1390. ob_start();
  1391. new zerobin;
  1392. $content = ob_get_contents();
  1393. $this->assertTag(
  1394. array(
  1395. 'id' => 'status',
  1396. 'content' => 'Paste was properly deleted'
  1397. ),
  1398. $content,
  1399. 'outputs deleted status correctly'
  1400. );
  1401. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1402. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1403. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1404. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1405. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1406. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1407. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1408. }
  1409. /**
  1410. * @runInSeparateProcess
  1411. */
  1412. public function testView19()
  1413. {
  1414. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1415. ob_start();
  1416. new zerobin;
  1417. $content = ob_get_contents();
  1418. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1419. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1420. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1421. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1422. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1423. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1424. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1425. }
  1426. /**
  1427. * @runInSeparateProcess
  1428. */
  1429. public function testRead19()
  1430. {
  1431. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1432. $this->_model->create(self::$pasteid, self::$paste);
  1433. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1434. ob_start();
  1435. new zerobin;
  1436. $content = ob_get_contents();
  1437. $this->assertTag(
  1438. array(
  1439. 'id' => 'cipherdata',
  1440. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1441. ),
  1442. $content,
  1443. 'outputs data correctly'
  1444. );
  1445. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1446. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1447. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1448. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1449. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1450. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1451. }
  1452. /**
  1453. * @runInSeparateProcess
  1454. */
  1455. public function testDelete19()
  1456. {
  1457. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1458. $this->_model->create(self::$pasteid, self::$paste);
  1459. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1460. $_GET['pasteid'] = self::$pasteid;
  1461. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1462. ob_start();
  1463. new zerobin;
  1464. $content = ob_get_contents();
  1465. $this->assertTag(
  1466. array(
  1467. 'id' => 'status',
  1468. 'content' => 'Paste was properly deleted'
  1469. ),
  1470. $content,
  1471. 'outputs deleted status correctly'
  1472. );
  1473. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1474. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1475. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1476. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1477. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1478. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1479. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1480. }
  1481. /**
  1482. * @runInSeparateProcess
  1483. */
  1484. public function testView20()
  1485. {
  1486. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1487. ob_start();
  1488. new zerobin;
  1489. $content = ob_get_contents();
  1490. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1491. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1492. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1493. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1494. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1495. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1496. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1497. }
  1498. /**
  1499. * @runInSeparateProcess
  1500. */
  1501. public function testRead20()
  1502. {
  1503. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1504. $this->_model->create(self::$pasteid, self::$paste);
  1505. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1506. ob_start();
  1507. new zerobin;
  1508. $content = ob_get_contents();
  1509. $this->assertTag(
  1510. array(
  1511. 'id' => 'cipherdata',
  1512. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1513. ),
  1514. $content,
  1515. 'outputs data correctly'
  1516. );
  1517. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1518. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1519. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1520. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1521. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1522. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1523. }
  1524. /**
  1525. * @runInSeparateProcess
  1526. */
  1527. public function testDelete20()
  1528. {
  1529. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1530. $this->_model->create(self::$pasteid, self::$paste);
  1531. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1532. $_GET['pasteid'] = self::$pasteid;
  1533. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1534. ob_start();
  1535. new zerobin;
  1536. $content = ob_get_contents();
  1537. $this->assertTag(
  1538. array(
  1539. 'id' => 'status',
  1540. 'content' => 'Paste was properly deleted'
  1541. ),
  1542. $content,
  1543. 'outputs deleted status correctly'
  1544. );
  1545. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1546. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1547. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1548. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1549. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1550. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1551. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1552. }
  1553. /**
  1554. * @runInSeparateProcess
  1555. */
  1556. public function testView21()
  1557. {
  1558. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1559. ob_start();
  1560. new zerobin;
  1561. $content = ob_get_contents();
  1562. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1563. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1564. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1565. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1566. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1567. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1568. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1569. }
  1570. /**
  1571. * @runInSeparateProcess
  1572. */
  1573. public function testRead21()
  1574. {
  1575. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1576. $this->_model->create(self::$pasteid, self::$paste);
  1577. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1578. ob_start();
  1579. new zerobin;
  1580. $content = ob_get_contents();
  1581. $this->assertTag(
  1582. array(
  1583. 'id' => 'cipherdata',
  1584. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1585. ),
  1586. $content,
  1587. 'outputs data correctly'
  1588. );
  1589. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1590. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1591. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1592. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1593. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1594. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1595. }
  1596. /**
  1597. * @runInSeparateProcess
  1598. */
  1599. public function testDelete21()
  1600. {
  1601. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1602. $this->_model->create(self::$pasteid, self::$paste);
  1603. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1604. $_GET['pasteid'] = self::$pasteid;
  1605. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1606. ob_start();
  1607. new zerobin;
  1608. $content = ob_get_contents();
  1609. $this->assertTag(
  1610. array(
  1611. 'id' => 'status',
  1612. 'content' => 'Paste was properly deleted'
  1613. ),
  1614. $content,
  1615. 'outputs deleted status correctly'
  1616. );
  1617. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1618. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1619. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1620. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1621. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1622. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1623. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1624. }
  1625. /**
  1626. * @runInSeparateProcess
  1627. */
  1628. public function testView22()
  1629. {
  1630. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1631. ob_start();
  1632. new zerobin;
  1633. $content = ob_get_contents();
  1634. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1635. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1636. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1637. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1638. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1639. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1640. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1641. }
  1642. /**
  1643. * @runInSeparateProcess
  1644. */
  1645. public function testRead22()
  1646. {
  1647. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1648. $this->_model->create(self::$pasteid, self::$paste);
  1649. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1650. ob_start();
  1651. new zerobin;
  1652. $content = ob_get_contents();
  1653. $this->assertTag(
  1654. array(
  1655. 'id' => 'cipherdata',
  1656. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1657. ),
  1658. $content,
  1659. 'outputs data correctly'
  1660. );
  1661. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1662. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1663. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1664. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1665. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1666. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1667. }
  1668. /**
  1669. * @runInSeparateProcess
  1670. */
  1671. public function testDelete22()
  1672. {
  1673. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1674. $this->_model->create(self::$pasteid, self::$paste);
  1675. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1676. $_GET['pasteid'] = self::$pasteid;
  1677. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1678. ob_start();
  1679. new zerobin;
  1680. $content = ob_get_contents();
  1681. $this->assertTag(
  1682. array(
  1683. 'id' => 'status',
  1684. 'content' => 'Paste was properly deleted'
  1685. ),
  1686. $content,
  1687. 'outputs deleted status correctly'
  1688. );
  1689. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1690. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1691. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1692. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1693. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1694. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1695. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1696. }
  1697. /**
  1698. * @runInSeparateProcess
  1699. */
  1700. public function testView23()
  1701. {
  1702. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1703. ob_start();
  1704. new zerobin;
  1705. $content = ob_get_contents();
  1706. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1707. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1708. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1709. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1710. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  1711. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1712. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1713. }
  1714. /**
  1715. * @runInSeparateProcess
  1716. */
  1717. public function testRead23()
  1718. {
  1719. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1720. $this->_model->create(self::$pasteid, self::$paste);
  1721. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1722. ob_start();
  1723. new zerobin;
  1724. $content = ob_get_contents();
  1725. $this->assertTag(
  1726. array(
  1727. 'id' => 'cipherdata',
  1728. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1729. ),
  1730. $content,
  1731. 'outputs data correctly'
  1732. );
  1733. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1734. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1735. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1736. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1737. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1738. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1739. }
  1740. /**
  1741. * @runInSeparateProcess
  1742. */
  1743. public function testDelete23()
  1744. {
  1745. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1746. $this->_model->create(self::$pasteid, self::$paste);
  1747. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1748. $_GET['pasteid'] = self::$pasteid;
  1749. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1750. ob_start();
  1751. new zerobin;
  1752. $content = ob_get_contents();
  1753. $this->assertTag(
  1754. array(
  1755. 'id' => 'status',
  1756. 'content' => 'Paste was properly deleted'
  1757. ),
  1758. $content,
  1759. 'outputs deleted status correctly'
  1760. );
  1761. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1762. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1763. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1764. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1765. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1766. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1767. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1768. }
  1769. /**
  1770. * @runInSeparateProcess
  1771. */
  1772. public function testView24()
  1773. {
  1774. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1775. ob_start();
  1776. new zerobin;
  1777. $content = ob_get_contents();
  1778. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1779. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1780. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1781. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1782. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1783. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1784. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1785. }
  1786. /**
  1787. * @runInSeparateProcess
  1788. */
  1789. public function testRead24()
  1790. {
  1791. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1792. $this->_model->create(self::$pasteid, self::$paste);
  1793. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1794. ob_start();
  1795. new zerobin;
  1796. $content = ob_get_contents();
  1797. $this->assertTag(
  1798. array(
  1799. 'id' => 'cipherdata',
  1800. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1801. ),
  1802. $content,
  1803. 'outputs data correctly'
  1804. );
  1805. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1806. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1807. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1808. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1809. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1810. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1811. }
  1812. /**
  1813. * @runInSeparateProcess
  1814. */
  1815. public function testDelete24()
  1816. {
  1817. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1818. $this->_model->create(self::$pasteid, self::$paste);
  1819. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1820. $_GET['pasteid'] = self::$pasteid;
  1821. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1822. ob_start();
  1823. new zerobin;
  1824. $content = ob_get_contents();
  1825. $this->assertTag(
  1826. array(
  1827. 'id' => 'status',
  1828. 'content' => 'Paste was properly deleted'
  1829. ),
  1830. $content,
  1831. 'outputs deleted status correctly'
  1832. );
  1833. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1834. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1835. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1836. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1837. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1838. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1839. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1840. }
  1841. /**
  1842. * @runInSeparateProcess
  1843. */
  1844. public function testView25()
  1845. {
  1846. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1847. ob_start();
  1848. new zerobin;
  1849. $content = ob_get_contents();
  1850. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1851. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1852. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1853. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1854. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1855. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1856. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1857. }
  1858. /**
  1859. * @runInSeparateProcess
  1860. */
  1861. public function testRead25()
  1862. {
  1863. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1864. $this->_model->create(self::$pasteid, self::$paste);
  1865. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1866. ob_start();
  1867. new zerobin;
  1868. $content = ob_get_contents();
  1869. $this->assertTag(
  1870. array(
  1871. 'id' => 'cipherdata',
  1872. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1873. ),
  1874. $content,
  1875. 'outputs data correctly'
  1876. );
  1877. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1878. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1879. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1880. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1881. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1882. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1883. }
  1884. /**
  1885. * @runInSeparateProcess
  1886. */
  1887. public function testDelete25()
  1888. {
  1889. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1890. $this->_model->create(self::$pasteid, self::$paste);
  1891. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1892. $_GET['pasteid'] = self::$pasteid;
  1893. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1894. ob_start();
  1895. new zerobin;
  1896. $content = ob_get_contents();
  1897. $this->assertTag(
  1898. array(
  1899. 'id' => 'status',
  1900. 'content' => 'Paste was properly deleted'
  1901. ),
  1902. $content,
  1903. 'outputs deleted status correctly'
  1904. );
  1905. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1906. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1907. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  1908. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  1909. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  1910. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1911. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1912. }
  1913. /**
  1914. * @runInSeparateProcess
  1915. */
  1916. public function testView26()
  1917. {
  1918. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1919. ob_start();
  1920. new zerobin;
  1921. $content = ob_get_contents();
  1922. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1923. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1924. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1925. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1926. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1927. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1928. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1929. }
  1930. /**
  1931. * @runInSeparateProcess
  1932. */
  1933. public function testRead26()
  1934. {
  1935. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1936. $this->_model->create(self::$pasteid, self::$paste);
  1937. $_SERVER['QUERY_STRING'] = self::$pasteid;
  1938. ob_start();
  1939. new zerobin;
  1940. $content = ob_get_contents();
  1941. $this->assertTag(
  1942. array(
  1943. 'id' => 'cipherdata',
  1944. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  1945. ),
  1946. $content,
  1947. 'outputs data correctly'
  1948. );
  1949. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1950. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1951. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1952. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1953. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1954. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1955. }
  1956. /**
  1957. * @runInSeparateProcess
  1958. */
  1959. public function testDelete26()
  1960. {
  1961. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1962. $this->_model->create(self::$pasteid, self::$paste);
  1963. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  1964. $_GET['pasteid'] = self::$pasteid;
  1965. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  1966. ob_start();
  1967. new zerobin;
  1968. $content = ob_get_contents();
  1969. $this->assertTag(
  1970. array(
  1971. 'id' => 'status',
  1972. 'content' => 'Paste was properly deleted'
  1973. ),
  1974. $content,
  1975. 'outputs deleted status correctly'
  1976. );
  1977. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  1978. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  1979. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1980. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1981. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1982. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  1983. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  1984. }
  1985. /**
  1986. * @runInSeparateProcess
  1987. */
  1988. public function testView27()
  1989. {
  1990. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  1991. ob_start();
  1992. new zerobin;
  1993. $content = ob_get_contents();
  1994. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  1995. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  1996. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  1997. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  1998. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  1999. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2000. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2001. }
  2002. /**
  2003. * @runInSeparateProcess
  2004. */
  2005. public function testRead27()
  2006. {
  2007. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2008. $this->_model->create(self::$pasteid, self::$paste);
  2009. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2010. ob_start();
  2011. new zerobin;
  2012. $content = ob_get_contents();
  2013. $this->assertTag(
  2014. array(
  2015. 'id' => 'cipherdata',
  2016. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2017. ),
  2018. $content,
  2019. 'outputs data correctly'
  2020. );
  2021. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2022. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2023. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2024. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2025. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2026. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2027. }
  2028. /**
  2029. * @runInSeparateProcess
  2030. */
  2031. public function testDelete27()
  2032. {
  2033. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2034. $this->_model->create(self::$pasteid, self::$paste);
  2035. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2036. $_GET['pasteid'] = self::$pasteid;
  2037. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2038. ob_start();
  2039. new zerobin;
  2040. $content = ob_get_contents();
  2041. $this->assertTag(
  2042. array(
  2043. 'id' => 'status',
  2044. 'content' => 'Paste was properly deleted'
  2045. ),
  2046. $content,
  2047. 'outputs deleted status correctly'
  2048. );
  2049. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2050. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2051. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2052. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2053. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2054. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2055. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2056. }
  2057. /**
  2058. * @runInSeparateProcess
  2059. */
  2060. public function testView28()
  2061. {
  2062. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2063. ob_start();
  2064. new zerobin;
  2065. $content = ob_get_contents();
  2066. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2067. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2068. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2069. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2070. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  2071. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2072. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2073. }
  2074. /**
  2075. * @runInSeparateProcess
  2076. */
  2077. public function testRead28()
  2078. {
  2079. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2080. $this->_model->create(self::$pasteid, self::$paste);
  2081. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2082. ob_start();
  2083. new zerobin;
  2084. $content = ob_get_contents();
  2085. $this->assertTag(
  2086. array(
  2087. 'id' => 'cipherdata',
  2088. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2089. ),
  2090. $content,
  2091. 'outputs data correctly'
  2092. );
  2093. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2094. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2095. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2096. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2097. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2098. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2099. }
  2100. /**
  2101. * @runInSeparateProcess
  2102. */
  2103. public function testDelete28()
  2104. {
  2105. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2106. $this->_model->create(self::$pasteid, self::$paste);
  2107. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2108. $_GET['pasteid'] = self::$pasteid;
  2109. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2110. ob_start();
  2111. new zerobin;
  2112. $content = ob_get_contents();
  2113. $this->assertTag(
  2114. array(
  2115. 'id' => 'status',
  2116. 'content' => 'Paste was properly deleted'
  2117. ),
  2118. $content,
  2119. 'outputs deleted status correctly'
  2120. );
  2121. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2122. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2123. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2124. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2125. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2126. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2127. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2128. }
  2129. /**
  2130. * @runInSeparateProcess
  2131. */
  2132. public function testView29()
  2133. {
  2134. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2135. ob_start();
  2136. new zerobin;
  2137. $content = ob_get_contents();
  2138. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2139. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2140. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2141. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2142. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  2143. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2144. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2145. }
  2146. /**
  2147. * @runInSeparateProcess
  2148. */
  2149. public function testRead29()
  2150. {
  2151. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2152. $this->_model->create(self::$pasteid, self::$paste);
  2153. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2154. ob_start();
  2155. new zerobin;
  2156. $content = ob_get_contents();
  2157. $this->assertTag(
  2158. array(
  2159. 'id' => 'cipherdata',
  2160. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2161. ),
  2162. $content,
  2163. 'outputs data correctly'
  2164. );
  2165. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2166. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2167. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2168. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2169. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2170. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2171. }
  2172. /**
  2173. * @runInSeparateProcess
  2174. */
  2175. public function testDelete29()
  2176. {
  2177. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2178. $this->_model->create(self::$pasteid, self::$paste);
  2179. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2180. $_GET['pasteid'] = self::$pasteid;
  2181. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2182. ob_start();
  2183. new zerobin;
  2184. $content = ob_get_contents();
  2185. $this->assertTag(
  2186. array(
  2187. 'id' => 'status',
  2188. 'content' => 'Paste was properly deleted'
  2189. ),
  2190. $content,
  2191. 'outputs deleted status correctly'
  2192. );
  2193. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2194. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2195. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2196. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2197. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2198. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2199. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2200. }
  2201. /**
  2202. * @runInSeparateProcess
  2203. */
  2204. public function testView30()
  2205. {
  2206. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2207. ob_start();
  2208. new zerobin;
  2209. $content = ob_get_contents();
  2210. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2211. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2212. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2213. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2214. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  2215. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2216. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2217. }
  2218. /**
  2219. * @runInSeparateProcess
  2220. */
  2221. public function testRead30()
  2222. {
  2223. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2224. $this->_model->create(self::$pasteid, self::$paste);
  2225. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2226. ob_start();
  2227. new zerobin;
  2228. $content = ob_get_contents();
  2229. $this->assertTag(
  2230. array(
  2231. 'id' => 'cipherdata',
  2232. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2233. ),
  2234. $content,
  2235. 'outputs data correctly'
  2236. );
  2237. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2238. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2239. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2240. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2241. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2242. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2243. }
  2244. /**
  2245. * @runInSeparateProcess
  2246. */
  2247. public function testDelete30()
  2248. {
  2249. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2250. $this->_model->create(self::$pasteid, self::$paste);
  2251. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2252. $_GET['pasteid'] = self::$pasteid;
  2253. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2254. ob_start();
  2255. new zerobin;
  2256. $content = ob_get_contents();
  2257. $this->assertTag(
  2258. array(
  2259. 'id' => 'status',
  2260. 'content' => 'Paste was properly deleted'
  2261. ),
  2262. $content,
  2263. 'outputs deleted status correctly'
  2264. );
  2265. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2266. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2267. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2268. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2269. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2270. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2271. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2272. }
  2273. /**
  2274. * @runInSeparateProcess
  2275. */
  2276. public function testView31()
  2277. {
  2278. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2279. ob_start();
  2280. new zerobin;
  2281. $content = ob_get_contents();
  2282. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2283. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2284. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2285. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2286. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  2287. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2288. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2289. }
  2290. /**
  2291. * @runInSeparateProcess
  2292. */
  2293. public function testRead31()
  2294. {
  2295. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2296. $this->_model->create(self::$pasteid, self::$paste);
  2297. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2298. ob_start();
  2299. new zerobin;
  2300. $content = ob_get_contents();
  2301. $this->assertTag(
  2302. array(
  2303. 'id' => 'cipherdata',
  2304. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2305. ),
  2306. $content,
  2307. 'outputs data correctly'
  2308. );
  2309. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2310. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2311. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2312. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2313. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2314. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2315. }
  2316. /**
  2317. * @runInSeparateProcess
  2318. */
  2319. public function testDelete31()
  2320. {
  2321. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2322. $this->_model->create(self::$pasteid, self::$paste);
  2323. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2324. $_GET['pasteid'] = self::$pasteid;
  2325. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2326. ob_start();
  2327. new zerobin;
  2328. $content = ob_get_contents();
  2329. $this->assertTag(
  2330. array(
  2331. 'id' => 'status',
  2332. 'content' => 'Paste was properly deleted'
  2333. ),
  2334. $content,
  2335. 'outputs deleted status correctly'
  2336. );
  2337. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2338. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2339. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2340. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2341. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2342. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  2343. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  2344. }
  2345. /**
  2346. * @runInSeparateProcess
  2347. */
  2348. public function testView32()
  2349. {
  2350. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2351. ob_start();
  2352. new zerobin;
  2353. $content = ob_get_contents();
  2354. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2355. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2356. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2357. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2358. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2359. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2360. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2361. }
  2362. /**
  2363. * @runInSeparateProcess
  2364. */
  2365. public function testCreate32()
  2366. {
  2367. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2368. $_POST = self::$paste;
  2369. $_SERVER['REMOTE_ADDR'] = '::1';
  2370. sleep(3);
  2371. ob_start();
  2372. new zerobin;
  2373. $content = ob_get_contents();
  2374. $response = json_decode($content, true);
  2375. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2376. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2377. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2378. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2379. }
  2380. /**
  2381. * @runInSeparateProcess
  2382. */
  2383. public function testRead32()
  2384. {
  2385. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2386. $this->_model->create(self::$pasteid, self::$paste);
  2387. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2388. ob_start();
  2389. new zerobin;
  2390. $content = ob_get_contents();
  2391. $this->assertTag(
  2392. array(
  2393. 'id' => 'cipherdata',
  2394. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2395. ),
  2396. $content,
  2397. 'outputs data correctly'
  2398. );
  2399. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2400. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2401. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2402. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2403. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2404. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2405. }
  2406. /**
  2407. * @runInSeparateProcess
  2408. */
  2409. public function testDelete32()
  2410. {
  2411. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2412. $this->_model->create(self::$pasteid, self::$paste);
  2413. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2414. $_GET['pasteid'] = self::$pasteid;
  2415. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2416. ob_start();
  2417. new zerobin;
  2418. $content = ob_get_contents();
  2419. $this->assertTag(
  2420. array(
  2421. 'id' => 'status',
  2422. 'content' => 'Paste was properly deleted'
  2423. ),
  2424. $content,
  2425. 'outputs deleted status correctly'
  2426. );
  2427. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2428. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2429. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2430. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2431. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2432. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2433. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2434. }
  2435. /**
  2436. * @runInSeparateProcess
  2437. */
  2438. public function testView33()
  2439. {
  2440. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2441. ob_start();
  2442. new zerobin;
  2443. $content = ob_get_contents();
  2444. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2445. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2446. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2447. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2448. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2449. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2450. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2451. }
  2452. /**
  2453. * @runInSeparateProcess
  2454. */
  2455. public function testCreate33()
  2456. {
  2457. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2458. $_POST = self::$paste;
  2459. $_SERVER['REMOTE_ADDR'] = '::1';
  2460. sleep(3);
  2461. ob_start();
  2462. new zerobin;
  2463. $content = ob_get_contents();
  2464. $response = json_decode($content, true);
  2465. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2466. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2467. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2468. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2469. }
  2470. /**
  2471. * @runInSeparateProcess
  2472. */
  2473. public function testRead33()
  2474. {
  2475. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2476. $this->_model->create(self::$pasteid, self::$paste);
  2477. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2478. ob_start();
  2479. new zerobin;
  2480. $content = ob_get_contents();
  2481. $this->assertTag(
  2482. array(
  2483. 'id' => 'cipherdata',
  2484. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2485. ),
  2486. $content,
  2487. 'outputs data correctly'
  2488. );
  2489. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2490. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2491. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2492. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2493. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2494. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2495. }
  2496. /**
  2497. * @runInSeparateProcess
  2498. */
  2499. public function testDelete33()
  2500. {
  2501. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2502. $this->_model->create(self::$pasteid, self::$paste);
  2503. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2504. $_GET['pasteid'] = self::$pasteid;
  2505. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2506. ob_start();
  2507. new zerobin;
  2508. $content = ob_get_contents();
  2509. $this->assertTag(
  2510. array(
  2511. 'id' => 'status',
  2512. 'content' => 'Paste was properly deleted'
  2513. ),
  2514. $content,
  2515. 'outputs deleted status correctly'
  2516. );
  2517. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2518. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2519. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2520. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2521. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  2522. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2523. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2524. }
  2525. /**
  2526. * @runInSeparateProcess
  2527. */
  2528. public function testView34()
  2529. {
  2530. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2531. ob_start();
  2532. new zerobin;
  2533. $content = ob_get_contents();
  2534. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2535. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2536. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2537. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2538. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2539. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2540. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2541. }
  2542. /**
  2543. * @runInSeparateProcess
  2544. */
  2545. public function testCreate34()
  2546. {
  2547. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2548. $_POST = self::$paste;
  2549. $_SERVER['REMOTE_ADDR'] = '::1';
  2550. sleep(3);
  2551. ob_start();
  2552. new zerobin;
  2553. $content = ob_get_contents();
  2554. $response = json_decode($content, true);
  2555. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2556. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2557. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2558. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2559. }
  2560. /**
  2561. * @runInSeparateProcess
  2562. */
  2563. public function testRead34()
  2564. {
  2565. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2566. $this->_model->create(self::$pasteid, self::$paste);
  2567. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2568. ob_start();
  2569. new zerobin;
  2570. $content = ob_get_contents();
  2571. $this->assertTag(
  2572. array(
  2573. 'id' => 'cipherdata',
  2574. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2575. ),
  2576. $content,
  2577. 'outputs data correctly'
  2578. );
  2579. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2580. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2581. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2583. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2584. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2585. }
  2586. /**
  2587. * @runInSeparateProcess
  2588. */
  2589. public function testDelete34()
  2590. {
  2591. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2592. $this->_model->create(self::$pasteid, self::$paste);
  2593. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2594. $_GET['pasteid'] = self::$pasteid;
  2595. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2596. ob_start();
  2597. new zerobin;
  2598. $content = ob_get_contents();
  2599. $this->assertTag(
  2600. array(
  2601. 'id' => 'status',
  2602. 'content' => 'Paste was properly deleted'
  2603. ),
  2604. $content,
  2605. 'outputs deleted status correctly'
  2606. );
  2607. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2608. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2609. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2610. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2611. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2612. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2613. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2614. }
  2615. /**
  2616. * @runInSeparateProcess
  2617. */
  2618. public function testView35()
  2619. {
  2620. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2621. ob_start();
  2622. new zerobin;
  2623. $content = ob_get_contents();
  2624. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2625. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2626. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2627. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2628. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2629. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2630. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2631. }
  2632. /**
  2633. * @runInSeparateProcess
  2634. */
  2635. public function testCreate35()
  2636. {
  2637. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2638. $_POST = self::$paste;
  2639. $_SERVER['REMOTE_ADDR'] = '::1';
  2640. sleep(3);
  2641. ob_start();
  2642. new zerobin;
  2643. $content = ob_get_contents();
  2644. $response = json_decode($content, true);
  2645. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2646. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2647. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2648. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2649. }
  2650. /**
  2651. * @runInSeparateProcess
  2652. */
  2653. public function testRead35()
  2654. {
  2655. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2656. $this->_model->create(self::$pasteid, self::$paste);
  2657. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2658. ob_start();
  2659. new zerobin;
  2660. $content = ob_get_contents();
  2661. $this->assertTag(
  2662. array(
  2663. 'id' => 'cipherdata',
  2664. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2665. ),
  2666. $content,
  2667. 'outputs data correctly'
  2668. );
  2669. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2670. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2671. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2672. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2673. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2674. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2675. }
  2676. /**
  2677. * @runInSeparateProcess
  2678. */
  2679. public function testDelete35()
  2680. {
  2681. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2682. $this->_model->create(self::$pasteid, self::$paste);
  2683. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2684. $_GET['pasteid'] = self::$pasteid;
  2685. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2686. ob_start();
  2687. new zerobin;
  2688. $content = ob_get_contents();
  2689. $this->assertTag(
  2690. array(
  2691. 'id' => 'status',
  2692. 'content' => 'Paste was properly deleted'
  2693. ),
  2694. $content,
  2695. 'outputs deleted status correctly'
  2696. );
  2697. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2698. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2699. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2700. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2701. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2702. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2703. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2704. }
  2705. /**
  2706. * @runInSeparateProcess
  2707. */
  2708. public function testView36()
  2709. {
  2710. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2711. ob_start();
  2712. new zerobin;
  2713. $content = ob_get_contents();
  2714. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2715. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2716. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2717. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2718. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2719. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2720. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2721. }
  2722. /**
  2723. * @runInSeparateProcess
  2724. */
  2725. public function testCreate36()
  2726. {
  2727. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2728. $_POST = self::$paste;
  2729. $_SERVER['REMOTE_ADDR'] = '::1';
  2730. sleep(3);
  2731. ob_start();
  2732. new zerobin;
  2733. $content = ob_get_contents();
  2734. $response = json_decode($content, true);
  2735. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2736. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2737. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2738. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2739. }
  2740. /**
  2741. * @runInSeparateProcess
  2742. */
  2743. public function testRead36()
  2744. {
  2745. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2746. $this->_model->create(self::$pasteid, self::$paste);
  2747. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2748. ob_start();
  2749. new zerobin;
  2750. $content = ob_get_contents();
  2751. $this->assertTag(
  2752. array(
  2753. 'id' => 'cipherdata',
  2754. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2755. ),
  2756. $content,
  2757. 'outputs data correctly'
  2758. );
  2759. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2760. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2761. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2762. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2763. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2764. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2765. }
  2766. /**
  2767. * @runInSeparateProcess
  2768. */
  2769. public function testDelete36()
  2770. {
  2771. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2772. $this->_model->create(self::$pasteid, self::$paste);
  2773. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2774. $_GET['pasteid'] = self::$pasteid;
  2775. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2776. ob_start();
  2777. new zerobin;
  2778. $content = ob_get_contents();
  2779. $this->assertTag(
  2780. array(
  2781. 'id' => 'status',
  2782. 'content' => 'Paste was properly deleted'
  2783. ),
  2784. $content,
  2785. 'outputs deleted status correctly'
  2786. );
  2787. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2788. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2789. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2790. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2791. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2792. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2793. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2794. }
  2795. /**
  2796. * @runInSeparateProcess
  2797. */
  2798. public function testView37()
  2799. {
  2800. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2801. ob_start();
  2802. new zerobin;
  2803. $content = ob_get_contents();
  2804. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2805. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2806. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2807. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2808. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2809. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2810. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2811. }
  2812. /**
  2813. * @runInSeparateProcess
  2814. */
  2815. public function testCreate37()
  2816. {
  2817. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2818. $_POST = self::$paste;
  2819. $_SERVER['REMOTE_ADDR'] = '::1';
  2820. sleep(3);
  2821. ob_start();
  2822. new zerobin;
  2823. $content = ob_get_contents();
  2824. $response = json_decode($content, true);
  2825. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2826. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2827. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2828. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2829. }
  2830. /**
  2831. * @runInSeparateProcess
  2832. */
  2833. public function testRead37()
  2834. {
  2835. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2836. $this->_model->create(self::$pasteid, self::$paste);
  2837. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2838. ob_start();
  2839. new zerobin;
  2840. $content = ob_get_contents();
  2841. $this->assertTag(
  2842. array(
  2843. 'id' => 'cipherdata',
  2844. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2845. ),
  2846. $content,
  2847. 'outputs data correctly'
  2848. );
  2849. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2850. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2851. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2852. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2853. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2854. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2855. }
  2856. /**
  2857. * @runInSeparateProcess
  2858. */
  2859. public function testDelete37()
  2860. {
  2861. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2862. $this->_model->create(self::$pasteid, self::$paste);
  2863. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2864. $_GET['pasteid'] = self::$pasteid;
  2865. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2866. ob_start();
  2867. new zerobin;
  2868. $content = ob_get_contents();
  2869. $this->assertTag(
  2870. array(
  2871. 'id' => 'status',
  2872. 'content' => 'Paste was properly deleted'
  2873. ),
  2874. $content,
  2875. 'outputs deleted status correctly'
  2876. );
  2877. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2878. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2879. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  2880. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  2881. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2882. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2883. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2884. }
  2885. /**
  2886. * @runInSeparateProcess
  2887. */
  2888. public function testView38()
  2889. {
  2890. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2891. ob_start();
  2892. new zerobin;
  2893. $content = ob_get_contents();
  2894. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2895. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2896. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2897. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2898. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2899. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2900. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2901. }
  2902. /**
  2903. * @runInSeparateProcess
  2904. */
  2905. public function testCreate38()
  2906. {
  2907. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2908. $_POST = self::$paste;
  2909. $_SERVER['REMOTE_ADDR'] = '::1';
  2910. sleep(3);
  2911. ob_start();
  2912. new zerobin;
  2913. $content = ob_get_contents();
  2914. $response = json_decode($content, true);
  2915. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  2916. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  2917. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  2918. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  2919. }
  2920. /**
  2921. * @runInSeparateProcess
  2922. */
  2923. public function testRead38()
  2924. {
  2925. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2926. $this->_model->create(self::$pasteid, self::$paste);
  2927. $_SERVER['QUERY_STRING'] = self::$pasteid;
  2928. ob_start();
  2929. new zerobin;
  2930. $content = ob_get_contents();
  2931. $this->assertTag(
  2932. array(
  2933. 'id' => 'cipherdata',
  2934. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  2935. ),
  2936. $content,
  2937. 'outputs data correctly'
  2938. );
  2939. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2940. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2941. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2942. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2943. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2944. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2945. }
  2946. /**
  2947. * @runInSeparateProcess
  2948. */
  2949. public function testDelete38()
  2950. {
  2951. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2952. $this->_model->create(self::$pasteid, self::$paste);
  2953. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  2954. $_GET['pasteid'] = self::$pasteid;
  2955. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  2956. ob_start();
  2957. new zerobin;
  2958. $content = ob_get_contents();
  2959. $this->assertTag(
  2960. array(
  2961. 'id' => 'status',
  2962. 'content' => 'Paste was properly deleted'
  2963. ),
  2964. $content,
  2965. 'outputs deleted status correctly'
  2966. );
  2967. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  2968. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  2969. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2970. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2971. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2972. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2973. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2974. }
  2975. /**
  2976. * @runInSeparateProcess
  2977. */
  2978. public function testView39()
  2979. {
  2980. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2981. ob_start();
  2982. new zerobin;
  2983. $content = ob_get_contents();
  2984. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  2985. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  2986. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  2987. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  2988. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  2989. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  2990. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  2991. }
  2992. /**
  2993. * @runInSeparateProcess
  2994. */
  2995. public function testCreate39()
  2996. {
  2997. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  2998. $_POST = self::$paste;
  2999. $_SERVER['REMOTE_ADDR'] = '::1';
  3000. sleep(3);
  3001. ob_start();
  3002. new zerobin;
  3003. $content = ob_get_contents();
  3004. $response = json_decode($content, true);
  3005. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  3006. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  3007. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3008. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3009. }
  3010. /**
  3011. * @runInSeparateProcess
  3012. */
  3013. public function testRead39()
  3014. {
  3015. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3016. $this->_model->create(self::$pasteid, self::$paste);
  3017. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3018. ob_start();
  3019. new zerobin;
  3020. $content = ob_get_contents();
  3021. $this->assertTag(
  3022. array(
  3023. 'id' => 'cipherdata',
  3024. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3025. ),
  3026. $content,
  3027. 'outputs data correctly'
  3028. );
  3029. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3030. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3031. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3032. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3033. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3034. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3035. }
  3036. /**
  3037. * @runInSeparateProcess
  3038. */
  3039. public function testDelete39()
  3040. {
  3041. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3042. $this->_model->create(self::$pasteid, self::$paste);
  3043. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3044. $_GET['pasteid'] = self::$pasteid;
  3045. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3046. ob_start();
  3047. new zerobin;
  3048. $content = ob_get_contents();
  3049. $this->assertTag(
  3050. array(
  3051. 'id' => 'status',
  3052. 'content' => 'Paste was properly deleted'
  3053. ),
  3054. $content,
  3055. 'outputs deleted status correctly'
  3056. );
  3057. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3058. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3059. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3060. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3061. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3062. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3063. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3064. }
  3065. /**
  3066. * @runInSeparateProcess
  3067. */
  3068. public function testView40()
  3069. {
  3070. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3071. ob_start();
  3072. new zerobin;
  3073. $content = ob_get_contents();
  3074. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3075. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3076. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3077. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3078. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3079. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3080. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3081. }
  3082. /**
  3083. * @runInSeparateProcess
  3084. */
  3085. public function testCreate40()
  3086. {
  3087. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3088. $_POST = self::$paste;
  3089. $_SERVER['REMOTE_ADDR'] = '::1';
  3090. ob_start();
  3091. new zerobin;
  3092. $content = ob_get_contents();
  3093. $response = json_decode($content, true);
  3094. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3095. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3096. }
  3097. /**
  3098. * @runInSeparateProcess
  3099. */
  3100. public function testRead40()
  3101. {
  3102. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3103. $this->_model->create(self::$pasteid, self::$paste);
  3104. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3105. ob_start();
  3106. new zerobin;
  3107. $content = ob_get_contents();
  3108. $this->assertTag(
  3109. array(
  3110. 'id' => 'cipherdata',
  3111. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3112. ),
  3113. $content,
  3114. 'outputs data correctly'
  3115. );
  3116. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3117. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3118. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3119. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3120. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3121. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3122. }
  3123. /**
  3124. * @runInSeparateProcess
  3125. */
  3126. public function testDelete40()
  3127. {
  3128. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3129. $this->_model->create(self::$pasteid, self::$paste);
  3130. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3131. $_GET['pasteid'] = self::$pasteid;
  3132. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3133. ob_start();
  3134. new zerobin;
  3135. $content = ob_get_contents();
  3136. $this->assertTag(
  3137. array(
  3138. 'id' => 'status',
  3139. 'content' => 'Paste was properly deleted'
  3140. ),
  3141. $content,
  3142. 'outputs deleted status correctly'
  3143. );
  3144. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3145. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3146. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3147. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3148. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3149. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3150. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3151. }
  3152. /**
  3153. * @runInSeparateProcess
  3154. */
  3155. public function testView41()
  3156. {
  3157. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3158. ob_start();
  3159. new zerobin;
  3160. $content = ob_get_contents();
  3161. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3162. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3163. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3164. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3165. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3166. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3167. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3168. }
  3169. /**
  3170. * @runInSeparateProcess
  3171. */
  3172. public function testCreate41()
  3173. {
  3174. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3175. $_POST = self::$paste;
  3176. $_SERVER['REMOTE_ADDR'] = '::1';
  3177. ob_start();
  3178. new zerobin;
  3179. $content = ob_get_contents();
  3180. $response = json_decode($content, true);
  3181. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3182. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3183. }
  3184. /**
  3185. * @runInSeparateProcess
  3186. */
  3187. public function testRead41()
  3188. {
  3189. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3190. $this->_model->create(self::$pasteid, self::$paste);
  3191. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3192. ob_start();
  3193. new zerobin;
  3194. $content = ob_get_contents();
  3195. $this->assertTag(
  3196. array(
  3197. 'id' => 'cipherdata',
  3198. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3199. ),
  3200. $content,
  3201. 'outputs data correctly'
  3202. );
  3203. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3204. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3205. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3206. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3207. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3208. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3209. }
  3210. /**
  3211. * @runInSeparateProcess
  3212. */
  3213. public function testDelete41()
  3214. {
  3215. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3216. $this->_model->create(self::$pasteid, self::$paste);
  3217. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3218. $_GET['pasteid'] = self::$pasteid;
  3219. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3220. ob_start();
  3221. new zerobin;
  3222. $content = ob_get_contents();
  3223. $this->assertTag(
  3224. array(
  3225. 'id' => 'status',
  3226. 'content' => 'Paste was properly deleted'
  3227. ),
  3228. $content,
  3229. 'outputs deleted status correctly'
  3230. );
  3231. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3232. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3233. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3234. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3235. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3236. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3237. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3238. }
  3239. /**
  3240. * @runInSeparateProcess
  3241. */
  3242. public function testView42()
  3243. {
  3244. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3245. ob_start();
  3246. new zerobin;
  3247. $content = ob_get_contents();
  3248. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3249. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3250. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3251. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3252. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3253. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3254. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3255. }
  3256. /**
  3257. * @runInSeparateProcess
  3258. */
  3259. public function testCreate42()
  3260. {
  3261. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3262. $_POST = self::$paste;
  3263. $_SERVER['REMOTE_ADDR'] = '::1';
  3264. ob_start();
  3265. new zerobin;
  3266. $content = ob_get_contents();
  3267. $response = json_decode($content, true);
  3268. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3269. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3270. }
  3271. /**
  3272. * @runInSeparateProcess
  3273. */
  3274. public function testRead42()
  3275. {
  3276. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3277. $this->_model->create(self::$pasteid, self::$paste);
  3278. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3279. ob_start();
  3280. new zerobin;
  3281. $content = ob_get_contents();
  3282. $this->assertTag(
  3283. array(
  3284. 'id' => 'cipherdata',
  3285. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3286. ),
  3287. $content,
  3288. 'outputs data correctly'
  3289. );
  3290. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3291. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3292. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3293. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3294. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3295. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3296. }
  3297. /**
  3298. * @runInSeparateProcess
  3299. */
  3300. public function testDelete42()
  3301. {
  3302. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3303. $this->_model->create(self::$pasteid, self::$paste);
  3304. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3305. $_GET['pasteid'] = self::$pasteid;
  3306. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3307. ob_start();
  3308. new zerobin;
  3309. $content = ob_get_contents();
  3310. $this->assertTag(
  3311. array(
  3312. 'id' => 'status',
  3313. 'content' => 'Paste was properly deleted'
  3314. ),
  3315. $content,
  3316. 'outputs deleted status correctly'
  3317. );
  3318. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3319. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3320. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3321. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3322. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3323. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3324. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3325. }
  3326. /**
  3327. * @runInSeparateProcess
  3328. */
  3329. public function testView43()
  3330. {
  3331. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3332. ob_start();
  3333. new zerobin;
  3334. $content = ob_get_contents();
  3335. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3336. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3337. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3338. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3339. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3340. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3341. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3342. }
  3343. /**
  3344. * @runInSeparateProcess
  3345. */
  3346. public function testCreate43()
  3347. {
  3348. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3349. $_POST = self::$paste;
  3350. $_SERVER['REMOTE_ADDR'] = '::1';
  3351. ob_start();
  3352. new zerobin;
  3353. $content = ob_get_contents();
  3354. $response = json_decode($content, true);
  3355. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3356. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3357. }
  3358. /**
  3359. * @runInSeparateProcess
  3360. */
  3361. public function testRead43()
  3362. {
  3363. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3364. $this->_model->create(self::$pasteid, self::$paste);
  3365. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3366. ob_start();
  3367. new zerobin;
  3368. $content = ob_get_contents();
  3369. $this->assertTag(
  3370. array(
  3371. 'id' => 'cipherdata',
  3372. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3373. ),
  3374. $content,
  3375. 'outputs data correctly'
  3376. );
  3377. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3378. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3379. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3380. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3381. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3382. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3383. }
  3384. /**
  3385. * @runInSeparateProcess
  3386. */
  3387. public function testDelete43()
  3388. {
  3389. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3390. $this->_model->create(self::$pasteid, self::$paste);
  3391. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3392. $_GET['pasteid'] = self::$pasteid;
  3393. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3394. ob_start();
  3395. new zerobin;
  3396. $content = ob_get_contents();
  3397. $this->assertTag(
  3398. array(
  3399. 'id' => 'status',
  3400. 'content' => 'Paste was properly deleted'
  3401. ),
  3402. $content,
  3403. 'outputs deleted status correctly'
  3404. );
  3405. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3406. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3407. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3408. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3409. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3410. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3411. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3412. }
  3413. /**
  3414. * @runInSeparateProcess
  3415. */
  3416. public function testView44()
  3417. {
  3418. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3419. ob_start();
  3420. new zerobin;
  3421. $content = ob_get_contents();
  3422. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3423. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3424. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3425. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3426. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3427. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3428. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3429. }
  3430. /**
  3431. * @runInSeparateProcess
  3432. */
  3433. public function testCreate44()
  3434. {
  3435. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3436. $_POST = self::$paste;
  3437. $_SERVER['REMOTE_ADDR'] = '::1';
  3438. ob_start();
  3439. new zerobin;
  3440. $content = ob_get_contents();
  3441. $response = json_decode($content, true);
  3442. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3443. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3444. }
  3445. /**
  3446. * @runInSeparateProcess
  3447. */
  3448. public function testRead44()
  3449. {
  3450. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3451. $this->_model->create(self::$pasteid, self::$paste);
  3452. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3453. ob_start();
  3454. new zerobin;
  3455. $content = ob_get_contents();
  3456. $this->assertTag(
  3457. array(
  3458. 'id' => 'cipherdata',
  3459. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3460. ),
  3461. $content,
  3462. 'outputs data correctly'
  3463. );
  3464. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3465. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3466. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3467. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3468. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3469. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3470. }
  3471. /**
  3472. * @runInSeparateProcess
  3473. */
  3474. public function testDelete44()
  3475. {
  3476. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3477. $this->_model->create(self::$pasteid, self::$paste);
  3478. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3479. $_GET['pasteid'] = self::$pasteid;
  3480. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3481. ob_start();
  3482. new zerobin;
  3483. $content = ob_get_contents();
  3484. $this->assertTag(
  3485. array(
  3486. 'id' => 'status',
  3487. 'content' => 'Paste was properly deleted'
  3488. ),
  3489. $content,
  3490. 'outputs deleted status correctly'
  3491. );
  3492. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3493. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3494. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3495. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3496. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3497. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3498. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3499. }
  3500. /**
  3501. * @runInSeparateProcess
  3502. */
  3503. public function testView45()
  3504. {
  3505. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3506. ob_start();
  3507. new zerobin;
  3508. $content = ob_get_contents();
  3509. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3510. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3511. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3512. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3513. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3514. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3515. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3516. }
  3517. /**
  3518. * @runInSeparateProcess
  3519. */
  3520. public function testCreate45()
  3521. {
  3522. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3523. $_POST = self::$paste;
  3524. $_SERVER['REMOTE_ADDR'] = '::1';
  3525. ob_start();
  3526. new zerobin;
  3527. $content = ob_get_contents();
  3528. $response = json_decode($content, true);
  3529. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3530. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3531. }
  3532. /**
  3533. * @runInSeparateProcess
  3534. */
  3535. public function testRead45()
  3536. {
  3537. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3538. $this->_model->create(self::$pasteid, self::$paste);
  3539. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3540. ob_start();
  3541. new zerobin;
  3542. $content = ob_get_contents();
  3543. $this->assertTag(
  3544. array(
  3545. 'id' => 'cipherdata',
  3546. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3547. ),
  3548. $content,
  3549. 'outputs data correctly'
  3550. );
  3551. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3552. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3553. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3554. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3555. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3556. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3557. }
  3558. /**
  3559. * @runInSeparateProcess
  3560. */
  3561. public function testDelete45()
  3562. {
  3563. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3564. $this->_model->create(self::$pasteid, self::$paste);
  3565. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3566. $_GET['pasteid'] = self::$pasteid;
  3567. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3568. ob_start();
  3569. new zerobin;
  3570. $content = ob_get_contents();
  3571. $this->assertTag(
  3572. array(
  3573. 'id' => 'status',
  3574. 'content' => 'Paste was properly deleted'
  3575. ),
  3576. $content,
  3577. 'outputs deleted status correctly'
  3578. );
  3579. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3580. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3581. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3582. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3583. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3584. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3585. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3586. }
  3587. /**
  3588. * @runInSeparateProcess
  3589. */
  3590. public function testView46()
  3591. {
  3592. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3593. ob_start();
  3594. new zerobin;
  3595. $content = ob_get_contents();
  3596. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3597. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3598. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3599. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3600. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3601. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3602. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3603. }
  3604. /**
  3605. * @runInSeparateProcess
  3606. */
  3607. public function testCreate46()
  3608. {
  3609. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3610. $_POST = self::$paste;
  3611. $_SERVER['REMOTE_ADDR'] = '::1';
  3612. ob_start();
  3613. new zerobin;
  3614. $content = ob_get_contents();
  3615. $response = json_decode($content, true);
  3616. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3617. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3618. }
  3619. /**
  3620. * @runInSeparateProcess
  3621. */
  3622. public function testRead46()
  3623. {
  3624. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3625. $this->_model->create(self::$pasteid, self::$paste);
  3626. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3627. ob_start();
  3628. new zerobin;
  3629. $content = ob_get_contents();
  3630. $this->assertTag(
  3631. array(
  3632. 'id' => 'cipherdata',
  3633. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3634. ),
  3635. $content,
  3636. 'outputs data correctly'
  3637. );
  3638. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3639. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3640. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3641. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3642. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3643. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3644. }
  3645. /**
  3646. * @runInSeparateProcess
  3647. */
  3648. public function testDelete46()
  3649. {
  3650. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3651. $this->_model->create(self::$pasteid, self::$paste);
  3652. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3653. $_GET['pasteid'] = self::$pasteid;
  3654. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3655. ob_start();
  3656. new zerobin;
  3657. $content = ob_get_contents();
  3658. $this->assertTag(
  3659. array(
  3660. 'id' => 'status',
  3661. 'content' => 'Paste was properly deleted'
  3662. ),
  3663. $content,
  3664. 'outputs deleted status correctly'
  3665. );
  3666. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3667. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3668. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3669. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3670. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3671. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3672. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3673. }
  3674. /**
  3675. * @runInSeparateProcess
  3676. */
  3677. public function testView47()
  3678. {
  3679. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3680. ob_start();
  3681. new zerobin;
  3682. $content = ob_get_contents();
  3683. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3684. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3685. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3686. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3687. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  3688. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3689. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3690. }
  3691. /**
  3692. * @runInSeparateProcess
  3693. */
  3694. public function testCreate47()
  3695. {
  3696. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3697. $_POST = self::$paste;
  3698. $_SERVER['REMOTE_ADDR'] = '::1';
  3699. ob_start();
  3700. new zerobin;
  3701. $content = ob_get_contents();
  3702. $response = json_decode($content, true);
  3703. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3704. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3705. }
  3706. /**
  3707. * @runInSeparateProcess
  3708. */
  3709. public function testRead47()
  3710. {
  3711. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3712. $this->_model->create(self::$pasteid, self::$paste);
  3713. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3714. ob_start();
  3715. new zerobin;
  3716. $content = ob_get_contents();
  3717. $this->assertTag(
  3718. array(
  3719. 'id' => 'cipherdata',
  3720. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3721. ),
  3722. $content,
  3723. 'outputs data correctly'
  3724. );
  3725. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3726. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3727. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3728. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3729. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3730. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3731. }
  3732. /**
  3733. * @runInSeparateProcess
  3734. */
  3735. public function testDelete47()
  3736. {
  3737. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3738. $this->_model->create(self::$pasteid, self::$paste);
  3739. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3740. $_GET['pasteid'] = self::$pasteid;
  3741. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3742. ob_start();
  3743. new zerobin;
  3744. $content = ob_get_contents();
  3745. $this->assertTag(
  3746. array(
  3747. 'id' => 'status',
  3748. 'content' => 'Paste was properly deleted'
  3749. ),
  3750. $content,
  3751. 'outputs deleted status correctly'
  3752. );
  3753. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3754. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3755. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3756. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3757. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3758. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  3759. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  3760. }
  3761. /**
  3762. * @runInSeparateProcess
  3763. */
  3764. public function testView48()
  3765. {
  3766. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3767. ob_start();
  3768. new zerobin;
  3769. $content = ob_get_contents();
  3770. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3771. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3772. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3773. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3774. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  3775. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3776. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3777. }
  3778. /**
  3779. * @runInSeparateProcess
  3780. */
  3781. public function testCreate48()
  3782. {
  3783. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3784. $_POST = self::$paste;
  3785. $_SERVER['REMOTE_ADDR'] = '::1';
  3786. sleep(3);
  3787. ob_start();
  3788. new zerobin;
  3789. $content = ob_get_contents();
  3790. $response = json_decode($content, true);
  3791. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  3792. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  3793. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3794. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3795. }
  3796. /**
  3797. * @runInSeparateProcess
  3798. */
  3799. public function testRead48()
  3800. {
  3801. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3802. $this->_model->create(self::$pasteid, self::$paste);
  3803. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3804. ob_start();
  3805. new zerobin;
  3806. $content = ob_get_contents();
  3807. $this->assertTag(
  3808. array(
  3809. 'id' => 'cipherdata',
  3810. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3811. ),
  3812. $content,
  3813. 'outputs data correctly'
  3814. );
  3815. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3816. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3817. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3818. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3819. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3820. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3821. }
  3822. /**
  3823. * @runInSeparateProcess
  3824. */
  3825. public function testDelete48()
  3826. {
  3827. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3828. $this->_model->create(self::$pasteid, self::$paste);
  3829. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3830. $_GET['pasteid'] = self::$pasteid;
  3831. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3832. ob_start();
  3833. new zerobin;
  3834. $content = ob_get_contents();
  3835. $this->assertTag(
  3836. array(
  3837. 'id' => 'status',
  3838. 'content' => 'Paste was properly deleted'
  3839. ),
  3840. $content,
  3841. 'outputs deleted status correctly'
  3842. );
  3843. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3844. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3845. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3846. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3847. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3848. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3849. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3850. }
  3851. /**
  3852. * @runInSeparateProcess
  3853. */
  3854. public function testView49()
  3855. {
  3856. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3857. ob_start();
  3858. new zerobin;
  3859. $content = ob_get_contents();
  3860. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3861. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3862. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3863. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3864. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  3865. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3866. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3867. }
  3868. /**
  3869. * @runInSeparateProcess
  3870. */
  3871. public function testCreate49()
  3872. {
  3873. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3874. $_POST = self::$paste;
  3875. $_SERVER['REMOTE_ADDR'] = '::1';
  3876. sleep(3);
  3877. ob_start();
  3878. new zerobin;
  3879. $content = ob_get_contents();
  3880. $response = json_decode($content, true);
  3881. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  3882. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  3883. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3884. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3885. }
  3886. /**
  3887. * @runInSeparateProcess
  3888. */
  3889. public function testRead49()
  3890. {
  3891. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3892. $this->_model->create(self::$pasteid, self::$paste);
  3893. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3894. ob_start();
  3895. new zerobin;
  3896. $content = ob_get_contents();
  3897. $this->assertTag(
  3898. array(
  3899. 'id' => 'cipherdata',
  3900. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3901. ),
  3902. $content,
  3903. 'outputs data correctly'
  3904. );
  3905. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3906. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3907. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3908. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3909. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3910. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3911. }
  3912. /**
  3913. * @runInSeparateProcess
  3914. */
  3915. public function testDelete49()
  3916. {
  3917. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3918. $this->_model->create(self::$pasteid, self::$paste);
  3919. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  3920. $_GET['pasteid'] = self::$pasteid;
  3921. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  3922. ob_start();
  3923. new zerobin;
  3924. $content = ob_get_contents();
  3925. $this->assertTag(
  3926. array(
  3927. 'id' => 'status',
  3928. 'content' => 'Paste was properly deleted'
  3929. ),
  3930. $content,
  3931. 'outputs deleted status correctly'
  3932. );
  3933. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  3934. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  3935. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  3936. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  3937. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  3938. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3939. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3940. }
  3941. /**
  3942. * @runInSeparateProcess
  3943. */
  3944. public function testView50()
  3945. {
  3946. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3947. ob_start();
  3948. new zerobin;
  3949. $content = ob_get_contents();
  3950. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3951. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3952. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3953. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3954. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  3955. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  3956. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  3957. }
  3958. /**
  3959. * @runInSeparateProcess
  3960. */
  3961. public function testCreate50()
  3962. {
  3963. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3964. $_POST = self::$paste;
  3965. $_SERVER['REMOTE_ADDR'] = '::1';
  3966. sleep(3);
  3967. ob_start();
  3968. new zerobin;
  3969. $content = ob_get_contents();
  3970. $response = json_decode($content, true);
  3971. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  3972. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  3973. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  3974. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  3975. }
  3976. /**
  3977. * @runInSeparateProcess
  3978. */
  3979. public function testRead50()
  3980. {
  3981. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  3982. $this->_model->create(self::$pasteid, self::$paste);
  3983. $_SERVER['QUERY_STRING'] = self::$pasteid;
  3984. ob_start();
  3985. new zerobin;
  3986. $content = ob_get_contents();
  3987. $this->assertTag(
  3988. array(
  3989. 'id' => 'cipherdata',
  3990. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  3991. ),
  3992. $content,
  3993. 'outputs data correctly'
  3994. );
  3995. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  3996. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  3997. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  3998. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  3999. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4000. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4001. }
  4002. /**
  4003. * @runInSeparateProcess
  4004. */
  4005. public function testDelete50()
  4006. {
  4007. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4008. $this->_model->create(self::$pasteid, self::$paste);
  4009. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4010. $_GET['pasteid'] = self::$pasteid;
  4011. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4012. ob_start();
  4013. new zerobin;
  4014. $content = ob_get_contents();
  4015. $this->assertTag(
  4016. array(
  4017. 'id' => 'status',
  4018. 'content' => 'Paste was properly deleted'
  4019. ),
  4020. $content,
  4021. 'outputs deleted status correctly'
  4022. );
  4023. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4024. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4025. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4026. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4027. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4028. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4029. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4030. }
  4031. /**
  4032. * @runInSeparateProcess
  4033. */
  4034. public function testView51()
  4035. {
  4036. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4037. ob_start();
  4038. new zerobin;
  4039. $content = ob_get_contents();
  4040. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4041. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4042. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4043. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4044. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  4045. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4046. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4047. }
  4048. /**
  4049. * @runInSeparateProcess
  4050. */
  4051. public function testCreate51()
  4052. {
  4053. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4054. $_POST = self::$paste;
  4055. $_SERVER['REMOTE_ADDR'] = '::1';
  4056. sleep(3);
  4057. ob_start();
  4058. new zerobin;
  4059. $content = ob_get_contents();
  4060. $response = json_decode($content, true);
  4061. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  4062. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  4063. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4064. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4065. }
  4066. /**
  4067. * @runInSeparateProcess
  4068. */
  4069. public function testRead51()
  4070. {
  4071. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4072. $this->_model->create(self::$pasteid, self::$paste);
  4073. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4074. ob_start();
  4075. new zerobin;
  4076. $content = ob_get_contents();
  4077. $this->assertTag(
  4078. array(
  4079. 'id' => 'cipherdata',
  4080. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4081. ),
  4082. $content,
  4083. 'outputs data correctly'
  4084. );
  4085. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4086. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4087. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4088. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4089. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4090. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4091. }
  4092. /**
  4093. * @runInSeparateProcess
  4094. */
  4095. public function testDelete51()
  4096. {
  4097. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4098. $this->_model->create(self::$pasteid, self::$paste);
  4099. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4100. $_GET['pasteid'] = self::$pasteid;
  4101. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4102. ob_start();
  4103. new zerobin;
  4104. $content = ob_get_contents();
  4105. $this->assertTag(
  4106. array(
  4107. 'id' => 'status',
  4108. 'content' => 'Paste was properly deleted'
  4109. ),
  4110. $content,
  4111. 'outputs deleted status correctly'
  4112. );
  4113. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4114. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4115. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4116. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4117. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4118. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4119. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4120. }
  4121. /**
  4122. * @runInSeparateProcess
  4123. */
  4124. public function testView52()
  4125. {
  4126. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4127. ob_start();
  4128. new zerobin;
  4129. $content = ob_get_contents();
  4130. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4131. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4132. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4133. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4134. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  4135. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4136. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4137. }
  4138. /**
  4139. * @runInSeparateProcess
  4140. */
  4141. public function testCreate52()
  4142. {
  4143. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4144. $_POST = self::$paste;
  4145. $_SERVER['REMOTE_ADDR'] = '::1';
  4146. sleep(3);
  4147. ob_start();
  4148. new zerobin;
  4149. $content = ob_get_contents();
  4150. $response = json_decode($content, true);
  4151. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  4152. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  4153. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4154. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4155. }
  4156. /**
  4157. * @runInSeparateProcess
  4158. */
  4159. public function testRead52()
  4160. {
  4161. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4162. $this->_model->create(self::$pasteid, self::$paste);
  4163. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4164. ob_start();
  4165. new zerobin;
  4166. $content = ob_get_contents();
  4167. $this->assertTag(
  4168. array(
  4169. 'id' => 'cipherdata',
  4170. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4171. ),
  4172. $content,
  4173. 'outputs data correctly'
  4174. );
  4175. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4176. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4177. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4178. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4179. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4180. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4181. }
  4182. /**
  4183. * @runInSeparateProcess
  4184. */
  4185. public function testDelete52()
  4186. {
  4187. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4188. $this->_model->create(self::$pasteid, self::$paste);
  4189. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4190. $_GET['pasteid'] = self::$pasteid;
  4191. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4192. ob_start();
  4193. new zerobin;
  4194. $content = ob_get_contents();
  4195. $this->assertTag(
  4196. array(
  4197. 'id' => 'status',
  4198. 'content' => 'Paste was properly deleted'
  4199. ),
  4200. $content,
  4201. 'outputs deleted status correctly'
  4202. );
  4203. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4204. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4205. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4206. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4207. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4208. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4209. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4210. }
  4211. /**
  4212. * @runInSeparateProcess
  4213. */
  4214. public function testView53()
  4215. {
  4216. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4217. ob_start();
  4218. new zerobin;
  4219. $content = ob_get_contents();
  4220. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4221. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4222. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4223. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4224. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  4225. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4226. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4227. }
  4228. /**
  4229. * @runInSeparateProcess
  4230. */
  4231. public function testCreate53()
  4232. {
  4233. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4234. $_POST = self::$paste;
  4235. $_SERVER['REMOTE_ADDR'] = '::1';
  4236. sleep(3);
  4237. ob_start();
  4238. new zerobin;
  4239. $content = ob_get_contents();
  4240. $response = json_decode($content, true);
  4241. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  4242. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  4243. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4244. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4245. }
  4246. /**
  4247. * @runInSeparateProcess
  4248. */
  4249. public function testRead53()
  4250. {
  4251. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4252. $this->_model->create(self::$pasteid, self::$paste);
  4253. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4254. ob_start();
  4255. new zerobin;
  4256. $content = ob_get_contents();
  4257. $this->assertTag(
  4258. array(
  4259. 'id' => 'cipherdata',
  4260. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4261. ),
  4262. $content,
  4263. 'outputs data correctly'
  4264. );
  4265. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4266. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4267. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4268. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4269. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4270. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4271. }
  4272. /**
  4273. * @runInSeparateProcess
  4274. */
  4275. public function testDelete53()
  4276. {
  4277. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4278. $this->_model->create(self::$pasteid, self::$paste);
  4279. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4280. $_GET['pasteid'] = self::$pasteid;
  4281. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4282. ob_start();
  4283. new zerobin;
  4284. $content = ob_get_contents();
  4285. $this->assertTag(
  4286. array(
  4287. 'id' => 'status',
  4288. 'content' => 'Paste was properly deleted'
  4289. ),
  4290. $content,
  4291. 'outputs deleted status correctly'
  4292. );
  4293. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4294. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4295. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4296. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4297. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4298. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4299. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4300. }
  4301. /**
  4302. * @runInSeparateProcess
  4303. */
  4304. public function testView54()
  4305. {
  4306. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4307. ob_start();
  4308. new zerobin;
  4309. $content = ob_get_contents();
  4310. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4311. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4312. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4313. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4314. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  4315. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4316. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4317. }
  4318. /**
  4319. * @runInSeparateProcess
  4320. */
  4321. public function testCreate54()
  4322. {
  4323. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4324. $_POST = self::$paste;
  4325. $_SERVER['REMOTE_ADDR'] = '::1';
  4326. sleep(3);
  4327. ob_start();
  4328. new zerobin;
  4329. $content = ob_get_contents();
  4330. $response = json_decode($content, true);
  4331. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  4332. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  4333. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4334. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4335. }
  4336. /**
  4337. * @runInSeparateProcess
  4338. */
  4339. public function testRead54()
  4340. {
  4341. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4342. $this->_model->create(self::$pasteid, self::$paste);
  4343. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4344. ob_start();
  4345. new zerobin;
  4346. $content = ob_get_contents();
  4347. $this->assertTag(
  4348. array(
  4349. 'id' => 'cipherdata',
  4350. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4351. ),
  4352. $content,
  4353. 'outputs data correctly'
  4354. );
  4355. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4356. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4357. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4358. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4359. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4360. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4361. }
  4362. /**
  4363. * @runInSeparateProcess
  4364. */
  4365. public function testDelete54()
  4366. {
  4367. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4368. $this->_model->create(self::$pasteid, self::$paste);
  4369. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4370. $_GET['pasteid'] = self::$pasteid;
  4371. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4372. ob_start();
  4373. new zerobin;
  4374. $content = ob_get_contents();
  4375. $this->assertTag(
  4376. array(
  4377. 'id' => 'status',
  4378. 'content' => 'Paste was properly deleted'
  4379. ),
  4380. $content,
  4381. 'outputs deleted status correctly'
  4382. );
  4383. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4384. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4385. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4386. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4387. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4388. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4389. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4390. }
  4391. /**
  4392. * @runInSeparateProcess
  4393. */
  4394. public function testView55()
  4395. {
  4396. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4397. ob_start();
  4398. new zerobin;
  4399. $content = ob_get_contents();
  4400. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4401. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4402. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4403. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4404. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  4405. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4406. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4407. }
  4408. /**
  4409. * @runInSeparateProcess
  4410. */
  4411. public function testCreate55()
  4412. {
  4413. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4414. $_POST = self::$paste;
  4415. $_SERVER['REMOTE_ADDR'] = '::1';
  4416. sleep(3);
  4417. ob_start();
  4418. new zerobin;
  4419. $content = ob_get_contents();
  4420. $response = json_decode($content, true);
  4421. $this->assertEquals(0, $response["status"], 'when sizelimit limit is not reached, successfully create paste');
  4422. $this->assertTrue($this->_model->exists($response["id"]), 'when sizelimit limit is not reached, paste exists after posting data');
  4423. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4424. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4425. }
  4426. /**
  4427. * @runInSeparateProcess
  4428. */
  4429. public function testRead55()
  4430. {
  4431. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4432. $this->_model->create(self::$pasteid, self::$paste);
  4433. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4434. ob_start();
  4435. new zerobin;
  4436. $content = ob_get_contents();
  4437. $this->assertTag(
  4438. array(
  4439. 'id' => 'cipherdata',
  4440. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4441. ),
  4442. $content,
  4443. 'outputs data correctly'
  4444. );
  4445. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4446. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4447. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4448. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4449. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4450. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4451. }
  4452. /**
  4453. * @runInSeparateProcess
  4454. */
  4455. public function testDelete55()
  4456. {
  4457. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4458. $this->_model->create(self::$pasteid, self::$paste);
  4459. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4460. $_GET['pasteid'] = self::$pasteid;
  4461. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4462. ob_start();
  4463. new zerobin;
  4464. $content = ob_get_contents();
  4465. $this->assertTag(
  4466. array(
  4467. 'id' => 'status',
  4468. 'content' => 'Paste was properly deleted'
  4469. ),
  4470. $content,
  4471. 'outputs deleted status correctly'
  4472. );
  4473. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4474. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4475. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4476. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4477. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4478. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4479. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4480. }
  4481. /**
  4482. * @runInSeparateProcess
  4483. */
  4484. public function testView56()
  4485. {
  4486. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4487. ob_start();
  4488. new zerobin;
  4489. $content = ob_get_contents();
  4490. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4491. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4492. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4493. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4494. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4495. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4496. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4497. }
  4498. /**
  4499. * @runInSeparateProcess
  4500. */
  4501. public function testCreate56()
  4502. {
  4503. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4504. $_POST = self::$paste;
  4505. $_SERVER['REMOTE_ADDR'] = '::1';
  4506. ob_start();
  4507. new zerobin;
  4508. $content = ob_get_contents();
  4509. $response = json_decode($content, true);
  4510. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4511. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4512. }
  4513. /**
  4514. * @runInSeparateProcess
  4515. */
  4516. public function testRead56()
  4517. {
  4518. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4519. $this->_model->create(self::$pasteid, self::$paste);
  4520. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4521. ob_start();
  4522. new zerobin;
  4523. $content = ob_get_contents();
  4524. $this->assertTag(
  4525. array(
  4526. 'id' => 'cipherdata',
  4527. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4528. ),
  4529. $content,
  4530. 'outputs data correctly'
  4531. );
  4532. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4533. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4534. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4535. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4536. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4537. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4538. }
  4539. /**
  4540. * @runInSeparateProcess
  4541. */
  4542. public function testDelete56()
  4543. {
  4544. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4545. $this->_model->create(self::$pasteid, self::$paste);
  4546. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4547. $_GET['pasteid'] = self::$pasteid;
  4548. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4549. ob_start();
  4550. new zerobin;
  4551. $content = ob_get_contents();
  4552. $this->assertTag(
  4553. array(
  4554. 'id' => 'status',
  4555. 'content' => 'Paste was properly deleted'
  4556. ),
  4557. $content,
  4558. 'outputs deleted status correctly'
  4559. );
  4560. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4561. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4562. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4563. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4564. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4565. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4566. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4567. }
  4568. /**
  4569. * @runInSeparateProcess
  4570. */
  4571. public function testView57()
  4572. {
  4573. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4574. ob_start();
  4575. new zerobin;
  4576. $content = ob_get_contents();
  4577. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4578. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4579. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4580. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4581. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4583. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4584. }
  4585. /**
  4586. * @runInSeparateProcess
  4587. */
  4588. public function testCreate57()
  4589. {
  4590. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4591. $_POST = self::$paste;
  4592. $_SERVER['REMOTE_ADDR'] = '::1';
  4593. ob_start();
  4594. new zerobin;
  4595. $content = ob_get_contents();
  4596. $response = json_decode($content, true);
  4597. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4598. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4599. }
  4600. /**
  4601. * @runInSeparateProcess
  4602. */
  4603. public function testRead57()
  4604. {
  4605. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4606. $this->_model->create(self::$pasteid, self::$paste);
  4607. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4608. ob_start();
  4609. new zerobin;
  4610. $content = ob_get_contents();
  4611. $this->assertTag(
  4612. array(
  4613. 'id' => 'cipherdata',
  4614. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4615. ),
  4616. $content,
  4617. 'outputs data correctly'
  4618. );
  4619. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4620. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4621. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4622. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4623. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4624. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4625. }
  4626. /**
  4627. * @runInSeparateProcess
  4628. */
  4629. public function testDelete57()
  4630. {
  4631. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4632. $this->_model->create(self::$pasteid, self::$paste);
  4633. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4634. $_GET['pasteid'] = self::$pasteid;
  4635. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4636. ob_start();
  4637. new zerobin;
  4638. $content = ob_get_contents();
  4639. $this->assertTag(
  4640. array(
  4641. 'id' => 'status',
  4642. 'content' => 'Paste was properly deleted'
  4643. ),
  4644. $content,
  4645. 'outputs deleted status correctly'
  4646. );
  4647. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4648. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4649. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4650. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4651. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  4652. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4653. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4654. }
  4655. /**
  4656. * @runInSeparateProcess
  4657. */
  4658. public function testView58()
  4659. {
  4660. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4661. ob_start();
  4662. new zerobin;
  4663. $content = ob_get_contents();
  4664. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4665. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4666. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4667. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4668. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4669. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4670. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4671. }
  4672. /**
  4673. * @runInSeparateProcess
  4674. */
  4675. public function testCreate58()
  4676. {
  4677. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4678. $_POST = self::$paste;
  4679. $_SERVER['REMOTE_ADDR'] = '::1';
  4680. ob_start();
  4681. new zerobin;
  4682. $content = ob_get_contents();
  4683. $response = json_decode($content, true);
  4684. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4685. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4686. }
  4687. /**
  4688. * @runInSeparateProcess
  4689. */
  4690. public function testRead58()
  4691. {
  4692. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4693. $this->_model->create(self::$pasteid, self::$paste);
  4694. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4695. ob_start();
  4696. new zerobin;
  4697. $content = ob_get_contents();
  4698. $this->assertTag(
  4699. array(
  4700. 'id' => 'cipherdata',
  4701. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4702. ),
  4703. $content,
  4704. 'outputs data correctly'
  4705. );
  4706. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4707. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4708. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4709. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4710. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4711. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4712. }
  4713. /**
  4714. * @runInSeparateProcess
  4715. */
  4716. public function testDelete58()
  4717. {
  4718. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4719. $this->_model->create(self::$pasteid, self::$paste);
  4720. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4721. $_GET['pasteid'] = self::$pasteid;
  4722. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4723. ob_start();
  4724. new zerobin;
  4725. $content = ob_get_contents();
  4726. $this->assertTag(
  4727. array(
  4728. 'id' => 'status',
  4729. 'content' => 'Paste was properly deleted'
  4730. ),
  4731. $content,
  4732. 'outputs deleted status correctly'
  4733. );
  4734. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4735. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4736. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4737. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4738. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4739. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4740. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4741. }
  4742. /**
  4743. * @runInSeparateProcess
  4744. */
  4745. public function testView59()
  4746. {
  4747. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4748. ob_start();
  4749. new zerobin;
  4750. $content = ob_get_contents();
  4751. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4752. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4753. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4754. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4755. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4756. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4757. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4758. }
  4759. /**
  4760. * @runInSeparateProcess
  4761. */
  4762. public function testCreate59()
  4763. {
  4764. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4765. $_POST = self::$paste;
  4766. $_SERVER['REMOTE_ADDR'] = '::1';
  4767. ob_start();
  4768. new zerobin;
  4769. $content = ob_get_contents();
  4770. $response = json_decode($content, true);
  4771. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4772. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4773. }
  4774. /**
  4775. * @runInSeparateProcess
  4776. */
  4777. public function testRead59()
  4778. {
  4779. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4780. $this->_model->create(self::$pasteid, self::$paste);
  4781. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4782. ob_start();
  4783. new zerobin;
  4784. $content = ob_get_contents();
  4785. $this->assertTag(
  4786. array(
  4787. 'id' => 'cipherdata',
  4788. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4789. ),
  4790. $content,
  4791. 'outputs data correctly'
  4792. );
  4793. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4794. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4795. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4796. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4797. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4798. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4799. }
  4800. /**
  4801. * @runInSeparateProcess
  4802. */
  4803. public function testDelete59()
  4804. {
  4805. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4806. $this->_model->create(self::$pasteid, self::$paste);
  4807. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4808. $_GET['pasteid'] = self::$pasteid;
  4809. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4810. ob_start();
  4811. new zerobin;
  4812. $content = ob_get_contents();
  4813. $this->assertTag(
  4814. array(
  4815. 'id' => 'status',
  4816. 'content' => 'Paste was properly deleted'
  4817. ),
  4818. $content,
  4819. 'outputs deleted status correctly'
  4820. );
  4821. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4822. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4823. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  4824. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  4825. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4826. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4827. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4828. }
  4829. /**
  4830. * @runInSeparateProcess
  4831. */
  4832. public function testView60()
  4833. {
  4834. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4835. ob_start();
  4836. new zerobin;
  4837. $content = ob_get_contents();
  4838. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4839. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4840. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4841. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4842. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4843. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4844. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4845. }
  4846. /**
  4847. * @runInSeparateProcess
  4848. */
  4849. public function testCreate60()
  4850. {
  4851. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4852. $_POST = self::$paste;
  4853. $_SERVER['REMOTE_ADDR'] = '::1';
  4854. ob_start();
  4855. new zerobin;
  4856. $content = ob_get_contents();
  4857. $response = json_decode($content, true);
  4858. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4859. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4860. }
  4861. /**
  4862. * @runInSeparateProcess
  4863. */
  4864. public function testRead60()
  4865. {
  4866. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4867. $this->_model->create(self::$pasteid, self::$paste);
  4868. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4869. ob_start();
  4870. new zerobin;
  4871. $content = ob_get_contents();
  4872. $this->assertTag(
  4873. array(
  4874. 'id' => 'cipherdata',
  4875. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4876. ),
  4877. $content,
  4878. 'outputs data correctly'
  4879. );
  4880. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4881. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4882. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4883. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4884. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4885. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4886. }
  4887. /**
  4888. * @runInSeparateProcess
  4889. */
  4890. public function testDelete60()
  4891. {
  4892. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4893. $this->_model->create(self::$pasteid, self::$paste);
  4894. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4895. $_GET['pasteid'] = self::$pasteid;
  4896. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4897. ob_start();
  4898. new zerobin;
  4899. $content = ob_get_contents();
  4900. $this->assertTag(
  4901. array(
  4902. 'id' => 'status',
  4903. 'content' => 'Paste was properly deleted'
  4904. ),
  4905. $content,
  4906. 'outputs deleted status correctly'
  4907. );
  4908. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4909. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  4910. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4911. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4912. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4913. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4914. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4915. }
  4916. /**
  4917. * @runInSeparateProcess
  4918. */
  4919. public function testView61()
  4920. {
  4921. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4922. ob_start();
  4923. new zerobin;
  4924. $content = ob_get_contents();
  4925. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4926. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4927. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4928. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4929. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  4930. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4931. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4932. }
  4933. /**
  4934. * @runInSeparateProcess
  4935. */
  4936. public function testCreate61()
  4937. {
  4938. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4939. $_POST = self::$paste;
  4940. $_SERVER['REMOTE_ADDR'] = '::1';
  4941. ob_start();
  4942. new zerobin;
  4943. $content = ob_get_contents();
  4944. $response = json_decode($content, true);
  4945. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  4946. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  4947. }
  4948. /**
  4949. * @runInSeparateProcess
  4950. */
  4951. public function testRead61()
  4952. {
  4953. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4954. $this->_model->create(self::$pasteid, self::$paste);
  4955. $_SERVER['QUERY_STRING'] = self::$pasteid;
  4956. ob_start();
  4957. new zerobin;
  4958. $content = ob_get_contents();
  4959. $this->assertTag(
  4960. array(
  4961. 'id' => 'cipherdata',
  4962. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  4963. ),
  4964. $content,
  4965. 'outputs data correctly'
  4966. );
  4967. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4968. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4969. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4970. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  4971. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  4972. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  4973. }
  4974. /**
  4975. * @runInSeparateProcess
  4976. */
  4977. public function testDelete61()
  4978. {
  4979. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  4980. $this->_model->create(self::$pasteid, self::$paste);
  4981. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  4982. $_GET['pasteid'] = self::$pasteid;
  4983. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  4984. ob_start();
  4985. new zerobin;
  4986. $content = ob_get_contents();
  4987. $this->assertTag(
  4988. array(
  4989. 'id' => 'status',
  4990. 'content' => 'Paste was properly deleted'
  4991. ),
  4992. $content,
  4993. 'outputs deleted status correctly'
  4994. );
  4995. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  4996. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  4997. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  4998. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  4999. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5000. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5001. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5002. }
  5003. /**
  5004. * @runInSeparateProcess
  5005. */
  5006. public function testView62()
  5007. {
  5008. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5009. ob_start();
  5010. new zerobin;
  5011. $content = ob_get_contents();
  5012. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5013. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5014. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5015. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5016. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  5017. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5018. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5019. }
  5020. /**
  5021. * @runInSeparateProcess
  5022. */
  5023. public function testCreate62()
  5024. {
  5025. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5026. $_POST = self::$paste;
  5027. $_SERVER['REMOTE_ADDR'] = '::1';
  5028. ob_start();
  5029. new zerobin;
  5030. $content = ob_get_contents();
  5031. $response = json_decode($content, true);
  5032. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  5033. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  5034. }
  5035. /**
  5036. * @runInSeparateProcess
  5037. */
  5038. public function testRead62()
  5039. {
  5040. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5041. $this->_model->create(self::$pasteid, self::$paste);
  5042. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5043. ob_start();
  5044. new zerobin;
  5045. $content = ob_get_contents();
  5046. $this->assertTag(
  5047. array(
  5048. 'id' => 'cipherdata',
  5049. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5050. ),
  5051. $content,
  5052. 'outputs data correctly'
  5053. );
  5054. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5055. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5056. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5057. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5058. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5059. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5060. }
  5061. /**
  5062. * @runInSeparateProcess
  5063. */
  5064. public function testDelete62()
  5065. {
  5066. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5067. $this->_model->create(self::$pasteid, self::$paste);
  5068. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5069. $_GET['pasteid'] = self::$pasteid;
  5070. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5071. ob_start();
  5072. new zerobin;
  5073. $content = ob_get_contents();
  5074. $this->assertTag(
  5075. array(
  5076. 'id' => 'status',
  5077. 'content' => 'Paste was properly deleted'
  5078. ),
  5079. $content,
  5080. 'outputs deleted status correctly'
  5081. );
  5082. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5083. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5084. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5085. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5086. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5087. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5088. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5089. }
  5090. /**
  5091. * @runInSeparateProcess
  5092. */
  5093. public function testView63()
  5094. {
  5095. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5096. ob_start();
  5097. new zerobin;
  5098. $content = ob_get_contents();
  5099. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5100. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5101. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5102. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5103. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  5104. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5105. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5106. }
  5107. /**
  5108. * @runInSeparateProcess
  5109. */
  5110. public function testCreate63()
  5111. {
  5112. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5113. $_POST = self::$paste;
  5114. $_SERVER['REMOTE_ADDR'] = '::1';
  5115. ob_start();
  5116. new zerobin;
  5117. $content = ob_get_contents();
  5118. $response = json_decode($content, true);
  5119. $this->assertEquals(0, $response["status"], 'when traffic limit is disabled, successfully create paste');
  5120. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is disabled, paste exists after posting data');
  5121. }
  5122. /**
  5123. * @runInSeparateProcess
  5124. */
  5125. public function testRead63()
  5126. {
  5127. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5128. $this->_model->create(self::$pasteid, self::$paste);
  5129. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5130. ob_start();
  5131. new zerobin;
  5132. $content = ob_get_contents();
  5133. $this->assertTag(
  5134. array(
  5135. 'id' => 'cipherdata',
  5136. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5137. ),
  5138. $content,
  5139. 'outputs data correctly'
  5140. );
  5141. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5142. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5143. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5144. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5145. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5146. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5147. }
  5148. /**
  5149. * @runInSeparateProcess
  5150. */
  5151. public function testDelete63()
  5152. {
  5153. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 0, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5154. $this->_model->create(self::$pasteid, self::$paste);
  5155. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5156. $_GET['pasteid'] = self::$pasteid;
  5157. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5158. ob_start();
  5159. new zerobin;
  5160. $content = ob_get_contents();
  5161. $this->assertTag(
  5162. array(
  5163. 'id' => 'status',
  5164. 'content' => 'Paste was properly deleted'
  5165. ),
  5166. $content,
  5167. 'outputs deleted status correctly'
  5168. );
  5169. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5170. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5171. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5172. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5173. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5174. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  5175. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  5176. }
  5177. /**
  5178. * @runInSeparateProcess
  5179. */
  5180. public function testView64()
  5181. {
  5182. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5183. ob_start();
  5184. new zerobin;
  5185. $content = ob_get_contents();
  5186. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5187. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5188. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5189. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5190. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5191. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5192. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5193. }
  5194. /**
  5195. * @runInSeparateProcess
  5196. */
  5197. public function testCreate64()
  5198. {
  5199. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5200. $_POST = self::$paste;
  5201. $_SERVER['REMOTE_ADDR'] = '::1';
  5202. $_POST["opendiscussion"] = "neither 1 nor 0";
  5203. ob_start();
  5204. new zerobin;
  5205. $content = ob_get_contents();
  5206. $response = json_decode($content, true);
  5207. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  5208. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  5209. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  5210. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  5211. }
  5212. /**
  5213. * @runInSeparateProcess
  5214. */
  5215. public function testRead64()
  5216. {
  5217. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5218. $this->_model->create(self::$pasteid, self::$paste);
  5219. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5220. ob_start();
  5221. new zerobin;
  5222. $content = ob_get_contents();
  5223. $this->assertTag(
  5224. array(
  5225. 'id' => 'cipherdata',
  5226. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5227. ),
  5228. $content,
  5229. 'outputs data correctly'
  5230. );
  5231. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5232. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5233. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5234. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5235. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5236. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5237. }
  5238. /**
  5239. * @runInSeparateProcess
  5240. */
  5241. public function testDelete64()
  5242. {
  5243. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5244. $this->_model->create(self::$pasteid, self::$paste);
  5245. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5246. $_GET['pasteid'] = self::$pasteid;
  5247. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5248. ob_start();
  5249. new zerobin;
  5250. $content = ob_get_contents();
  5251. $this->assertTag(
  5252. array(
  5253. 'id' => 'status',
  5254. 'content' => 'Paste was properly deleted'
  5255. ),
  5256. $content,
  5257. 'outputs deleted status correctly'
  5258. );
  5259. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5260. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5261. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5262. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5263. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5264. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5265. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5266. }
  5267. /**
  5268. * @runInSeparateProcess
  5269. */
  5270. public function testView65()
  5271. {
  5272. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5273. ob_start();
  5274. new zerobin;
  5275. $content = ob_get_contents();
  5276. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5277. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5278. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5279. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5280. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5281. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5282. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5283. }
  5284. /**
  5285. * @runInSeparateProcess
  5286. */
  5287. public function testRead65()
  5288. {
  5289. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5290. $this->_model->create(self::$pasteid, self::$paste);
  5291. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5292. ob_start();
  5293. new zerobin;
  5294. $content = ob_get_contents();
  5295. $this->assertTag(
  5296. array(
  5297. 'id' => 'cipherdata',
  5298. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5299. ),
  5300. $content,
  5301. 'outputs data correctly'
  5302. );
  5303. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5304. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5305. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5306. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5307. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5308. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5309. }
  5310. /**
  5311. * @runInSeparateProcess
  5312. */
  5313. public function testDelete65()
  5314. {
  5315. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5316. $this->_model->create(self::$pasteid, self::$paste);
  5317. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5318. $_GET['pasteid'] = self::$pasteid;
  5319. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5320. ob_start();
  5321. new zerobin;
  5322. $content = ob_get_contents();
  5323. $this->assertTag(
  5324. array(
  5325. 'id' => 'status',
  5326. 'content' => 'Paste was properly deleted'
  5327. ),
  5328. $content,
  5329. 'outputs deleted status correctly'
  5330. );
  5331. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5332. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5333. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5334. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5335. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5336. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5337. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5338. }
  5339. /**
  5340. * @runInSeparateProcess
  5341. */
  5342. public function testView66()
  5343. {
  5344. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5345. ob_start();
  5346. new zerobin;
  5347. $content = ob_get_contents();
  5348. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5349. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5350. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5351. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5352. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5353. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5354. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5355. }
  5356. /**
  5357. * @runInSeparateProcess
  5358. */
  5359. public function testCreate66()
  5360. {
  5361. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5362. $_POST = self::$paste;
  5363. $_SERVER['REMOTE_ADDR'] = '::1';
  5364. ob_start();
  5365. new zerobin;
  5366. $content = ob_get_contents();
  5367. $response = json_decode($content, true);
  5368. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  5369. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  5370. }
  5371. /**
  5372. * @runInSeparateProcess
  5373. */
  5374. public function testRead66()
  5375. {
  5376. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5377. $this->_model->create(self::$pasteid, self::$paste);
  5378. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5379. ob_start();
  5380. new zerobin;
  5381. $content = ob_get_contents();
  5382. $this->assertTag(
  5383. array(
  5384. 'id' => 'cipherdata',
  5385. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5386. ),
  5387. $content,
  5388. 'outputs data correctly'
  5389. );
  5390. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5391. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5392. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5393. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5394. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5395. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5396. }
  5397. /**
  5398. * @runInSeparateProcess
  5399. */
  5400. public function testDelete66()
  5401. {
  5402. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5403. $this->_model->create(self::$pasteid, self::$paste);
  5404. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5405. $_GET['pasteid'] = self::$pasteid;
  5406. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5407. ob_start();
  5408. new zerobin;
  5409. $content = ob_get_contents();
  5410. $this->assertTag(
  5411. array(
  5412. 'id' => 'status',
  5413. 'content' => 'Paste was properly deleted'
  5414. ),
  5415. $content,
  5416. 'outputs deleted status correctly'
  5417. );
  5418. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5419. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5420. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5421. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5422. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5423. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5424. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5425. }
  5426. /**
  5427. * @runInSeparateProcess
  5428. */
  5429. public function testView67()
  5430. {
  5431. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5432. ob_start();
  5433. new zerobin;
  5434. $content = ob_get_contents();
  5435. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5436. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5437. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5438. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5439. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5440. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5441. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5442. }
  5443. /**
  5444. * @runInSeparateProcess
  5445. */
  5446. public function testRead67()
  5447. {
  5448. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5449. $this->_model->create(self::$pasteid, self::$paste);
  5450. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5451. ob_start();
  5452. new zerobin;
  5453. $content = ob_get_contents();
  5454. $this->assertTag(
  5455. array(
  5456. 'id' => 'cipherdata',
  5457. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5458. ),
  5459. $content,
  5460. 'outputs data correctly'
  5461. );
  5462. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5463. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5464. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5465. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5466. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5467. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5468. }
  5469. /**
  5470. * @runInSeparateProcess
  5471. */
  5472. public function testDelete67()
  5473. {
  5474. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5475. $this->_model->create(self::$pasteid, self::$paste);
  5476. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5477. $_GET['pasteid'] = self::$pasteid;
  5478. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5479. ob_start();
  5480. new zerobin;
  5481. $content = ob_get_contents();
  5482. $this->assertTag(
  5483. array(
  5484. 'id' => 'status',
  5485. 'content' => 'Paste was properly deleted'
  5486. ),
  5487. $content,
  5488. 'outputs deleted status correctly'
  5489. );
  5490. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5491. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5492. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5493. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5494. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  5495. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5496. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5497. }
  5498. /**
  5499. * @runInSeparateProcess
  5500. */
  5501. public function testView68()
  5502. {
  5503. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5504. ob_start();
  5505. new zerobin;
  5506. $content = ob_get_contents();
  5507. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5508. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5509. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5510. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5511. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5512. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5513. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5514. }
  5515. /**
  5516. * @runInSeparateProcess
  5517. */
  5518. public function testCreate68()
  5519. {
  5520. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5521. $_POST = self::$paste;
  5522. $_SERVER['REMOTE_ADDR'] = '::1';
  5523. $_POST["opendiscussion"] = "neither 1 nor 0";
  5524. ob_start();
  5525. new zerobin;
  5526. $content = ob_get_contents();
  5527. $response = json_decode($content, true);
  5528. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  5529. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  5530. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  5531. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  5532. }
  5533. /**
  5534. * @runInSeparateProcess
  5535. */
  5536. public function testRead68()
  5537. {
  5538. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5539. $this->_model->create(self::$pasteid, self::$paste);
  5540. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5541. ob_start();
  5542. new zerobin;
  5543. $content = ob_get_contents();
  5544. $this->assertTag(
  5545. array(
  5546. 'id' => 'cipherdata',
  5547. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5548. ),
  5549. $content,
  5550. 'outputs data correctly'
  5551. );
  5552. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5553. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5554. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5555. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5556. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5557. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5558. }
  5559. /**
  5560. * @runInSeparateProcess
  5561. */
  5562. public function testDelete68()
  5563. {
  5564. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5565. $this->_model->create(self::$pasteid, self::$paste);
  5566. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5567. $_GET['pasteid'] = self::$pasteid;
  5568. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5569. ob_start();
  5570. new zerobin;
  5571. $content = ob_get_contents();
  5572. $this->assertTag(
  5573. array(
  5574. 'id' => 'status',
  5575. 'content' => 'Paste was properly deleted'
  5576. ),
  5577. $content,
  5578. 'outputs deleted status correctly'
  5579. );
  5580. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5581. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5583. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5584. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5585. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5586. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5587. }
  5588. /**
  5589. * @runInSeparateProcess
  5590. */
  5591. public function testView69()
  5592. {
  5593. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5594. ob_start();
  5595. new zerobin;
  5596. $content = ob_get_contents();
  5597. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5598. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5599. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5600. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5601. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5602. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5603. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5604. }
  5605. /**
  5606. * @runInSeparateProcess
  5607. */
  5608. public function testRead69()
  5609. {
  5610. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5611. $this->_model->create(self::$pasteid, self::$paste);
  5612. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5613. ob_start();
  5614. new zerobin;
  5615. $content = ob_get_contents();
  5616. $this->assertTag(
  5617. array(
  5618. 'id' => 'cipherdata',
  5619. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5620. ),
  5621. $content,
  5622. 'outputs data correctly'
  5623. );
  5624. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5625. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5626. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5627. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5628. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5629. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5630. }
  5631. /**
  5632. * @runInSeparateProcess
  5633. */
  5634. public function testDelete69()
  5635. {
  5636. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5637. $this->_model->create(self::$pasteid, self::$paste);
  5638. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5639. $_GET['pasteid'] = self::$pasteid;
  5640. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5641. ob_start();
  5642. new zerobin;
  5643. $content = ob_get_contents();
  5644. $this->assertTag(
  5645. array(
  5646. 'id' => 'status',
  5647. 'content' => 'Paste was properly deleted'
  5648. ),
  5649. $content,
  5650. 'outputs deleted status correctly'
  5651. );
  5652. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5653. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5654. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5655. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5656. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5657. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5658. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5659. }
  5660. /**
  5661. * @runInSeparateProcess
  5662. */
  5663. public function testView70()
  5664. {
  5665. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5666. ob_start();
  5667. new zerobin;
  5668. $content = ob_get_contents();
  5669. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5670. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5671. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5672. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5673. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5674. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5675. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5676. }
  5677. /**
  5678. * @runInSeparateProcess
  5679. */
  5680. public function testCreate70()
  5681. {
  5682. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5683. $_POST = self::$paste;
  5684. $_SERVER['REMOTE_ADDR'] = '::1';
  5685. ob_start();
  5686. new zerobin;
  5687. $content = ob_get_contents();
  5688. $response = json_decode($content, true);
  5689. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  5690. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  5691. }
  5692. /**
  5693. * @runInSeparateProcess
  5694. */
  5695. public function testRead70()
  5696. {
  5697. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5698. $this->_model->create(self::$pasteid, self::$paste);
  5699. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5700. ob_start();
  5701. new zerobin;
  5702. $content = ob_get_contents();
  5703. $this->assertTag(
  5704. array(
  5705. 'id' => 'cipherdata',
  5706. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5707. ),
  5708. $content,
  5709. 'outputs data correctly'
  5710. );
  5711. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5712. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5713. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5714. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5715. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5716. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5717. }
  5718. /**
  5719. * @runInSeparateProcess
  5720. */
  5721. public function testDelete70()
  5722. {
  5723. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5724. $this->_model->create(self::$pasteid, self::$paste);
  5725. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5726. $_GET['pasteid'] = self::$pasteid;
  5727. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5728. ob_start();
  5729. new zerobin;
  5730. $content = ob_get_contents();
  5731. $this->assertTag(
  5732. array(
  5733. 'id' => 'status',
  5734. 'content' => 'Paste was properly deleted'
  5735. ),
  5736. $content,
  5737. 'outputs deleted status correctly'
  5738. );
  5739. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5740. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5741. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5742. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5743. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5744. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5745. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5746. }
  5747. /**
  5748. * @runInSeparateProcess
  5749. */
  5750. public function testView71()
  5751. {
  5752. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5753. ob_start();
  5754. new zerobin;
  5755. $content = ob_get_contents();
  5756. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5757. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5758. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5759. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5760. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5761. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5762. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5763. }
  5764. /**
  5765. * @runInSeparateProcess
  5766. */
  5767. public function testRead71()
  5768. {
  5769. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5770. $this->_model->create(self::$pasteid, self::$paste);
  5771. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5772. ob_start();
  5773. new zerobin;
  5774. $content = ob_get_contents();
  5775. $this->assertTag(
  5776. array(
  5777. 'id' => 'cipherdata',
  5778. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5779. ),
  5780. $content,
  5781. 'outputs data correctly'
  5782. );
  5783. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5784. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5785. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5786. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5787. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5788. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5789. }
  5790. /**
  5791. * @runInSeparateProcess
  5792. */
  5793. public function testDelete71()
  5794. {
  5795. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5796. $this->_model->create(self::$pasteid, self::$paste);
  5797. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5798. $_GET['pasteid'] = self::$pasteid;
  5799. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5800. ob_start();
  5801. new zerobin;
  5802. $content = ob_get_contents();
  5803. $this->assertTag(
  5804. array(
  5805. 'id' => 'status',
  5806. 'content' => 'Paste was properly deleted'
  5807. ),
  5808. $content,
  5809. 'outputs deleted status correctly'
  5810. );
  5811. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5812. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5813. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  5814. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  5815. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5816. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5817. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5818. }
  5819. /**
  5820. * @runInSeparateProcess
  5821. */
  5822. public function testView72()
  5823. {
  5824. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5825. ob_start();
  5826. new zerobin;
  5827. $content = ob_get_contents();
  5828. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5829. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5830. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5831. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5832. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5833. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5834. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5835. }
  5836. /**
  5837. * @runInSeparateProcess
  5838. */
  5839. public function testCreate72()
  5840. {
  5841. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5842. $_POST = self::$paste;
  5843. $_SERVER['REMOTE_ADDR'] = '::1';
  5844. $_POST["opendiscussion"] = "neither 1 nor 0";
  5845. ob_start();
  5846. new zerobin;
  5847. $content = ob_get_contents();
  5848. $response = json_decode($content, true);
  5849. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  5850. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  5851. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  5852. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  5853. }
  5854. /**
  5855. * @runInSeparateProcess
  5856. */
  5857. public function testRead72()
  5858. {
  5859. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5860. $this->_model->create(self::$pasteid, self::$paste);
  5861. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5862. ob_start();
  5863. new zerobin;
  5864. $content = ob_get_contents();
  5865. $this->assertTag(
  5866. array(
  5867. 'id' => 'cipherdata',
  5868. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5869. ),
  5870. $content,
  5871. 'outputs data correctly'
  5872. );
  5873. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5874. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5875. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5876. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5877. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5878. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5879. }
  5880. /**
  5881. * @runInSeparateProcess
  5882. */
  5883. public function testDelete72()
  5884. {
  5885. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5886. $this->_model->create(self::$pasteid, self::$paste);
  5887. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5888. $_GET['pasteid'] = self::$pasteid;
  5889. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5890. ob_start();
  5891. new zerobin;
  5892. $content = ob_get_contents();
  5893. $this->assertTag(
  5894. array(
  5895. 'id' => 'status',
  5896. 'content' => 'Paste was properly deleted'
  5897. ),
  5898. $content,
  5899. 'outputs deleted status correctly'
  5900. );
  5901. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5902. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5903. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5904. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5905. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5906. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5907. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5908. }
  5909. /**
  5910. * @runInSeparateProcess
  5911. */
  5912. public function testView73()
  5913. {
  5914. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5915. ob_start();
  5916. new zerobin;
  5917. $content = ob_get_contents();
  5918. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5919. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5920. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5921. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5922. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5923. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5924. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5925. }
  5926. /**
  5927. * @runInSeparateProcess
  5928. */
  5929. public function testRead73()
  5930. {
  5931. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5932. $this->_model->create(self::$pasteid, self::$paste);
  5933. $_SERVER['QUERY_STRING'] = self::$pasteid;
  5934. ob_start();
  5935. new zerobin;
  5936. $content = ob_get_contents();
  5937. $this->assertTag(
  5938. array(
  5939. 'id' => 'cipherdata',
  5940. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  5941. ),
  5942. $content,
  5943. 'outputs data correctly'
  5944. );
  5945. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5946. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5947. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5948. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5949. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5950. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5951. }
  5952. /**
  5953. * @runInSeparateProcess
  5954. */
  5955. public function testDelete73()
  5956. {
  5957. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5958. $this->_model->create(self::$pasteid, self::$paste);
  5959. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  5960. $_GET['pasteid'] = self::$pasteid;
  5961. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  5962. ob_start();
  5963. new zerobin;
  5964. $content = ob_get_contents();
  5965. $this->assertTag(
  5966. array(
  5967. 'id' => 'status',
  5968. 'content' => 'Paste was properly deleted'
  5969. ),
  5970. $content,
  5971. 'outputs deleted status correctly'
  5972. );
  5973. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  5974. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  5975. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5976. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5977. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5978. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5979. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5980. }
  5981. /**
  5982. * @runInSeparateProcess
  5983. */
  5984. public function testView74()
  5985. {
  5986. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  5987. ob_start();
  5988. new zerobin;
  5989. $content = ob_get_contents();
  5990. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  5991. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  5992. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  5993. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  5994. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  5995. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  5996. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  5997. }
  5998. /**
  5999. * @runInSeparateProcess
  6000. */
  6001. public function testCreate74()
  6002. {
  6003. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6004. $_POST = self::$paste;
  6005. $_SERVER['REMOTE_ADDR'] = '::1';
  6006. ob_start();
  6007. new zerobin;
  6008. $content = ob_get_contents();
  6009. $response = json_decode($content, true);
  6010. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6011. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6012. }
  6013. /**
  6014. * @runInSeparateProcess
  6015. */
  6016. public function testRead74()
  6017. {
  6018. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6019. $this->_model->create(self::$pasteid, self::$paste);
  6020. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6021. ob_start();
  6022. new zerobin;
  6023. $content = ob_get_contents();
  6024. $this->assertTag(
  6025. array(
  6026. 'id' => 'cipherdata',
  6027. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6028. ),
  6029. $content,
  6030. 'outputs data correctly'
  6031. );
  6032. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6033. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6034. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6035. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6036. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6037. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6038. }
  6039. /**
  6040. * @runInSeparateProcess
  6041. */
  6042. public function testDelete74()
  6043. {
  6044. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6045. $this->_model->create(self::$pasteid, self::$paste);
  6046. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6047. $_GET['pasteid'] = self::$pasteid;
  6048. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6049. ob_start();
  6050. new zerobin;
  6051. $content = ob_get_contents();
  6052. $this->assertTag(
  6053. array(
  6054. 'id' => 'status',
  6055. 'content' => 'Paste was properly deleted'
  6056. ),
  6057. $content,
  6058. 'outputs deleted status correctly'
  6059. );
  6060. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6061. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6062. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6063. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6064. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6065. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6066. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6067. }
  6068. /**
  6069. * @runInSeparateProcess
  6070. */
  6071. public function testView75()
  6072. {
  6073. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6074. ob_start();
  6075. new zerobin;
  6076. $content = ob_get_contents();
  6077. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6078. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6079. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6080. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6081. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  6082. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6083. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6084. }
  6085. /**
  6086. * @runInSeparateProcess
  6087. */
  6088. public function testRead75()
  6089. {
  6090. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6091. $this->_model->create(self::$pasteid, self::$paste);
  6092. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6093. ob_start();
  6094. new zerobin;
  6095. $content = ob_get_contents();
  6096. $this->assertTag(
  6097. array(
  6098. 'id' => 'cipherdata',
  6099. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6100. ),
  6101. $content,
  6102. 'outputs data correctly'
  6103. );
  6104. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6105. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6106. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6107. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6108. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6109. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6110. }
  6111. /**
  6112. * @runInSeparateProcess
  6113. */
  6114. public function testDelete75()
  6115. {
  6116. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6117. $this->_model->create(self::$pasteid, self::$paste);
  6118. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6119. $_GET['pasteid'] = self::$pasteid;
  6120. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6121. ob_start();
  6122. new zerobin;
  6123. $content = ob_get_contents();
  6124. $this->assertTag(
  6125. array(
  6126. 'id' => 'status',
  6127. 'content' => 'Paste was properly deleted'
  6128. ),
  6129. $content,
  6130. 'outputs deleted status correctly'
  6131. );
  6132. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6133. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6134. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6135. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6136. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6137. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6138. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6139. }
  6140. /**
  6141. * @runInSeparateProcess
  6142. */
  6143. public function testView76()
  6144. {
  6145. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6146. ob_start();
  6147. new zerobin;
  6148. $content = ob_get_contents();
  6149. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6150. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6151. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6152. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6153. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  6154. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6155. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6156. }
  6157. /**
  6158. * @runInSeparateProcess
  6159. */
  6160. public function testCreate76()
  6161. {
  6162. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6163. $_POST = self::$paste;
  6164. $_SERVER['REMOTE_ADDR'] = '::1';
  6165. $_POST["opendiscussion"] = "neither 1 nor 0";
  6166. ob_start();
  6167. new zerobin;
  6168. $content = ob_get_contents();
  6169. $response = json_decode($content, true);
  6170. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  6171. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  6172. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6173. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6174. }
  6175. /**
  6176. * @runInSeparateProcess
  6177. */
  6178. public function testRead76()
  6179. {
  6180. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6181. $this->_model->create(self::$pasteid, self::$paste);
  6182. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6183. ob_start();
  6184. new zerobin;
  6185. $content = ob_get_contents();
  6186. $this->assertTag(
  6187. array(
  6188. 'id' => 'cipherdata',
  6189. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6190. ),
  6191. $content,
  6192. 'outputs data correctly'
  6193. );
  6194. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6195. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6196. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6197. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6198. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6199. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6200. }
  6201. /**
  6202. * @runInSeparateProcess
  6203. */
  6204. public function testDelete76()
  6205. {
  6206. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6207. $this->_model->create(self::$pasteid, self::$paste);
  6208. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6209. $_GET['pasteid'] = self::$pasteid;
  6210. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6211. ob_start();
  6212. new zerobin;
  6213. $content = ob_get_contents();
  6214. $this->assertTag(
  6215. array(
  6216. 'id' => 'status',
  6217. 'content' => 'Paste was properly deleted'
  6218. ),
  6219. $content,
  6220. 'outputs deleted status correctly'
  6221. );
  6222. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6223. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6224. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6225. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6226. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6227. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6228. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6229. }
  6230. /**
  6231. * @runInSeparateProcess
  6232. */
  6233. public function testView77()
  6234. {
  6235. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6236. ob_start();
  6237. new zerobin;
  6238. $content = ob_get_contents();
  6239. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6240. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6241. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6242. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6243. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  6244. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6245. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6246. }
  6247. /**
  6248. * @runInSeparateProcess
  6249. */
  6250. public function testRead77()
  6251. {
  6252. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6253. $this->_model->create(self::$pasteid, self::$paste);
  6254. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6255. ob_start();
  6256. new zerobin;
  6257. $content = ob_get_contents();
  6258. $this->assertTag(
  6259. array(
  6260. 'id' => 'cipherdata',
  6261. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6262. ),
  6263. $content,
  6264. 'outputs data correctly'
  6265. );
  6266. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6267. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6268. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6269. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6270. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6271. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6272. }
  6273. /**
  6274. * @runInSeparateProcess
  6275. */
  6276. public function testDelete77()
  6277. {
  6278. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6279. $this->_model->create(self::$pasteid, self::$paste);
  6280. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6281. $_GET['pasteid'] = self::$pasteid;
  6282. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6283. ob_start();
  6284. new zerobin;
  6285. $content = ob_get_contents();
  6286. $this->assertTag(
  6287. array(
  6288. 'id' => 'status',
  6289. 'content' => 'Paste was properly deleted'
  6290. ),
  6291. $content,
  6292. 'outputs deleted status correctly'
  6293. );
  6294. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6295. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6296. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6297. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6298. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6299. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6300. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6301. }
  6302. /**
  6303. * @runInSeparateProcess
  6304. */
  6305. public function testView78()
  6306. {
  6307. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6308. ob_start();
  6309. new zerobin;
  6310. $content = ob_get_contents();
  6311. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6312. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6313. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6314. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6315. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  6316. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6317. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6318. }
  6319. /**
  6320. * @runInSeparateProcess
  6321. */
  6322. public function testCreate78()
  6323. {
  6324. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6325. $_POST = self::$paste;
  6326. $_SERVER['REMOTE_ADDR'] = '::1';
  6327. ob_start();
  6328. new zerobin;
  6329. $content = ob_get_contents();
  6330. $response = json_decode($content, true);
  6331. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6332. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6333. }
  6334. /**
  6335. * @runInSeparateProcess
  6336. */
  6337. public function testRead78()
  6338. {
  6339. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6340. $this->_model->create(self::$pasteid, self::$paste);
  6341. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6342. ob_start();
  6343. new zerobin;
  6344. $content = ob_get_contents();
  6345. $this->assertTag(
  6346. array(
  6347. 'id' => 'cipherdata',
  6348. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6349. ),
  6350. $content,
  6351. 'outputs data correctly'
  6352. );
  6353. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6354. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6355. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6356. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6357. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6358. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6359. }
  6360. /**
  6361. * @runInSeparateProcess
  6362. */
  6363. public function testDelete78()
  6364. {
  6365. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6366. $this->_model->create(self::$pasteid, self::$paste);
  6367. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6368. $_GET['pasteid'] = self::$pasteid;
  6369. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6370. ob_start();
  6371. new zerobin;
  6372. $content = ob_get_contents();
  6373. $this->assertTag(
  6374. array(
  6375. 'id' => 'status',
  6376. 'content' => 'Paste was properly deleted'
  6377. ),
  6378. $content,
  6379. 'outputs deleted status correctly'
  6380. );
  6381. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6382. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6383. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6384. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6385. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6386. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6387. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6388. }
  6389. /**
  6390. * @runInSeparateProcess
  6391. */
  6392. public function testView79()
  6393. {
  6394. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6395. ob_start();
  6396. new zerobin;
  6397. $content = ob_get_contents();
  6398. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6399. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6400. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6401. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6402. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  6403. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6404. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6405. }
  6406. /**
  6407. * @runInSeparateProcess
  6408. */
  6409. public function testRead79()
  6410. {
  6411. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6412. $this->_model->create(self::$pasteid, self::$paste);
  6413. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6414. ob_start();
  6415. new zerobin;
  6416. $content = ob_get_contents();
  6417. $this->assertTag(
  6418. array(
  6419. 'id' => 'cipherdata',
  6420. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6421. ),
  6422. $content,
  6423. 'outputs data correctly'
  6424. );
  6425. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6426. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6427. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6428. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6429. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6430. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6431. }
  6432. /**
  6433. * @runInSeparateProcess
  6434. */
  6435. public function testDelete79()
  6436. {
  6437. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6438. $this->_model->create(self::$pasteid, self::$paste);
  6439. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6440. $_GET['pasteid'] = self::$pasteid;
  6441. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6442. ob_start();
  6443. new zerobin;
  6444. $content = ob_get_contents();
  6445. $this->assertTag(
  6446. array(
  6447. 'id' => 'status',
  6448. 'content' => 'Paste was properly deleted'
  6449. ),
  6450. $content,
  6451. 'outputs deleted status correctly'
  6452. );
  6453. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6454. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6455. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6456. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6457. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6458. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6459. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6460. }
  6461. /**
  6462. * @runInSeparateProcess
  6463. */
  6464. public function testView80()
  6465. {
  6466. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6467. ob_start();
  6468. new zerobin;
  6469. $content = ob_get_contents();
  6470. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6471. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6472. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6473. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6474. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6475. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6476. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6477. }
  6478. /**
  6479. * @runInSeparateProcess
  6480. */
  6481. public function testCreate80()
  6482. {
  6483. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6484. $_POST = self::$paste;
  6485. $_SERVER['REMOTE_ADDR'] = '::1';
  6486. $_POST["opendiscussion"] = "neither 1 nor 0";
  6487. ob_start();
  6488. new zerobin;
  6489. $content = ob_get_contents();
  6490. $response = json_decode($content, true);
  6491. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  6492. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  6493. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6494. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6495. }
  6496. /**
  6497. * @runInSeparateProcess
  6498. */
  6499. public function testRead80()
  6500. {
  6501. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6502. $this->_model->create(self::$pasteid, self::$paste);
  6503. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6504. ob_start();
  6505. new zerobin;
  6506. $content = ob_get_contents();
  6507. $this->assertTag(
  6508. array(
  6509. 'id' => 'cipherdata',
  6510. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6511. ),
  6512. $content,
  6513. 'outputs data correctly'
  6514. );
  6515. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6516. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6517. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6518. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6519. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6520. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6521. }
  6522. /**
  6523. * @runInSeparateProcess
  6524. */
  6525. public function testDelete80()
  6526. {
  6527. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6528. $this->_model->create(self::$pasteid, self::$paste);
  6529. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6530. $_GET['pasteid'] = self::$pasteid;
  6531. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6532. ob_start();
  6533. new zerobin;
  6534. $content = ob_get_contents();
  6535. $this->assertTag(
  6536. array(
  6537. 'id' => 'status',
  6538. 'content' => 'Paste was properly deleted'
  6539. ),
  6540. $content,
  6541. 'outputs deleted status correctly'
  6542. );
  6543. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6544. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6545. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6546. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6547. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6548. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6549. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6550. }
  6551. /**
  6552. * @runInSeparateProcess
  6553. */
  6554. public function testView81()
  6555. {
  6556. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6557. ob_start();
  6558. new zerobin;
  6559. $content = ob_get_contents();
  6560. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6561. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6562. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6563. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6564. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6565. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6566. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6567. }
  6568. /**
  6569. * @runInSeparateProcess
  6570. */
  6571. public function testRead81()
  6572. {
  6573. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6574. $this->_model->create(self::$pasteid, self::$paste);
  6575. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6576. ob_start();
  6577. new zerobin;
  6578. $content = ob_get_contents();
  6579. $this->assertTag(
  6580. array(
  6581. 'id' => 'cipherdata',
  6582. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6583. ),
  6584. $content,
  6585. 'outputs data correctly'
  6586. );
  6587. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6588. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6589. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6590. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6591. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6592. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6593. }
  6594. /**
  6595. * @runInSeparateProcess
  6596. */
  6597. public function testDelete81()
  6598. {
  6599. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6600. $this->_model->create(self::$pasteid, self::$paste);
  6601. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6602. $_GET['pasteid'] = self::$pasteid;
  6603. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6604. ob_start();
  6605. new zerobin;
  6606. $content = ob_get_contents();
  6607. $this->assertTag(
  6608. array(
  6609. 'id' => 'status',
  6610. 'content' => 'Paste was properly deleted'
  6611. ),
  6612. $content,
  6613. 'outputs deleted status correctly'
  6614. );
  6615. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6616. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6617. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6618. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6619. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6620. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6621. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6622. }
  6623. /**
  6624. * @runInSeparateProcess
  6625. */
  6626. public function testView82()
  6627. {
  6628. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6629. ob_start();
  6630. new zerobin;
  6631. $content = ob_get_contents();
  6632. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6633. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6634. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6635. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6636. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6637. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6638. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6639. }
  6640. /**
  6641. * @runInSeparateProcess
  6642. */
  6643. public function testCreate82()
  6644. {
  6645. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6646. $_POST = self::$paste;
  6647. $_SERVER['REMOTE_ADDR'] = '::1';
  6648. ob_start();
  6649. new zerobin;
  6650. $content = ob_get_contents();
  6651. $response = json_decode($content, true);
  6652. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6653. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6654. }
  6655. /**
  6656. * @runInSeparateProcess
  6657. */
  6658. public function testRead82()
  6659. {
  6660. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6661. $this->_model->create(self::$pasteid, self::$paste);
  6662. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6663. ob_start();
  6664. new zerobin;
  6665. $content = ob_get_contents();
  6666. $this->assertTag(
  6667. array(
  6668. 'id' => 'cipherdata',
  6669. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6670. ),
  6671. $content,
  6672. 'outputs data correctly'
  6673. );
  6674. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6675. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6676. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6677. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6678. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6679. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6680. }
  6681. /**
  6682. * @runInSeparateProcess
  6683. */
  6684. public function testDelete82()
  6685. {
  6686. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6687. $this->_model->create(self::$pasteid, self::$paste);
  6688. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6689. $_GET['pasteid'] = self::$pasteid;
  6690. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6691. ob_start();
  6692. new zerobin;
  6693. $content = ob_get_contents();
  6694. $this->assertTag(
  6695. array(
  6696. 'id' => 'status',
  6697. 'content' => 'Paste was properly deleted'
  6698. ),
  6699. $content,
  6700. 'outputs deleted status correctly'
  6701. );
  6702. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6703. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6704. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6705. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6706. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6707. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6708. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6709. }
  6710. /**
  6711. * @runInSeparateProcess
  6712. */
  6713. public function testView83()
  6714. {
  6715. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6716. ob_start();
  6717. new zerobin;
  6718. $content = ob_get_contents();
  6719. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6720. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6721. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6722. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6723. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6724. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6725. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6726. }
  6727. /**
  6728. * @runInSeparateProcess
  6729. */
  6730. public function testRead83()
  6731. {
  6732. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6733. $this->_model->create(self::$pasteid, self::$paste);
  6734. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6735. ob_start();
  6736. new zerobin;
  6737. $content = ob_get_contents();
  6738. $this->assertTag(
  6739. array(
  6740. 'id' => 'cipherdata',
  6741. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6742. ),
  6743. $content,
  6744. 'outputs data correctly'
  6745. );
  6746. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6747. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6748. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6749. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6750. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6751. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6752. }
  6753. /**
  6754. * @runInSeparateProcess
  6755. */
  6756. public function testDelete83()
  6757. {
  6758. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6759. $this->_model->create(self::$pasteid, self::$paste);
  6760. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6761. $_GET['pasteid'] = self::$pasteid;
  6762. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6763. ob_start();
  6764. new zerobin;
  6765. $content = ob_get_contents();
  6766. $this->assertTag(
  6767. array(
  6768. 'id' => 'status',
  6769. 'content' => 'Paste was properly deleted'
  6770. ),
  6771. $content,
  6772. 'outputs deleted status correctly'
  6773. );
  6774. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6775. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6776. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  6777. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  6778. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  6779. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6780. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6781. }
  6782. /**
  6783. * @runInSeparateProcess
  6784. */
  6785. public function testView84()
  6786. {
  6787. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6788. ob_start();
  6789. new zerobin;
  6790. $content = ob_get_contents();
  6791. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6792. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6793. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6794. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6795. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6796. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6797. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6798. }
  6799. /**
  6800. * @runInSeparateProcess
  6801. */
  6802. public function testCreate84()
  6803. {
  6804. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6805. $_POST = self::$paste;
  6806. $_SERVER['REMOTE_ADDR'] = '::1';
  6807. $_POST["opendiscussion"] = "neither 1 nor 0";
  6808. ob_start();
  6809. new zerobin;
  6810. $content = ob_get_contents();
  6811. $response = json_decode($content, true);
  6812. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  6813. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  6814. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6815. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6816. }
  6817. /**
  6818. * @runInSeparateProcess
  6819. */
  6820. public function testRead84()
  6821. {
  6822. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6823. $this->_model->create(self::$pasteid, self::$paste);
  6824. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6825. ob_start();
  6826. new zerobin;
  6827. $content = ob_get_contents();
  6828. $this->assertTag(
  6829. array(
  6830. 'id' => 'cipherdata',
  6831. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6832. ),
  6833. $content,
  6834. 'outputs data correctly'
  6835. );
  6836. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6837. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6838. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6839. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6840. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6841. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6842. }
  6843. /**
  6844. * @runInSeparateProcess
  6845. */
  6846. public function testDelete84()
  6847. {
  6848. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6849. $this->_model->create(self::$pasteid, self::$paste);
  6850. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6851. $_GET['pasteid'] = self::$pasteid;
  6852. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6853. ob_start();
  6854. new zerobin;
  6855. $content = ob_get_contents();
  6856. $this->assertTag(
  6857. array(
  6858. 'id' => 'status',
  6859. 'content' => 'Paste was properly deleted'
  6860. ),
  6861. $content,
  6862. 'outputs deleted status correctly'
  6863. );
  6864. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6865. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6866. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6867. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6868. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6869. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6870. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6871. }
  6872. /**
  6873. * @runInSeparateProcess
  6874. */
  6875. public function testView85()
  6876. {
  6877. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6878. ob_start();
  6879. new zerobin;
  6880. $content = ob_get_contents();
  6881. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6882. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6883. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6884. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6885. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6886. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6887. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6888. }
  6889. /**
  6890. * @runInSeparateProcess
  6891. */
  6892. public function testRead85()
  6893. {
  6894. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6895. $this->_model->create(self::$pasteid, self::$paste);
  6896. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6897. ob_start();
  6898. new zerobin;
  6899. $content = ob_get_contents();
  6900. $this->assertTag(
  6901. array(
  6902. 'id' => 'cipherdata',
  6903. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6904. ),
  6905. $content,
  6906. 'outputs data correctly'
  6907. );
  6908. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6909. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6910. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6911. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6912. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6913. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6914. }
  6915. /**
  6916. * @runInSeparateProcess
  6917. */
  6918. public function testDelete85()
  6919. {
  6920. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6921. $this->_model->create(self::$pasteid, self::$paste);
  6922. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  6923. $_GET['pasteid'] = self::$pasteid;
  6924. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  6925. ob_start();
  6926. new zerobin;
  6927. $content = ob_get_contents();
  6928. $this->assertTag(
  6929. array(
  6930. 'id' => 'status',
  6931. 'content' => 'Paste was properly deleted'
  6932. ),
  6933. $content,
  6934. 'outputs deleted status correctly'
  6935. );
  6936. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  6937. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  6938. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6939. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6940. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6941. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6942. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6943. }
  6944. /**
  6945. * @runInSeparateProcess
  6946. */
  6947. public function testView86()
  6948. {
  6949. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6950. ob_start();
  6951. new zerobin;
  6952. $content = ob_get_contents();
  6953. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6954. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6955. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6956. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6957. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  6958. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  6959. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  6960. }
  6961. /**
  6962. * @runInSeparateProcess
  6963. */
  6964. public function testCreate86()
  6965. {
  6966. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6967. $_POST = self::$paste;
  6968. $_SERVER['REMOTE_ADDR'] = '::1';
  6969. ob_start();
  6970. new zerobin;
  6971. $content = ob_get_contents();
  6972. $response = json_decode($content, true);
  6973. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  6974. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  6975. }
  6976. /**
  6977. * @runInSeparateProcess
  6978. */
  6979. public function testRead86()
  6980. {
  6981. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  6982. $this->_model->create(self::$pasteid, self::$paste);
  6983. $_SERVER['QUERY_STRING'] = self::$pasteid;
  6984. ob_start();
  6985. new zerobin;
  6986. $content = ob_get_contents();
  6987. $this->assertTag(
  6988. array(
  6989. 'id' => 'cipherdata',
  6990. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  6991. ),
  6992. $content,
  6993. 'outputs data correctly'
  6994. );
  6995. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  6996. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  6997. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  6998. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  6999. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7000. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7001. }
  7002. /**
  7003. * @runInSeparateProcess
  7004. */
  7005. public function testDelete86()
  7006. {
  7007. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7008. $this->_model->create(self::$pasteid, self::$paste);
  7009. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7010. $_GET['pasteid'] = self::$pasteid;
  7011. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7012. ob_start();
  7013. new zerobin;
  7014. $content = ob_get_contents();
  7015. $this->assertTag(
  7016. array(
  7017. 'id' => 'status',
  7018. 'content' => 'Paste was properly deleted'
  7019. ),
  7020. $content,
  7021. 'outputs deleted status correctly'
  7022. );
  7023. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7024. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7025. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7026. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7027. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7028. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7029. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7030. }
  7031. /**
  7032. * @runInSeparateProcess
  7033. */
  7034. public function testView87()
  7035. {
  7036. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7037. ob_start();
  7038. new zerobin;
  7039. $content = ob_get_contents();
  7040. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7041. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7042. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7043. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7044. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7045. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7046. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7047. }
  7048. /**
  7049. * @runInSeparateProcess
  7050. */
  7051. public function testRead87()
  7052. {
  7053. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7054. $this->_model->create(self::$pasteid, self::$paste);
  7055. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7056. ob_start();
  7057. new zerobin;
  7058. $content = ob_get_contents();
  7059. $this->assertTag(
  7060. array(
  7061. 'id' => 'cipherdata',
  7062. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7063. ),
  7064. $content,
  7065. 'outputs data correctly'
  7066. );
  7067. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7068. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7069. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7070. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7071. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7072. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7073. }
  7074. /**
  7075. * @runInSeparateProcess
  7076. */
  7077. public function testDelete87()
  7078. {
  7079. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7080. $this->_model->create(self::$pasteid, self::$paste);
  7081. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7082. $_GET['pasteid'] = self::$pasteid;
  7083. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7084. ob_start();
  7085. new zerobin;
  7086. $content = ob_get_contents();
  7087. $this->assertTag(
  7088. array(
  7089. 'id' => 'status',
  7090. 'content' => 'Paste was properly deleted'
  7091. ),
  7092. $content,
  7093. 'outputs deleted status correctly'
  7094. );
  7095. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7096. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7097. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7098. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7099. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7100. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7101. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7102. }
  7103. /**
  7104. * @runInSeparateProcess
  7105. */
  7106. public function testView88()
  7107. {
  7108. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7109. ob_start();
  7110. new zerobin;
  7111. $content = ob_get_contents();
  7112. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7113. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7114. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7115. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7116. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7117. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7118. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7119. }
  7120. /**
  7121. * @runInSeparateProcess
  7122. */
  7123. public function testCreate88()
  7124. {
  7125. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7126. $_POST = self::$paste;
  7127. $_SERVER['REMOTE_ADDR'] = '::1';
  7128. $_POST["opendiscussion"] = "neither 1 nor 0";
  7129. ob_start();
  7130. new zerobin;
  7131. $content = ob_get_contents();
  7132. $response = json_decode($content, true);
  7133. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  7134. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  7135. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7136. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7137. }
  7138. /**
  7139. * @runInSeparateProcess
  7140. */
  7141. public function testRead88()
  7142. {
  7143. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7144. $this->_model->create(self::$pasteid, self::$paste);
  7145. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7146. ob_start();
  7147. new zerobin;
  7148. $content = ob_get_contents();
  7149. $this->assertTag(
  7150. array(
  7151. 'id' => 'cipherdata',
  7152. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7153. ),
  7154. $content,
  7155. 'outputs data correctly'
  7156. );
  7157. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7158. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7159. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7160. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7161. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7162. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7163. }
  7164. /**
  7165. * @runInSeparateProcess
  7166. */
  7167. public function testDelete88()
  7168. {
  7169. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7170. $this->_model->create(self::$pasteid, self::$paste);
  7171. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7172. $_GET['pasteid'] = self::$pasteid;
  7173. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7174. ob_start();
  7175. new zerobin;
  7176. $content = ob_get_contents();
  7177. $this->assertTag(
  7178. array(
  7179. 'id' => 'status',
  7180. 'content' => 'Paste was properly deleted'
  7181. ),
  7182. $content,
  7183. 'outputs deleted status correctly'
  7184. );
  7185. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7186. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7187. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7188. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7189. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7190. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7191. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7192. }
  7193. /**
  7194. * @runInSeparateProcess
  7195. */
  7196. public function testView89()
  7197. {
  7198. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7199. ob_start();
  7200. new zerobin;
  7201. $content = ob_get_contents();
  7202. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7203. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7204. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7205. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7206. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7207. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7208. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7209. }
  7210. /**
  7211. * @runInSeparateProcess
  7212. */
  7213. public function testRead89()
  7214. {
  7215. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7216. $this->_model->create(self::$pasteid, self::$paste);
  7217. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7218. ob_start();
  7219. new zerobin;
  7220. $content = ob_get_contents();
  7221. $this->assertTag(
  7222. array(
  7223. 'id' => 'cipherdata',
  7224. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7225. ),
  7226. $content,
  7227. 'outputs data correctly'
  7228. );
  7229. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7230. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7231. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7232. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7233. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7234. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7235. }
  7236. /**
  7237. * @runInSeparateProcess
  7238. */
  7239. public function testDelete89()
  7240. {
  7241. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7242. $this->_model->create(self::$pasteid, self::$paste);
  7243. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7244. $_GET['pasteid'] = self::$pasteid;
  7245. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7246. ob_start();
  7247. new zerobin;
  7248. $content = ob_get_contents();
  7249. $this->assertTag(
  7250. array(
  7251. 'id' => 'status',
  7252. 'content' => 'Paste was properly deleted'
  7253. ),
  7254. $content,
  7255. 'outputs deleted status correctly'
  7256. );
  7257. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7258. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7259. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7260. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7261. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7262. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7263. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7264. }
  7265. /**
  7266. * @runInSeparateProcess
  7267. */
  7268. public function testView90()
  7269. {
  7270. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7271. ob_start();
  7272. new zerobin;
  7273. $content = ob_get_contents();
  7274. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7275. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7276. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7277. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7278. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7279. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7280. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7281. }
  7282. /**
  7283. * @runInSeparateProcess
  7284. */
  7285. public function testCreate90()
  7286. {
  7287. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7288. $_POST = self::$paste;
  7289. $_SERVER['REMOTE_ADDR'] = '::1';
  7290. ob_start();
  7291. new zerobin;
  7292. $content = ob_get_contents();
  7293. $response = json_decode($content, true);
  7294. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7295. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7296. }
  7297. /**
  7298. * @runInSeparateProcess
  7299. */
  7300. public function testRead90()
  7301. {
  7302. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7303. $this->_model->create(self::$pasteid, self::$paste);
  7304. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7305. ob_start();
  7306. new zerobin;
  7307. $content = ob_get_contents();
  7308. $this->assertTag(
  7309. array(
  7310. 'id' => 'cipherdata',
  7311. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7312. ),
  7313. $content,
  7314. 'outputs data correctly'
  7315. );
  7316. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7317. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7318. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7319. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7320. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7321. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7322. }
  7323. /**
  7324. * @runInSeparateProcess
  7325. */
  7326. public function testDelete90()
  7327. {
  7328. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7329. $this->_model->create(self::$pasteid, self::$paste);
  7330. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7331. $_GET['pasteid'] = self::$pasteid;
  7332. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7333. ob_start();
  7334. new zerobin;
  7335. $content = ob_get_contents();
  7336. $this->assertTag(
  7337. array(
  7338. 'id' => 'status',
  7339. 'content' => 'Paste was properly deleted'
  7340. ),
  7341. $content,
  7342. 'outputs deleted status correctly'
  7343. );
  7344. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7345. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7346. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7347. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7348. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7349. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7350. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7351. }
  7352. /**
  7353. * @runInSeparateProcess
  7354. */
  7355. public function testView91()
  7356. {
  7357. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7358. ob_start();
  7359. new zerobin;
  7360. $content = ob_get_contents();
  7361. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7362. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7363. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7364. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7365. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7366. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7367. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7368. }
  7369. /**
  7370. * @runInSeparateProcess
  7371. */
  7372. public function testRead91()
  7373. {
  7374. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7375. $this->_model->create(self::$pasteid, self::$paste);
  7376. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7377. ob_start();
  7378. new zerobin;
  7379. $content = ob_get_contents();
  7380. $this->assertTag(
  7381. array(
  7382. 'id' => 'cipherdata',
  7383. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7384. ),
  7385. $content,
  7386. 'outputs data correctly'
  7387. );
  7388. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7389. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7390. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7391. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7392. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7393. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7394. }
  7395. /**
  7396. * @runInSeparateProcess
  7397. */
  7398. public function testDelete91()
  7399. {
  7400. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7401. $this->_model->create(self::$pasteid, self::$paste);
  7402. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7403. $_GET['pasteid'] = self::$pasteid;
  7404. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7405. ob_start();
  7406. new zerobin;
  7407. $content = ob_get_contents();
  7408. $this->assertTag(
  7409. array(
  7410. 'id' => 'status',
  7411. 'content' => 'Paste was properly deleted'
  7412. ),
  7413. $content,
  7414. 'outputs deleted status correctly'
  7415. );
  7416. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7417. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7418. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7419. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7420. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7421. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7422. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7423. }
  7424. /**
  7425. * @runInSeparateProcess
  7426. */
  7427. public function testView92()
  7428. {
  7429. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7430. ob_start();
  7431. new zerobin;
  7432. $content = ob_get_contents();
  7433. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7434. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7435. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7436. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7437. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7438. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7439. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7440. }
  7441. /**
  7442. * @runInSeparateProcess
  7443. */
  7444. public function testCreate92()
  7445. {
  7446. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7447. $_POST = self::$paste;
  7448. $_SERVER['REMOTE_ADDR'] = '::1';
  7449. $_POST["opendiscussion"] = "neither 1 nor 0";
  7450. ob_start();
  7451. new zerobin;
  7452. $content = ob_get_contents();
  7453. $response = json_decode($content, true);
  7454. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  7455. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  7456. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7457. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7458. }
  7459. /**
  7460. * @runInSeparateProcess
  7461. */
  7462. public function testRead92()
  7463. {
  7464. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7465. $this->_model->create(self::$pasteid, self::$paste);
  7466. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7467. ob_start();
  7468. new zerobin;
  7469. $content = ob_get_contents();
  7470. $this->assertTag(
  7471. array(
  7472. 'id' => 'cipherdata',
  7473. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7474. ),
  7475. $content,
  7476. 'outputs data correctly'
  7477. );
  7478. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7479. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7480. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7481. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7482. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7483. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7484. }
  7485. /**
  7486. * @runInSeparateProcess
  7487. */
  7488. public function testDelete92()
  7489. {
  7490. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7491. $this->_model->create(self::$pasteid, self::$paste);
  7492. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7493. $_GET['pasteid'] = self::$pasteid;
  7494. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7495. ob_start();
  7496. new zerobin;
  7497. $content = ob_get_contents();
  7498. $this->assertTag(
  7499. array(
  7500. 'id' => 'status',
  7501. 'content' => 'Paste was properly deleted'
  7502. ),
  7503. $content,
  7504. 'outputs deleted status correctly'
  7505. );
  7506. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7507. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7508. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7509. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7510. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7511. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7512. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7513. }
  7514. /**
  7515. * @runInSeparateProcess
  7516. */
  7517. public function testView93()
  7518. {
  7519. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7520. ob_start();
  7521. new zerobin;
  7522. $content = ob_get_contents();
  7523. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7524. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7525. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7526. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7527. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7528. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7529. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7530. }
  7531. /**
  7532. * @runInSeparateProcess
  7533. */
  7534. public function testRead93()
  7535. {
  7536. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7537. $this->_model->create(self::$pasteid, self::$paste);
  7538. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7539. ob_start();
  7540. new zerobin;
  7541. $content = ob_get_contents();
  7542. $this->assertTag(
  7543. array(
  7544. 'id' => 'cipherdata',
  7545. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7546. ),
  7547. $content,
  7548. 'outputs data correctly'
  7549. );
  7550. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7551. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7552. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7553. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7554. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7555. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7556. }
  7557. /**
  7558. * @runInSeparateProcess
  7559. */
  7560. public function testDelete93()
  7561. {
  7562. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7563. $this->_model->create(self::$pasteid, self::$paste);
  7564. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7565. $_GET['pasteid'] = self::$pasteid;
  7566. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7567. ob_start();
  7568. new zerobin;
  7569. $content = ob_get_contents();
  7570. $this->assertTag(
  7571. array(
  7572. 'id' => 'status',
  7573. 'content' => 'Paste was properly deleted'
  7574. ),
  7575. $content,
  7576. 'outputs deleted status correctly'
  7577. );
  7578. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7579. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7580. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7581. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7583. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7584. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7585. }
  7586. /**
  7587. * @runInSeparateProcess
  7588. */
  7589. public function testView94()
  7590. {
  7591. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7592. ob_start();
  7593. new zerobin;
  7594. $content = ob_get_contents();
  7595. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7596. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7597. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7598. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7599. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7600. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7601. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7602. }
  7603. /**
  7604. * @runInSeparateProcess
  7605. */
  7606. public function testCreate94()
  7607. {
  7608. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7609. $_POST = self::$paste;
  7610. $_SERVER['REMOTE_ADDR'] = '::1';
  7611. ob_start();
  7612. new zerobin;
  7613. $content = ob_get_contents();
  7614. $response = json_decode($content, true);
  7615. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7616. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7617. }
  7618. /**
  7619. * @runInSeparateProcess
  7620. */
  7621. public function testRead94()
  7622. {
  7623. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7624. $this->_model->create(self::$pasteid, self::$paste);
  7625. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7626. ob_start();
  7627. new zerobin;
  7628. $content = ob_get_contents();
  7629. $this->assertTag(
  7630. array(
  7631. 'id' => 'cipherdata',
  7632. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7633. ),
  7634. $content,
  7635. 'outputs data correctly'
  7636. );
  7637. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7638. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7639. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7640. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7641. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7642. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7643. }
  7644. /**
  7645. * @runInSeparateProcess
  7646. */
  7647. public function testDelete94()
  7648. {
  7649. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7650. $this->_model->create(self::$pasteid, self::$paste);
  7651. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7652. $_GET['pasteid'] = self::$pasteid;
  7653. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7654. ob_start();
  7655. new zerobin;
  7656. $content = ob_get_contents();
  7657. $this->assertTag(
  7658. array(
  7659. 'id' => 'status',
  7660. 'content' => 'Paste was properly deleted'
  7661. ),
  7662. $content,
  7663. 'outputs deleted status correctly'
  7664. );
  7665. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7666. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7667. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7668. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7669. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7670. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7671. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7672. }
  7673. /**
  7674. * @runInSeparateProcess
  7675. */
  7676. public function testView95()
  7677. {
  7678. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7679. ob_start();
  7680. new zerobin;
  7681. $content = ob_get_contents();
  7682. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7683. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7684. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7685. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7686. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  7687. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7688. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7689. }
  7690. /**
  7691. * @runInSeparateProcess
  7692. */
  7693. public function testRead95()
  7694. {
  7695. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7696. $this->_model->create(self::$pasteid, self::$paste);
  7697. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7698. ob_start();
  7699. new zerobin;
  7700. $content = ob_get_contents();
  7701. $this->assertTag(
  7702. array(
  7703. 'id' => 'cipherdata',
  7704. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7705. ),
  7706. $content,
  7707. 'outputs data correctly'
  7708. );
  7709. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7710. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7711. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7712. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7713. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7714. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7715. }
  7716. /**
  7717. * @runInSeparateProcess
  7718. */
  7719. public function testDelete95()
  7720. {
  7721. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7722. $this->_model->create(self::$pasteid, self::$paste);
  7723. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7724. $_GET['pasteid'] = self::$pasteid;
  7725. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7726. ob_start();
  7727. new zerobin;
  7728. $content = ob_get_contents();
  7729. $this->assertTag(
  7730. array(
  7731. 'id' => 'status',
  7732. 'content' => 'Paste was properly deleted'
  7733. ),
  7734. $content,
  7735. 'outputs deleted status correctly'
  7736. );
  7737. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7738. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7739. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  7740. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  7741. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  7742. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  7743. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  7744. }
  7745. /**
  7746. * @runInSeparateProcess
  7747. */
  7748. public function testView96()
  7749. {
  7750. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7751. ob_start();
  7752. new zerobin;
  7753. $content = ob_get_contents();
  7754. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7755. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7756. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7757. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7758. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  7759. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7760. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7761. }
  7762. /**
  7763. * @runInSeparateProcess
  7764. */
  7765. public function testCreate96()
  7766. {
  7767. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7768. $_POST = self::$paste;
  7769. $_SERVER['REMOTE_ADDR'] = '::1';
  7770. $_POST["opendiscussion"] = "neither 1 nor 0";
  7771. ob_start();
  7772. new zerobin;
  7773. $content = ob_get_contents();
  7774. $response = json_decode($content, true);
  7775. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  7776. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  7777. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7778. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7779. }
  7780. /**
  7781. * @runInSeparateProcess
  7782. */
  7783. public function testRead96()
  7784. {
  7785. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7786. $this->_model->create(self::$pasteid, self::$paste);
  7787. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7788. ob_start();
  7789. new zerobin;
  7790. $content = ob_get_contents();
  7791. $this->assertTag(
  7792. array(
  7793. 'id' => 'cipherdata',
  7794. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7795. ),
  7796. $content,
  7797. 'outputs data correctly'
  7798. );
  7799. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7800. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7801. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7802. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7803. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7804. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7805. }
  7806. /**
  7807. * @runInSeparateProcess
  7808. */
  7809. public function testDelete96()
  7810. {
  7811. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7812. $this->_model->create(self::$pasteid, self::$paste);
  7813. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7814. $_GET['pasteid'] = self::$pasteid;
  7815. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7816. ob_start();
  7817. new zerobin;
  7818. $content = ob_get_contents();
  7819. $this->assertTag(
  7820. array(
  7821. 'id' => 'status',
  7822. 'content' => 'Paste was properly deleted'
  7823. ),
  7824. $content,
  7825. 'outputs deleted status correctly'
  7826. );
  7827. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7828. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7829. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7830. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7831. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7832. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7833. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7834. }
  7835. /**
  7836. * @runInSeparateProcess
  7837. */
  7838. public function testView97()
  7839. {
  7840. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7841. ob_start();
  7842. new zerobin;
  7843. $content = ob_get_contents();
  7844. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7845. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7846. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7847. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7848. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  7849. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7850. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7851. }
  7852. /**
  7853. * @runInSeparateProcess
  7854. */
  7855. public function testRead97()
  7856. {
  7857. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7858. $this->_model->create(self::$pasteid, self::$paste);
  7859. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7860. ob_start();
  7861. new zerobin;
  7862. $content = ob_get_contents();
  7863. $this->assertTag(
  7864. array(
  7865. 'id' => 'cipherdata',
  7866. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7867. ),
  7868. $content,
  7869. 'outputs data correctly'
  7870. );
  7871. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7872. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7873. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7874. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7875. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7876. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7877. }
  7878. /**
  7879. * @runInSeparateProcess
  7880. */
  7881. public function testDelete97()
  7882. {
  7883. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7884. $this->_model->create(self::$pasteid, self::$paste);
  7885. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7886. $_GET['pasteid'] = self::$pasteid;
  7887. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7888. ob_start();
  7889. new zerobin;
  7890. $content = ob_get_contents();
  7891. $this->assertTag(
  7892. array(
  7893. 'id' => 'status',
  7894. 'content' => 'Paste was properly deleted'
  7895. ),
  7896. $content,
  7897. 'outputs deleted status correctly'
  7898. );
  7899. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7900. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  7901. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7902. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7903. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7904. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7905. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7906. }
  7907. /**
  7908. * @runInSeparateProcess
  7909. */
  7910. public function testView98()
  7911. {
  7912. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7913. ob_start();
  7914. new zerobin;
  7915. $content = ob_get_contents();
  7916. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7917. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7918. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7919. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7920. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  7921. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7922. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7923. }
  7924. /**
  7925. * @runInSeparateProcess
  7926. */
  7927. public function testCreate98()
  7928. {
  7929. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7930. $_POST = self::$paste;
  7931. $_SERVER['REMOTE_ADDR'] = '::1';
  7932. ob_start();
  7933. new zerobin;
  7934. $content = ob_get_contents();
  7935. $response = json_decode($content, true);
  7936. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  7937. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  7938. }
  7939. /**
  7940. * @runInSeparateProcess
  7941. */
  7942. public function testRead98()
  7943. {
  7944. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7945. $this->_model->create(self::$pasteid, self::$paste);
  7946. $_SERVER['QUERY_STRING'] = self::$pasteid;
  7947. ob_start();
  7948. new zerobin;
  7949. $content = ob_get_contents();
  7950. $this->assertTag(
  7951. array(
  7952. 'id' => 'cipherdata',
  7953. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  7954. ),
  7955. $content,
  7956. 'outputs data correctly'
  7957. );
  7958. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7959. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7960. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7961. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7962. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7963. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7964. }
  7965. /**
  7966. * @runInSeparateProcess
  7967. */
  7968. public function testDelete98()
  7969. {
  7970. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  7971. $this->_model->create(self::$pasteid, self::$paste);
  7972. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  7973. $_GET['pasteid'] = self::$pasteid;
  7974. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  7975. ob_start();
  7976. new zerobin;
  7977. $content = ob_get_contents();
  7978. $this->assertTag(
  7979. array(
  7980. 'id' => 'status',
  7981. 'content' => 'Paste was properly deleted'
  7982. ),
  7983. $content,
  7984. 'outputs deleted status correctly'
  7985. );
  7986. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  7987. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  7988. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  7989. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  7990. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  7991. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  7992. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  7993. }
  7994. /**
  7995. * @runInSeparateProcess
  7996. */
  7997. public function testView99()
  7998. {
  7999. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8000. ob_start();
  8001. new zerobin;
  8002. $content = ob_get_contents();
  8003. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8004. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8005. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8006. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  8007. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8008. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8009. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8010. }
  8011. /**
  8012. * @runInSeparateProcess
  8013. */
  8014. public function testRead99()
  8015. {
  8016. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8017. $this->_model->create(self::$pasteid, self::$paste);
  8018. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8019. ob_start();
  8020. new zerobin;
  8021. $content = ob_get_contents();
  8022. $this->assertTag(
  8023. array(
  8024. 'id' => 'cipherdata',
  8025. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8026. ),
  8027. $content,
  8028. 'outputs data correctly'
  8029. );
  8030. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8031. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8032. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8033. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  8034. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8035. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8036. }
  8037. /**
  8038. * @runInSeparateProcess
  8039. */
  8040. public function testDelete99()
  8041. {
  8042. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8043. $this->_model->create(self::$pasteid, self::$paste);
  8044. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8045. $_GET['pasteid'] = self::$pasteid;
  8046. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8047. ob_start();
  8048. new zerobin;
  8049. $content = ob_get_contents();
  8050. $this->assertTag(
  8051. array(
  8052. 'id' => 'status',
  8053. 'content' => 'Paste was properly deleted'
  8054. ),
  8055. $content,
  8056. 'outputs deleted status correctly'
  8057. );
  8058. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8059. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8060. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8061. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8062. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  8063. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8064. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8065. }
  8066. /**
  8067. * @runInSeparateProcess
  8068. */
  8069. public function testView100()
  8070. {
  8071. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8072. ob_start();
  8073. new zerobin;
  8074. $content = ob_get_contents();
  8075. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8076. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8077. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8078. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8079. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8080. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8081. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8082. }
  8083. /**
  8084. * @runInSeparateProcess
  8085. */
  8086. public function testCreate100()
  8087. {
  8088. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8089. $_POST = self::$paste;
  8090. $_SERVER['REMOTE_ADDR'] = '::1';
  8091. $_POST["opendiscussion"] = "neither 1 nor 0";
  8092. ob_start();
  8093. new zerobin;
  8094. $content = ob_get_contents();
  8095. $response = json_decode($content, true);
  8096. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  8097. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  8098. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8099. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8100. }
  8101. /**
  8102. * @runInSeparateProcess
  8103. */
  8104. public function testRead100()
  8105. {
  8106. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8107. $this->_model->create(self::$pasteid, self::$paste);
  8108. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8109. ob_start();
  8110. new zerobin;
  8111. $content = ob_get_contents();
  8112. $this->assertTag(
  8113. array(
  8114. 'id' => 'cipherdata',
  8115. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8116. ),
  8117. $content,
  8118. 'outputs data correctly'
  8119. );
  8120. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8121. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8122. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8123. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8124. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8125. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8126. }
  8127. /**
  8128. * @runInSeparateProcess
  8129. */
  8130. public function testDelete100()
  8131. {
  8132. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8133. $this->_model->create(self::$pasteid, self::$paste);
  8134. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8135. $_GET['pasteid'] = self::$pasteid;
  8136. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8137. ob_start();
  8138. new zerobin;
  8139. $content = ob_get_contents();
  8140. $this->assertTag(
  8141. array(
  8142. 'id' => 'status',
  8143. 'content' => 'Paste was properly deleted'
  8144. ),
  8145. $content,
  8146. 'outputs deleted status correctly'
  8147. );
  8148. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8149. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8150. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8151. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8152. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8153. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8154. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8155. }
  8156. /**
  8157. * @runInSeparateProcess
  8158. */
  8159. public function testView101()
  8160. {
  8161. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8162. ob_start();
  8163. new zerobin;
  8164. $content = ob_get_contents();
  8165. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8166. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8167. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8168. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8169. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8170. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8171. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8172. }
  8173. /**
  8174. * @runInSeparateProcess
  8175. */
  8176. public function testRead101()
  8177. {
  8178. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8179. $this->_model->create(self::$pasteid, self::$paste);
  8180. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8181. ob_start();
  8182. new zerobin;
  8183. $content = ob_get_contents();
  8184. $this->assertTag(
  8185. array(
  8186. 'id' => 'cipherdata',
  8187. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8188. ),
  8189. $content,
  8190. 'outputs data correctly'
  8191. );
  8192. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8193. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8194. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8195. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8196. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8197. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8198. }
  8199. /**
  8200. * @runInSeparateProcess
  8201. */
  8202. public function testDelete101()
  8203. {
  8204. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8205. $this->_model->create(self::$pasteid, self::$paste);
  8206. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8207. $_GET['pasteid'] = self::$pasteid;
  8208. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8209. ob_start();
  8210. new zerobin;
  8211. $content = ob_get_contents();
  8212. $this->assertTag(
  8213. array(
  8214. 'id' => 'status',
  8215. 'content' => 'Paste was properly deleted'
  8216. ),
  8217. $content,
  8218. 'outputs deleted status correctly'
  8219. );
  8220. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8221. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8222. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8223. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8224. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8225. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8226. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8227. }
  8228. /**
  8229. * @runInSeparateProcess
  8230. */
  8231. public function testView102()
  8232. {
  8233. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8234. ob_start();
  8235. new zerobin;
  8236. $content = ob_get_contents();
  8237. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8238. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8239. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8240. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8241. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8242. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8243. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8244. }
  8245. /**
  8246. * @runInSeparateProcess
  8247. */
  8248. public function testCreate102()
  8249. {
  8250. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8251. $_POST = self::$paste;
  8252. $_SERVER['REMOTE_ADDR'] = '::1';
  8253. ob_start();
  8254. new zerobin;
  8255. $content = ob_get_contents();
  8256. $response = json_decode($content, true);
  8257. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8258. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8259. }
  8260. /**
  8261. * @runInSeparateProcess
  8262. */
  8263. public function testRead102()
  8264. {
  8265. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8266. $this->_model->create(self::$pasteid, self::$paste);
  8267. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8268. ob_start();
  8269. new zerobin;
  8270. $content = ob_get_contents();
  8271. $this->assertTag(
  8272. array(
  8273. 'id' => 'cipherdata',
  8274. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8275. ),
  8276. $content,
  8277. 'outputs data correctly'
  8278. );
  8279. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8280. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8281. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8282. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8283. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8284. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8285. }
  8286. /**
  8287. * @runInSeparateProcess
  8288. */
  8289. public function testDelete102()
  8290. {
  8291. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8292. $this->_model->create(self::$pasteid, self::$paste);
  8293. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8294. $_GET['pasteid'] = self::$pasteid;
  8295. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8296. ob_start();
  8297. new zerobin;
  8298. $content = ob_get_contents();
  8299. $this->assertTag(
  8300. array(
  8301. 'id' => 'status',
  8302. 'content' => 'Paste was properly deleted'
  8303. ),
  8304. $content,
  8305. 'outputs deleted status correctly'
  8306. );
  8307. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8308. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8309. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8310. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8311. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8312. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8313. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8314. }
  8315. /**
  8316. * @runInSeparateProcess
  8317. */
  8318. public function testView103()
  8319. {
  8320. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8321. ob_start();
  8322. new zerobin;
  8323. $content = ob_get_contents();
  8324. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8325. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8326. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8327. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8328. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8329. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8330. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8331. }
  8332. /**
  8333. * @runInSeparateProcess
  8334. */
  8335. public function testRead103()
  8336. {
  8337. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8338. $this->_model->create(self::$pasteid, self::$paste);
  8339. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8340. ob_start();
  8341. new zerobin;
  8342. $content = ob_get_contents();
  8343. $this->assertTag(
  8344. array(
  8345. 'id' => 'cipherdata',
  8346. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8347. ),
  8348. $content,
  8349. 'outputs data correctly'
  8350. );
  8351. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8352. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8353. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8354. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8355. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8356. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8357. }
  8358. /**
  8359. * @runInSeparateProcess
  8360. */
  8361. public function testDelete103()
  8362. {
  8363. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8364. $this->_model->create(self::$pasteid, self::$paste);
  8365. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8366. $_GET['pasteid'] = self::$pasteid;
  8367. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8368. ob_start();
  8369. new zerobin;
  8370. $content = ob_get_contents();
  8371. $this->assertTag(
  8372. array(
  8373. 'id' => 'status',
  8374. 'content' => 'Paste was properly deleted'
  8375. ),
  8376. $content,
  8377. 'outputs deleted status correctly'
  8378. );
  8379. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8380. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8381. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8382. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8383. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8384. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8385. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8386. }
  8387. /**
  8388. * @runInSeparateProcess
  8389. */
  8390. public function testView104()
  8391. {
  8392. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8393. ob_start();
  8394. new zerobin;
  8395. $content = ob_get_contents();
  8396. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8397. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8398. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8399. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8400. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8401. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8402. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8403. }
  8404. /**
  8405. * @runInSeparateProcess
  8406. */
  8407. public function testCreate104()
  8408. {
  8409. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8410. $_POST = self::$paste;
  8411. $_SERVER['REMOTE_ADDR'] = '::1';
  8412. $_POST["opendiscussion"] = "neither 1 nor 0";
  8413. ob_start();
  8414. new zerobin;
  8415. $content = ob_get_contents();
  8416. $response = json_decode($content, true);
  8417. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  8418. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  8419. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8420. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8421. }
  8422. /**
  8423. * @runInSeparateProcess
  8424. */
  8425. public function testRead104()
  8426. {
  8427. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8428. $this->_model->create(self::$pasteid, self::$paste);
  8429. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8430. ob_start();
  8431. new zerobin;
  8432. $content = ob_get_contents();
  8433. $this->assertTag(
  8434. array(
  8435. 'id' => 'cipherdata',
  8436. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8437. ),
  8438. $content,
  8439. 'outputs data correctly'
  8440. );
  8441. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8442. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8443. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8444. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8445. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8446. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8447. }
  8448. /**
  8449. * @runInSeparateProcess
  8450. */
  8451. public function testDelete104()
  8452. {
  8453. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8454. $this->_model->create(self::$pasteid, self::$paste);
  8455. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8456. $_GET['pasteid'] = self::$pasteid;
  8457. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8458. ob_start();
  8459. new zerobin;
  8460. $content = ob_get_contents();
  8461. $this->assertTag(
  8462. array(
  8463. 'id' => 'status',
  8464. 'content' => 'Paste was properly deleted'
  8465. ),
  8466. $content,
  8467. 'outputs deleted status correctly'
  8468. );
  8469. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8470. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8471. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8472. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8473. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8474. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8475. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8476. }
  8477. /**
  8478. * @runInSeparateProcess
  8479. */
  8480. public function testView105()
  8481. {
  8482. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8483. ob_start();
  8484. new zerobin;
  8485. $content = ob_get_contents();
  8486. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8487. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8488. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8489. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8490. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8491. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8492. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8493. }
  8494. /**
  8495. * @runInSeparateProcess
  8496. */
  8497. public function testRead105()
  8498. {
  8499. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8500. $this->_model->create(self::$pasteid, self::$paste);
  8501. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8502. ob_start();
  8503. new zerobin;
  8504. $content = ob_get_contents();
  8505. $this->assertTag(
  8506. array(
  8507. 'id' => 'cipherdata',
  8508. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8509. ),
  8510. $content,
  8511. 'outputs data correctly'
  8512. );
  8513. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8514. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8515. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8516. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8517. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8518. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8519. }
  8520. /**
  8521. * @runInSeparateProcess
  8522. */
  8523. public function testDelete105()
  8524. {
  8525. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8526. $this->_model->create(self::$pasteid, self::$paste);
  8527. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8528. $_GET['pasteid'] = self::$pasteid;
  8529. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8530. ob_start();
  8531. new zerobin;
  8532. $content = ob_get_contents();
  8533. $this->assertTag(
  8534. array(
  8535. 'id' => 'status',
  8536. 'content' => 'Paste was properly deleted'
  8537. ),
  8538. $content,
  8539. 'outputs deleted status correctly'
  8540. );
  8541. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8542. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8543. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8544. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8545. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8546. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8547. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8548. }
  8549. /**
  8550. * @runInSeparateProcess
  8551. */
  8552. public function testView106()
  8553. {
  8554. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8555. ob_start();
  8556. new zerobin;
  8557. $content = ob_get_contents();
  8558. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8559. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8560. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8561. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8562. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8563. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8564. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8565. }
  8566. /**
  8567. * @runInSeparateProcess
  8568. */
  8569. public function testCreate106()
  8570. {
  8571. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8572. $_POST = self::$paste;
  8573. $_SERVER['REMOTE_ADDR'] = '::1';
  8574. ob_start();
  8575. new zerobin;
  8576. $content = ob_get_contents();
  8577. $response = json_decode($content, true);
  8578. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8579. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8580. }
  8581. /**
  8582. * @runInSeparateProcess
  8583. */
  8584. public function testRead106()
  8585. {
  8586. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8587. $this->_model->create(self::$pasteid, self::$paste);
  8588. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8589. ob_start();
  8590. new zerobin;
  8591. $content = ob_get_contents();
  8592. $this->assertTag(
  8593. array(
  8594. 'id' => 'cipherdata',
  8595. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8596. ),
  8597. $content,
  8598. 'outputs data correctly'
  8599. );
  8600. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8601. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8602. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8603. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8604. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8605. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8606. }
  8607. /**
  8608. * @runInSeparateProcess
  8609. */
  8610. public function testDelete106()
  8611. {
  8612. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8613. $this->_model->create(self::$pasteid, self::$paste);
  8614. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8615. $_GET['pasteid'] = self::$pasteid;
  8616. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8617. ob_start();
  8618. new zerobin;
  8619. $content = ob_get_contents();
  8620. $this->assertTag(
  8621. array(
  8622. 'id' => 'status',
  8623. 'content' => 'Paste was properly deleted'
  8624. ),
  8625. $content,
  8626. 'outputs deleted status correctly'
  8627. );
  8628. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8629. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8630. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8631. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8632. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8633. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8634. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8635. }
  8636. /**
  8637. * @runInSeparateProcess
  8638. */
  8639. public function testView107()
  8640. {
  8641. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8642. ob_start();
  8643. new zerobin;
  8644. $content = ob_get_contents();
  8645. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8646. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8647. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8648. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8649. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8650. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8651. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8652. }
  8653. /**
  8654. * @runInSeparateProcess
  8655. */
  8656. public function testRead107()
  8657. {
  8658. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8659. $this->_model->create(self::$pasteid, self::$paste);
  8660. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8661. ob_start();
  8662. new zerobin;
  8663. $content = ob_get_contents();
  8664. $this->assertTag(
  8665. array(
  8666. 'id' => 'cipherdata',
  8667. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8668. ),
  8669. $content,
  8670. 'outputs data correctly'
  8671. );
  8672. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8673. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8674. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8675. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8676. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8677. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8678. }
  8679. /**
  8680. * @runInSeparateProcess
  8681. */
  8682. public function testDelete107()
  8683. {
  8684. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8685. $this->_model->create(self::$pasteid, self::$paste);
  8686. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8687. $_GET['pasteid'] = self::$pasteid;
  8688. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8689. ob_start();
  8690. new zerobin;
  8691. $content = ob_get_contents();
  8692. $this->assertTag(
  8693. array(
  8694. 'id' => 'status',
  8695. 'content' => 'Paste was properly deleted'
  8696. ),
  8697. $content,
  8698. 'outputs deleted status correctly'
  8699. );
  8700. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8701. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8702. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  8703. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  8704. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8705. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8706. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8707. }
  8708. /**
  8709. * @runInSeparateProcess
  8710. */
  8711. public function testView108()
  8712. {
  8713. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8714. ob_start();
  8715. new zerobin;
  8716. $content = ob_get_contents();
  8717. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8718. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8719. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8720. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8721. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8722. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8723. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8724. }
  8725. /**
  8726. * @runInSeparateProcess
  8727. */
  8728. public function testCreate108()
  8729. {
  8730. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8731. $_POST = self::$paste;
  8732. $_SERVER['REMOTE_ADDR'] = '::1';
  8733. $_POST["opendiscussion"] = "neither 1 nor 0";
  8734. ob_start();
  8735. new zerobin;
  8736. $content = ob_get_contents();
  8737. $response = json_decode($content, true);
  8738. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  8739. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  8740. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8741. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8742. }
  8743. /**
  8744. * @runInSeparateProcess
  8745. */
  8746. public function testRead108()
  8747. {
  8748. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8749. $this->_model->create(self::$pasteid, self::$paste);
  8750. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8751. ob_start();
  8752. new zerobin;
  8753. $content = ob_get_contents();
  8754. $this->assertTag(
  8755. array(
  8756. 'id' => 'cipherdata',
  8757. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8758. ),
  8759. $content,
  8760. 'outputs data correctly'
  8761. );
  8762. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8763. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8764. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8765. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8766. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8767. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8768. }
  8769. /**
  8770. * @runInSeparateProcess
  8771. */
  8772. public function testDelete108()
  8773. {
  8774. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8775. $this->_model->create(self::$pasteid, self::$paste);
  8776. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8777. $_GET['pasteid'] = self::$pasteid;
  8778. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8779. ob_start();
  8780. new zerobin;
  8781. $content = ob_get_contents();
  8782. $this->assertTag(
  8783. array(
  8784. 'id' => 'status',
  8785. 'content' => 'Paste was properly deleted'
  8786. ),
  8787. $content,
  8788. 'outputs deleted status correctly'
  8789. );
  8790. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8791. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8792. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8793. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8794. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8795. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8796. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8797. }
  8798. /**
  8799. * @runInSeparateProcess
  8800. */
  8801. public function testView109()
  8802. {
  8803. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8804. ob_start();
  8805. new zerobin;
  8806. $content = ob_get_contents();
  8807. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8808. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8809. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8810. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8811. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8812. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8813. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8814. }
  8815. /**
  8816. * @runInSeparateProcess
  8817. */
  8818. public function testRead109()
  8819. {
  8820. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8821. $this->_model->create(self::$pasteid, self::$paste);
  8822. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8823. ob_start();
  8824. new zerobin;
  8825. $content = ob_get_contents();
  8826. $this->assertTag(
  8827. array(
  8828. 'id' => 'cipherdata',
  8829. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8830. ),
  8831. $content,
  8832. 'outputs data correctly'
  8833. );
  8834. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8835. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8836. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8837. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8838. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8839. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8840. }
  8841. /**
  8842. * @runInSeparateProcess
  8843. */
  8844. public function testDelete109()
  8845. {
  8846. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8847. $this->_model->create(self::$pasteid, self::$paste);
  8848. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8849. $_GET['pasteid'] = self::$pasteid;
  8850. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8851. ob_start();
  8852. new zerobin;
  8853. $content = ob_get_contents();
  8854. $this->assertTag(
  8855. array(
  8856. 'id' => 'status',
  8857. 'content' => 'Paste was properly deleted'
  8858. ),
  8859. $content,
  8860. 'outputs deleted status correctly'
  8861. );
  8862. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8863. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  8864. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8865. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8866. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8867. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8868. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8869. }
  8870. /**
  8871. * @runInSeparateProcess
  8872. */
  8873. public function testView110()
  8874. {
  8875. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8876. ob_start();
  8877. new zerobin;
  8878. $content = ob_get_contents();
  8879. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8880. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8881. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8882. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8883. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8884. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8885. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8886. }
  8887. /**
  8888. * @runInSeparateProcess
  8889. */
  8890. public function testCreate110()
  8891. {
  8892. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8893. $_POST = self::$paste;
  8894. $_SERVER['REMOTE_ADDR'] = '::1';
  8895. ob_start();
  8896. new zerobin;
  8897. $content = ob_get_contents();
  8898. $response = json_decode($content, true);
  8899. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  8900. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  8901. }
  8902. /**
  8903. * @runInSeparateProcess
  8904. */
  8905. public function testRead110()
  8906. {
  8907. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8908. $this->_model->create(self::$pasteid, self::$paste);
  8909. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8910. ob_start();
  8911. new zerobin;
  8912. $content = ob_get_contents();
  8913. $this->assertTag(
  8914. array(
  8915. 'id' => 'cipherdata',
  8916. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8917. ),
  8918. $content,
  8919. 'outputs data correctly'
  8920. );
  8921. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8922. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8923. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8924. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8925. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8926. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8927. }
  8928. /**
  8929. * @runInSeparateProcess
  8930. */
  8931. public function testDelete110()
  8932. {
  8933. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8934. $this->_model->create(self::$pasteid, self::$paste);
  8935. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  8936. $_GET['pasteid'] = self::$pasteid;
  8937. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  8938. ob_start();
  8939. new zerobin;
  8940. $content = ob_get_contents();
  8941. $this->assertTag(
  8942. array(
  8943. 'id' => 'status',
  8944. 'content' => 'Paste was properly deleted'
  8945. ),
  8946. $content,
  8947. 'outputs deleted status correctly'
  8948. );
  8949. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  8950. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8951. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8952. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8953. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8954. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8955. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8956. }
  8957. /**
  8958. * @runInSeparateProcess
  8959. */
  8960. public function testView111()
  8961. {
  8962. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8963. ob_start();
  8964. new zerobin;
  8965. $content = ob_get_contents();
  8966. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8967. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8968. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8969. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8970. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  8971. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8972. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8973. }
  8974. /**
  8975. * @runInSeparateProcess
  8976. */
  8977. public function testRead111()
  8978. {
  8979. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  8980. $this->_model->create(self::$pasteid, self::$paste);
  8981. $_SERVER['QUERY_STRING'] = self::$pasteid;
  8982. ob_start();
  8983. new zerobin;
  8984. $content = ob_get_contents();
  8985. $this->assertTag(
  8986. array(
  8987. 'id' => 'cipherdata',
  8988. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  8989. ),
  8990. $content,
  8991. 'outputs data correctly'
  8992. );
  8993. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  8994. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  8995. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  8996. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  8997. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  8998. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  8999. }
  9000. /**
  9001. * @runInSeparateProcess
  9002. */
  9003. public function testDelete111()
  9004. {
  9005. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9006. $this->_model->create(self::$pasteid, self::$paste);
  9007. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9008. $_GET['pasteid'] = self::$pasteid;
  9009. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9010. ob_start();
  9011. new zerobin;
  9012. $content = ob_get_contents();
  9013. $this->assertTag(
  9014. array(
  9015. 'id' => 'status',
  9016. 'content' => 'Paste was properly deleted'
  9017. ),
  9018. $content,
  9019. 'outputs deleted status correctly'
  9020. );
  9021. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9022. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9023. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9024. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9025. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9026. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9027. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9028. }
  9029. /**
  9030. * @runInSeparateProcess
  9031. */
  9032. public function testView112()
  9033. {
  9034. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9035. ob_start();
  9036. new zerobin;
  9037. $content = ob_get_contents();
  9038. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9039. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9040. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9041. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9042. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9043. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9044. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9045. }
  9046. /**
  9047. * @runInSeparateProcess
  9048. */
  9049. public function testCreate112()
  9050. {
  9051. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9052. $_POST = self::$paste;
  9053. $_SERVER['REMOTE_ADDR'] = '::1';
  9054. $_POST["opendiscussion"] = "neither 1 nor 0";
  9055. ob_start();
  9056. new zerobin;
  9057. $content = ob_get_contents();
  9058. $response = json_decode($content, true);
  9059. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  9060. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  9061. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9062. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9063. }
  9064. /**
  9065. * @runInSeparateProcess
  9066. */
  9067. public function testRead112()
  9068. {
  9069. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9070. $this->_model->create(self::$pasteid, self::$paste);
  9071. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9072. ob_start();
  9073. new zerobin;
  9074. $content = ob_get_contents();
  9075. $this->assertTag(
  9076. array(
  9077. 'id' => 'cipherdata',
  9078. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9079. ),
  9080. $content,
  9081. 'outputs data correctly'
  9082. );
  9083. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9084. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9085. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9086. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9087. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9088. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9089. }
  9090. /**
  9091. * @runInSeparateProcess
  9092. */
  9093. public function testDelete112()
  9094. {
  9095. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9096. $this->_model->create(self::$pasteid, self::$paste);
  9097. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9098. $_GET['pasteid'] = self::$pasteid;
  9099. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9100. ob_start();
  9101. new zerobin;
  9102. $content = ob_get_contents();
  9103. $this->assertTag(
  9104. array(
  9105. 'id' => 'status',
  9106. 'content' => 'Paste was properly deleted'
  9107. ),
  9108. $content,
  9109. 'outputs deleted status correctly'
  9110. );
  9111. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9112. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9113. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9114. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9115. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9116. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9117. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9118. }
  9119. /**
  9120. * @runInSeparateProcess
  9121. */
  9122. public function testView113()
  9123. {
  9124. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9125. ob_start();
  9126. new zerobin;
  9127. $content = ob_get_contents();
  9128. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9129. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9130. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9131. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9132. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9133. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9134. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9135. }
  9136. /**
  9137. * @runInSeparateProcess
  9138. */
  9139. public function testRead113()
  9140. {
  9141. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9142. $this->_model->create(self::$pasteid, self::$paste);
  9143. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9144. ob_start();
  9145. new zerobin;
  9146. $content = ob_get_contents();
  9147. $this->assertTag(
  9148. array(
  9149. 'id' => 'cipherdata',
  9150. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9151. ),
  9152. $content,
  9153. 'outputs data correctly'
  9154. );
  9155. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9156. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9157. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9158. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9159. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9160. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9161. }
  9162. /**
  9163. * @runInSeparateProcess
  9164. */
  9165. public function testDelete113()
  9166. {
  9167. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9168. $this->_model->create(self::$pasteid, self::$paste);
  9169. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9170. $_GET['pasteid'] = self::$pasteid;
  9171. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9172. ob_start();
  9173. new zerobin;
  9174. $content = ob_get_contents();
  9175. $this->assertTag(
  9176. array(
  9177. 'id' => 'status',
  9178. 'content' => 'Paste was properly deleted'
  9179. ),
  9180. $content,
  9181. 'outputs deleted status correctly'
  9182. );
  9183. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9184. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9185. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9186. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9187. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9188. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9189. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9190. }
  9191. /**
  9192. * @runInSeparateProcess
  9193. */
  9194. public function testView114()
  9195. {
  9196. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9197. ob_start();
  9198. new zerobin;
  9199. $content = ob_get_contents();
  9200. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9201. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9202. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9203. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9204. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9205. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9206. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9207. }
  9208. /**
  9209. * @runInSeparateProcess
  9210. */
  9211. public function testCreate114()
  9212. {
  9213. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9214. $_POST = self::$paste;
  9215. $_SERVER['REMOTE_ADDR'] = '::1';
  9216. ob_start();
  9217. new zerobin;
  9218. $content = ob_get_contents();
  9219. $response = json_decode($content, true);
  9220. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9221. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9222. }
  9223. /**
  9224. * @runInSeparateProcess
  9225. */
  9226. public function testRead114()
  9227. {
  9228. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9229. $this->_model->create(self::$pasteid, self::$paste);
  9230. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9231. ob_start();
  9232. new zerobin;
  9233. $content = ob_get_contents();
  9234. $this->assertTag(
  9235. array(
  9236. 'id' => 'cipherdata',
  9237. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9238. ),
  9239. $content,
  9240. 'outputs data correctly'
  9241. );
  9242. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9243. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9244. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9245. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9246. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9247. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9248. }
  9249. /**
  9250. * @runInSeparateProcess
  9251. */
  9252. public function testDelete114()
  9253. {
  9254. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9255. $this->_model->create(self::$pasteid, self::$paste);
  9256. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9257. $_GET['pasteid'] = self::$pasteid;
  9258. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9259. ob_start();
  9260. new zerobin;
  9261. $content = ob_get_contents();
  9262. $this->assertTag(
  9263. array(
  9264. 'id' => 'status',
  9265. 'content' => 'Paste was properly deleted'
  9266. ),
  9267. $content,
  9268. 'outputs deleted status correctly'
  9269. );
  9270. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9271. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9272. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9273. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9274. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9275. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9276. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9277. }
  9278. /**
  9279. * @runInSeparateProcess
  9280. */
  9281. public function testView115()
  9282. {
  9283. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9284. ob_start();
  9285. new zerobin;
  9286. $content = ob_get_contents();
  9287. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9288. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9289. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9290. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9291. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9292. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9293. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9294. }
  9295. /**
  9296. * @runInSeparateProcess
  9297. */
  9298. public function testRead115()
  9299. {
  9300. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9301. $this->_model->create(self::$pasteid, self::$paste);
  9302. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9303. ob_start();
  9304. new zerobin;
  9305. $content = ob_get_contents();
  9306. $this->assertTag(
  9307. array(
  9308. 'id' => 'cipherdata',
  9309. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9310. ),
  9311. $content,
  9312. 'outputs data correctly'
  9313. );
  9314. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9315. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9316. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9317. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9318. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9319. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9320. }
  9321. /**
  9322. * @runInSeparateProcess
  9323. */
  9324. public function testDelete115()
  9325. {
  9326. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9327. $this->_model->create(self::$pasteid, self::$paste);
  9328. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9329. $_GET['pasteid'] = self::$pasteid;
  9330. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9331. ob_start();
  9332. new zerobin;
  9333. $content = ob_get_contents();
  9334. $this->assertTag(
  9335. array(
  9336. 'id' => 'status',
  9337. 'content' => 'Paste was properly deleted'
  9338. ),
  9339. $content,
  9340. 'outputs deleted status correctly'
  9341. );
  9342. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9343. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9344. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9345. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9346. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  9347. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9348. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9349. }
  9350. /**
  9351. * @runInSeparateProcess
  9352. */
  9353. public function testView116()
  9354. {
  9355. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9356. ob_start();
  9357. new zerobin;
  9358. $content = ob_get_contents();
  9359. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9360. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9361. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9362. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9363. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9364. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9365. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9366. }
  9367. /**
  9368. * @runInSeparateProcess
  9369. */
  9370. public function testCreate116()
  9371. {
  9372. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9373. $_POST = self::$paste;
  9374. $_SERVER['REMOTE_ADDR'] = '::1';
  9375. $_POST["opendiscussion"] = "neither 1 nor 0";
  9376. ob_start();
  9377. new zerobin;
  9378. $content = ob_get_contents();
  9379. $response = json_decode($content, true);
  9380. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  9381. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  9382. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9383. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9384. }
  9385. /**
  9386. * @runInSeparateProcess
  9387. */
  9388. public function testRead116()
  9389. {
  9390. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9391. $this->_model->create(self::$pasteid, self::$paste);
  9392. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9393. ob_start();
  9394. new zerobin;
  9395. $content = ob_get_contents();
  9396. $this->assertTag(
  9397. array(
  9398. 'id' => 'cipherdata',
  9399. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9400. ),
  9401. $content,
  9402. 'outputs data correctly'
  9403. );
  9404. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9405. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9406. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9407. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9408. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9409. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9410. }
  9411. /**
  9412. * @runInSeparateProcess
  9413. */
  9414. public function testDelete116()
  9415. {
  9416. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9417. $this->_model->create(self::$pasteid, self::$paste);
  9418. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9419. $_GET['pasteid'] = self::$pasteid;
  9420. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9421. ob_start();
  9422. new zerobin;
  9423. $content = ob_get_contents();
  9424. $this->assertTag(
  9425. array(
  9426. 'id' => 'status',
  9427. 'content' => 'Paste was properly deleted'
  9428. ),
  9429. $content,
  9430. 'outputs deleted status correctly'
  9431. );
  9432. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9433. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9434. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9435. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9436. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9437. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9438. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9439. }
  9440. /**
  9441. * @runInSeparateProcess
  9442. */
  9443. public function testView117()
  9444. {
  9445. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9446. ob_start();
  9447. new zerobin;
  9448. $content = ob_get_contents();
  9449. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9450. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9451. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9452. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9453. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9454. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9455. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9456. }
  9457. /**
  9458. * @runInSeparateProcess
  9459. */
  9460. public function testRead117()
  9461. {
  9462. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9463. $this->_model->create(self::$pasteid, self::$paste);
  9464. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9465. ob_start();
  9466. new zerobin;
  9467. $content = ob_get_contents();
  9468. $this->assertTag(
  9469. array(
  9470. 'id' => 'cipherdata',
  9471. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9472. ),
  9473. $content,
  9474. 'outputs data correctly'
  9475. );
  9476. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9477. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9478. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9479. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9480. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9481. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9482. }
  9483. /**
  9484. * @runInSeparateProcess
  9485. */
  9486. public function testDelete117()
  9487. {
  9488. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9489. $this->_model->create(self::$pasteid, self::$paste);
  9490. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9491. $_GET['pasteid'] = self::$pasteid;
  9492. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9493. ob_start();
  9494. new zerobin;
  9495. $content = ob_get_contents();
  9496. $this->assertTag(
  9497. array(
  9498. 'id' => 'status',
  9499. 'content' => 'Paste was properly deleted'
  9500. ),
  9501. $content,
  9502. 'outputs deleted status correctly'
  9503. );
  9504. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9505. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9506. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9507. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9508. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9509. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9510. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9511. }
  9512. /**
  9513. * @runInSeparateProcess
  9514. */
  9515. public function testView118()
  9516. {
  9517. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9518. ob_start();
  9519. new zerobin;
  9520. $content = ob_get_contents();
  9521. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9522. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9523. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9524. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9525. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9526. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9527. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9528. }
  9529. /**
  9530. * @runInSeparateProcess
  9531. */
  9532. public function testCreate118()
  9533. {
  9534. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9535. $_POST = self::$paste;
  9536. $_SERVER['REMOTE_ADDR'] = '::1';
  9537. ob_start();
  9538. new zerobin;
  9539. $content = ob_get_contents();
  9540. $response = json_decode($content, true);
  9541. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9542. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9543. }
  9544. /**
  9545. * @runInSeparateProcess
  9546. */
  9547. public function testRead118()
  9548. {
  9549. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9550. $this->_model->create(self::$pasteid, self::$paste);
  9551. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9552. ob_start();
  9553. new zerobin;
  9554. $content = ob_get_contents();
  9555. $this->assertTag(
  9556. array(
  9557. 'id' => 'cipherdata',
  9558. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9559. ),
  9560. $content,
  9561. 'outputs data correctly'
  9562. );
  9563. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9564. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9565. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9566. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9567. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9568. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9569. }
  9570. /**
  9571. * @runInSeparateProcess
  9572. */
  9573. public function testDelete118()
  9574. {
  9575. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9576. $this->_model->create(self::$pasteid, self::$paste);
  9577. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9578. $_GET['pasteid'] = self::$pasteid;
  9579. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9580. ob_start();
  9581. new zerobin;
  9582. $content = ob_get_contents();
  9583. $this->assertTag(
  9584. array(
  9585. 'id' => 'status',
  9586. 'content' => 'Paste was properly deleted'
  9587. ),
  9588. $content,
  9589. 'outputs deleted status correctly'
  9590. );
  9591. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9592. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9593. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9594. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9595. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9596. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9597. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9598. }
  9599. /**
  9600. * @runInSeparateProcess
  9601. */
  9602. public function testView119()
  9603. {
  9604. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9605. ob_start();
  9606. new zerobin;
  9607. $content = ob_get_contents();
  9608. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9609. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9610. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9611. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9612. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9613. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9614. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9615. }
  9616. /**
  9617. * @runInSeparateProcess
  9618. */
  9619. public function testRead119()
  9620. {
  9621. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9622. $this->_model->create(self::$pasteid, self::$paste);
  9623. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9624. ob_start();
  9625. new zerobin;
  9626. $content = ob_get_contents();
  9627. $this->assertTag(
  9628. array(
  9629. 'id' => 'cipherdata',
  9630. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9631. ),
  9632. $content,
  9633. 'outputs data correctly'
  9634. );
  9635. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9636. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9637. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9638. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9639. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9640. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9641. }
  9642. /**
  9643. * @runInSeparateProcess
  9644. */
  9645. public function testDelete119()
  9646. {
  9647. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9648. $this->_model->create(self::$pasteid, self::$paste);
  9649. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9650. $_GET['pasteid'] = self::$pasteid;
  9651. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9652. ob_start();
  9653. new zerobin;
  9654. $content = ob_get_contents();
  9655. $this->assertTag(
  9656. array(
  9657. 'id' => 'status',
  9658. 'content' => 'Paste was properly deleted'
  9659. ),
  9660. $content,
  9661. 'outputs deleted status correctly'
  9662. );
  9663. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9664. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9665. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  9666. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  9667. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9668. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9669. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9670. }
  9671. /**
  9672. * @runInSeparateProcess
  9673. */
  9674. public function testView120()
  9675. {
  9676. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9677. ob_start();
  9678. new zerobin;
  9679. $content = ob_get_contents();
  9680. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9681. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9682. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9683. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9684. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9685. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9686. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9687. }
  9688. /**
  9689. * @runInSeparateProcess
  9690. */
  9691. public function testCreate120()
  9692. {
  9693. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9694. $_POST = self::$paste;
  9695. $_SERVER['REMOTE_ADDR'] = '::1';
  9696. $_POST["opendiscussion"] = "neither 1 nor 0";
  9697. ob_start();
  9698. new zerobin;
  9699. $content = ob_get_contents();
  9700. $response = json_decode($content, true);
  9701. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  9702. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  9703. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9704. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9705. }
  9706. /**
  9707. * @runInSeparateProcess
  9708. */
  9709. public function testRead120()
  9710. {
  9711. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9712. $this->_model->create(self::$pasteid, self::$paste);
  9713. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9714. ob_start();
  9715. new zerobin;
  9716. $content = ob_get_contents();
  9717. $this->assertTag(
  9718. array(
  9719. 'id' => 'cipherdata',
  9720. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9721. ),
  9722. $content,
  9723. 'outputs data correctly'
  9724. );
  9725. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9726. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9727. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9728. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9729. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9730. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9731. }
  9732. /**
  9733. * @runInSeparateProcess
  9734. */
  9735. public function testDelete120()
  9736. {
  9737. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9738. $this->_model->create(self::$pasteid, self::$paste);
  9739. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9740. $_GET['pasteid'] = self::$pasteid;
  9741. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9742. ob_start();
  9743. new zerobin;
  9744. $content = ob_get_contents();
  9745. $this->assertTag(
  9746. array(
  9747. 'id' => 'status',
  9748. 'content' => 'Paste was properly deleted'
  9749. ),
  9750. $content,
  9751. 'outputs deleted status correctly'
  9752. );
  9753. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9754. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9755. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9756. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9757. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9758. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9759. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9760. }
  9761. /**
  9762. * @runInSeparateProcess
  9763. */
  9764. public function testView121()
  9765. {
  9766. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9767. ob_start();
  9768. new zerobin;
  9769. $content = ob_get_contents();
  9770. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9771. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9772. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9773. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9774. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9775. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9776. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9777. }
  9778. /**
  9779. * @runInSeparateProcess
  9780. */
  9781. public function testRead121()
  9782. {
  9783. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9784. $this->_model->create(self::$pasteid, self::$paste);
  9785. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9786. ob_start();
  9787. new zerobin;
  9788. $content = ob_get_contents();
  9789. $this->assertTag(
  9790. array(
  9791. 'id' => 'cipherdata',
  9792. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9793. ),
  9794. $content,
  9795. 'outputs data correctly'
  9796. );
  9797. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9798. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9799. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9800. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9801. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9802. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9803. }
  9804. /**
  9805. * @runInSeparateProcess
  9806. */
  9807. public function testDelete121()
  9808. {
  9809. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9810. $this->_model->create(self::$pasteid, self::$paste);
  9811. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9812. $_GET['pasteid'] = self::$pasteid;
  9813. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9814. ob_start();
  9815. new zerobin;
  9816. $content = ob_get_contents();
  9817. $this->assertTag(
  9818. array(
  9819. 'id' => 'status',
  9820. 'content' => 'Paste was properly deleted'
  9821. ),
  9822. $content,
  9823. 'outputs deleted status correctly'
  9824. );
  9825. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9826. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  9827. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9828. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9829. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9830. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9831. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9832. }
  9833. /**
  9834. * @runInSeparateProcess
  9835. */
  9836. public function testView122()
  9837. {
  9838. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9839. ob_start();
  9840. new zerobin;
  9841. $content = ob_get_contents();
  9842. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9843. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9844. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9845. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9846. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9847. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9848. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9849. }
  9850. /**
  9851. * @runInSeparateProcess
  9852. */
  9853. public function testCreate122()
  9854. {
  9855. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9856. $_POST = self::$paste;
  9857. $_SERVER['REMOTE_ADDR'] = '::1';
  9858. ob_start();
  9859. new zerobin;
  9860. $content = ob_get_contents();
  9861. $response = json_decode($content, true);
  9862. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  9863. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  9864. }
  9865. /**
  9866. * @runInSeparateProcess
  9867. */
  9868. public function testRead122()
  9869. {
  9870. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9871. $this->_model->create(self::$pasteid, self::$paste);
  9872. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9873. ob_start();
  9874. new zerobin;
  9875. $content = ob_get_contents();
  9876. $this->assertTag(
  9877. array(
  9878. 'id' => 'cipherdata',
  9879. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9880. ),
  9881. $content,
  9882. 'outputs data correctly'
  9883. );
  9884. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9885. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9886. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9887. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9888. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9889. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9890. }
  9891. /**
  9892. * @runInSeparateProcess
  9893. */
  9894. public function testDelete122()
  9895. {
  9896. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9897. $this->_model->create(self::$pasteid, self::$paste);
  9898. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9899. $_GET['pasteid'] = self::$pasteid;
  9900. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9901. ob_start();
  9902. new zerobin;
  9903. $content = ob_get_contents();
  9904. $this->assertTag(
  9905. array(
  9906. 'id' => 'status',
  9907. 'content' => 'Paste was properly deleted'
  9908. ),
  9909. $content,
  9910. 'outputs deleted status correctly'
  9911. );
  9912. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9913. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9914. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9915. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9916. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9917. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9918. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9919. }
  9920. /**
  9921. * @runInSeparateProcess
  9922. */
  9923. public function testView123()
  9924. {
  9925. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9926. ob_start();
  9927. new zerobin;
  9928. $content = ob_get_contents();
  9929. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9930. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9931. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9932. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9933. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  9934. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9935. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9936. }
  9937. /**
  9938. * @runInSeparateProcess
  9939. */
  9940. public function testRead123()
  9941. {
  9942. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9943. $this->_model->create(self::$pasteid, self::$paste);
  9944. $_SERVER['QUERY_STRING'] = self::$pasteid;
  9945. ob_start();
  9946. new zerobin;
  9947. $content = ob_get_contents();
  9948. $this->assertTag(
  9949. array(
  9950. 'id' => 'cipherdata',
  9951. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  9952. ),
  9953. $content,
  9954. 'outputs data correctly'
  9955. );
  9956. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9957. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9958. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9959. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9960. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9961. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9962. }
  9963. /**
  9964. * @runInSeparateProcess
  9965. */
  9966. public function testDelete123()
  9967. {
  9968. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9969. $this->_model->create(self::$pasteid, self::$paste);
  9970. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  9971. $_GET['pasteid'] = self::$pasteid;
  9972. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  9973. ob_start();
  9974. new zerobin;
  9975. $content = ob_get_contents();
  9976. $this->assertTag(
  9977. array(
  9978. 'id' => 'status',
  9979. 'content' => 'Paste was properly deleted'
  9980. ),
  9981. $content,
  9982. 'outputs deleted status correctly'
  9983. );
  9984. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  9985. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  9986. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  9987. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  9988. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  9989. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  9990. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  9991. }
  9992. /**
  9993. * @runInSeparateProcess
  9994. */
  9995. public function testView124()
  9996. {
  9997. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  9998. ob_start();
  9999. new zerobin;
  10000. $content = ob_get_contents();
  10001. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10002. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10003. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10004. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10005. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  10006. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10007. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10008. }
  10009. /**
  10010. * @runInSeparateProcess
  10011. */
  10012. public function testCreate124()
  10013. {
  10014. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10015. $_POST = self::$paste;
  10016. $_SERVER['REMOTE_ADDR'] = '::1';
  10017. $_POST["opendiscussion"] = "neither 1 nor 0";
  10018. ob_start();
  10019. new zerobin;
  10020. $content = ob_get_contents();
  10021. $response = json_decode($content, true);
  10022. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  10023. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  10024. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  10025. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10026. }
  10027. /**
  10028. * @runInSeparateProcess
  10029. */
  10030. public function testRead124()
  10031. {
  10032. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10033. $this->_model->create(self::$pasteid, self::$paste);
  10034. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10035. ob_start();
  10036. new zerobin;
  10037. $content = ob_get_contents();
  10038. $this->assertTag(
  10039. array(
  10040. 'id' => 'cipherdata',
  10041. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10042. ),
  10043. $content,
  10044. 'outputs data correctly'
  10045. );
  10046. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10047. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10048. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10049. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10050. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10051. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10052. }
  10053. /**
  10054. * @runInSeparateProcess
  10055. */
  10056. public function testDelete124()
  10057. {
  10058. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10059. $this->_model->create(self::$pasteid, self::$paste);
  10060. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10061. $_GET['pasteid'] = self::$pasteid;
  10062. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10063. ob_start();
  10064. new zerobin;
  10065. $content = ob_get_contents();
  10066. $this->assertTag(
  10067. array(
  10068. 'id' => 'status',
  10069. 'content' => 'Paste was properly deleted'
  10070. ),
  10071. $content,
  10072. 'outputs deleted status correctly'
  10073. );
  10074. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10075. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10076. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10077. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10078. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10079. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10080. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10081. }
  10082. /**
  10083. * @runInSeparateProcess
  10084. */
  10085. public function testView125()
  10086. {
  10087. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10088. ob_start();
  10089. new zerobin;
  10090. $content = ob_get_contents();
  10091. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10092. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10093. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10094. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10095. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  10096. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10097. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10098. }
  10099. /**
  10100. * @runInSeparateProcess
  10101. */
  10102. public function testRead125()
  10103. {
  10104. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10105. $this->_model->create(self::$pasteid, self::$paste);
  10106. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10107. ob_start();
  10108. new zerobin;
  10109. $content = ob_get_contents();
  10110. $this->assertTag(
  10111. array(
  10112. 'id' => 'cipherdata',
  10113. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10114. ),
  10115. $content,
  10116. 'outputs data correctly'
  10117. );
  10118. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10119. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10120. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10121. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10122. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10123. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10124. }
  10125. /**
  10126. * @runInSeparateProcess
  10127. */
  10128. public function testDelete125()
  10129. {
  10130. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10131. $this->_model->create(self::$pasteid, self::$paste);
  10132. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10133. $_GET['pasteid'] = self::$pasteid;
  10134. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10135. ob_start();
  10136. new zerobin;
  10137. $content = ob_get_contents();
  10138. $this->assertTag(
  10139. array(
  10140. 'id' => 'status',
  10141. 'content' => 'Paste was properly deleted'
  10142. ),
  10143. $content,
  10144. 'outputs deleted status correctly'
  10145. );
  10146. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10147. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10148. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10149. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10150. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10151. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10152. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10153. }
  10154. /**
  10155. * @runInSeparateProcess
  10156. */
  10157. public function testView126()
  10158. {
  10159. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10160. ob_start();
  10161. new zerobin;
  10162. $content = ob_get_contents();
  10163. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10164. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10165. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10166. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10167. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  10168. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10169. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10170. }
  10171. /**
  10172. * @runInSeparateProcess
  10173. */
  10174. public function testCreate126()
  10175. {
  10176. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10177. $_POST = self::$paste;
  10178. $_SERVER['REMOTE_ADDR'] = '::1';
  10179. ob_start();
  10180. new zerobin;
  10181. $content = ob_get_contents();
  10182. $response = json_decode($content, true);
  10183. $this->assertEquals(1, $response["status"], 'when sizelimit limit exceeded, fail to create paste');
  10184. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10185. }
  10186. /**
  10187. * @runInSeparateProcess
  10188. */
  10189. public function testRead126()
  10190. {
  10191. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10192. $this->_model->create(self::$pasteid, self::$paste);
  10193. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10194. ob_start();
  10195. new zerobin;
  10196. $content = ob_get_contents();
  10197. $this->assertTag(
  10198. array(
  10199. 'id' => 'cipherdata',
  10200. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10201. ),
  10202. $content,
  10203. 'outputs data correctly'
  10204. );
  10205. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10206. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10207. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10208. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10209. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10210. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10211. }
  10212. /**
  10213. * @runInSeparateProcess
  10214. */
  10215. public function testDelete126()
  10216. {
  10217. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10218. $this->_model->create(self::$pasteid, self::$paste);
  10219. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10220. $_GET['pasteid'] = self::$pasteid;
  10221. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10222. ob_start();
  10223. new zerobin;
  10224. $content = ob_get_contents();
  10225. $this->assertTag(
  10226. array(
  10227. 'id' => 'status',
  10228. 'content' => 'Paste was properly deleted'
  10229. ),
  10230. $content,
  10231. 'outputs deleted status correctly'
  10232. );
  10233. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10234. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10235. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10236. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10237. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10238. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10239. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10240. }
  10241. /**
  10242. * @runInSeparateProcess
  10243. */
  10244. public function testView127()
  10245. {
  10246. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10247. ob_start();
  10248. new zerobin;
  10249. $content = ob_get_contents();
  10250. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10251. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10252. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10253. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10254. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  10255. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10256. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10257. }
  10258. /**
  10259. * @runInSeparateProcess
  10260. */
  10261. public function testRead127()
  10262. {
  10263. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10264. $this->_model->create(self::$pasteid, self::$paste);
  10265. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10266. ob_start();
  10267. new zerobin;
  10268. $content = ob_get_contents();
  10269. $this->assertTag(
  10270. array(
  10271. 'id' => 'cipherdata',
  10272. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10273. ),
  10274. $content,
  10275. 'outputs data correctly'
  10276. );
  10277. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10278. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10279. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10280. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10281. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10282. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10283. }
  10284. /**
  10285. * @runInSeparateProcess
  10286. */
  10287. public function testDelete127()
  10288. {
  10289. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 10, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10290. $this->_model->create(self::$pasteid, self::$paste);
  10291. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10292. $_GET['pasteid'] = self::$pasteid;
  10293. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10294. ob_start();
  10295. new zerobin;
  10296. $content = ob_get_contents();
  10297. $this->assertTag(
  10298. array(
  10299. 'id' => 'status',
  10300. 'content' => 'Paste was properly deleted'
  10301. ),
  10302. $content,
  10303. 'outputs deleted status correctly'
  10304. );
  10305. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10306. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10307. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10308. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10309. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10310. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  10311. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  10312. }
  10313. /**
  10314. * @runInSeparateProcess
  10315. */
  10316. public function testView128()
  10317. {
  10318. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10319. ob_start();
  10320. new zerobin;
  10321. $content = ob_get_contents();
  10322. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10323. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10324. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10325. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10326. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10327. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10328. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10329. }
  10330. /**
  10331. * @runInSeparateProcess
  10332. */
  10333. public function testCreate128()
  10334. {
  10335. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10336. $_POST = self::$paste;
  10337. $_SERVER['REMOTE_ADDR'] = '::1';
  10338. $_POST["opendiscussion"] = "neither 1 nor 0";
  10339. ob_start();
  10340. new zerobin;
  10341. $content = ob_get_contents();
  10342. $response = json_decode($content, true);
  10343. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  10344. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  10345. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10346. }
  10347. /**
  10348. * @runInSeparateProcess
  10349. */
  10350. public function testRead128()
  10351. {
  10352. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10353. $this->_model->create(self::$pasteid, self::$paste);
  10354. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10355. ob_start();
  10356. new zerobin;
  10357. $content = ob_get_contents();
  10358. $this->assertTag(
  10359. array(
  10360. 'id' => 'cipherdata',
  10361. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10362. ),
  10363. $content,
  10364. 'outputs data correctly'
  10365. );
  10366. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10367. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10368. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10369. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10370. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10371. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10372. }
  10373. /**
  10374. * @runInSeparateProcess
  10375. */
  10376. public function testDelete128()
  10377. {
  10378. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10379. $this->_model->create(self::$pasteid, self::$paste);
  10380. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10381. $_GET['pasteid'] = self::$pasteid;
  10382. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10383. ob_start();
  10384. new zerobin;
  10385. $content = ob_get_contents();
  10386. $this->assertTag(
  10387. array(
  10388. 'id' => 'status',
  10389. 'content' => 'Paste was properly deleted'
  10390. ),
  10391. $content,
  10392. 'outputs deleted status correctly'
  10393. );
  10394. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10395. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10396. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10397. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10398. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10399. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10400. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10401. }
  10402. /**
  10403. * @runInSeparateProcess
  10404. */
  10405. public function testView129()
  10406. {
  10407. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10408. ob_start();
  10409. new zerobin;
  10410. $content = ob_get_contents();
  10411. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10412. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10413. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10414. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10415. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10416. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10417. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10418. }
  10419. /**
  10420. * @runInSeparateProcess
  10421. */
  10422. public function testCreate129()
  10423. {
  10424. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10425. $_POST = self::$paste;
  10426. $_SERVER['REMOTE_ADDR'] = '::1';
  10427. sleep(3);
  10428. ob_start();
  10429. new zerobin;
  10430. $content = ob_get_contents();
  10431. $response = json_decode($content, true);
  10432. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  10433. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  10434. }
  10435. /**
  10436. * @runInSeparateProcess
  10437. */
  10438. public function testRead129()
  10439. {
  10440. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10441. $this->_model->create(self::$pasteid, self::$paste);
  10442. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10443. ob_start();
  10444. new zerobin;
  10445. $content = ob_get_contents();
  10446. $this->assertTag(
  10447. array(
  10448. 'id' => 'cipherdata',
  10449. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10450. ),
  10451. $content,
  10452. 'outputs data correctly'
  10453. );
  10454. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10455. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10456. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10457. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10458. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10459. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10460. }
  10461. /**
  10462. * @runInSeparateProcess
  10463. */
  10464. public function testDelete129()
  10465. {
  10466. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10467. $this->_model->create(self::$pasteid, self::$paste);
  10468. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10469. $_GET['pasteid'] = self::$pasteid;
  10470. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10471. ob_start();
  10472. new zerobin;
  10473. $content = ob_get_contents();
  10474. $this->assertTag(
  10475. array(
  10476. 'id' => 'status',
  10477. 'content' => 'Paste was properly deleted'
  10478. ),
  10479. $content,
  10480. 'outputs deleted status correctly'
  10481. );
  10482. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10483. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10484. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10485. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10486. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10487. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10488. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10489. }
  10490. /**
  10491. * @runInSeparateProcess
  10492. */
  10493. public function testView130()
  10494. {
  10495. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10496. ob_start();
  10497. new zerobin;
  10498. $content = ob_get_contents();
  10499. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10500. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10501. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10502. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10503. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10504. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10505. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10506. }
  10507. /**
  10508. * @runInSeparateProcess
  10509. */
  10510. public function testCreate130()
  10511. {
  10512. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10513. $_POST = self::$paste;
  10514. $_SERVER['REMOTE_ADDR'] = '::1';
  10515. ob_start();
  10516. new zerobin;
  10517. $content = ob_get_contents();
  10518. $response = json_decode($content, true);
  10519. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10520. }
  10521. /**
  10522. * @runInSeparateProcess
  10523. */
  10524. public function testRead130()
  10525. {
  10526. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10527. $this->_model->create(self::$pasteid, self::$paste);
  10528. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10529. ob_start();
  10530. new zerobin;
  10531. $content = ob_get_contents();
  10532. $this->assertTag(
  10533. array(
  10534. 'id' => 'cipherdata',
  10535. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10536. ),
  10537. $content,
  10538. 'outputs data correctly'
  10539. );
  10540. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10541. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10542. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10543. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10544. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10545. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10546. }
  10547. /**
  10548. * @runInSeparateProcess
  10549. */
  10550. public function testDelete130()
  10551. {
  10552. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10553. $this->_model->create(self::$pasteid, self::$paste);
  10554. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10555. $_GET['pasteid'] = self::$pasteid;
  10556. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10557. ob_start();
  10558. new zerobin;
  10559. $content = ob_get_contents();
  10560. $this->assertTag(
  10561. array(
  10562. 'id' => 'status',
  10563. 'content' => 'Paste was properly deleted'
  10564. ),
  10565. $content,
  10566. 'outputs deleted status correctly'
  10567. );
  10568. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10569. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10570. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10571. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10572. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10573. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10574. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10575. }
  10576. /**
  10577. * @runInSeparateProcess
  10578. */
  10579. public function testView131()
  10580. {
  10581. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10582. ob_start();
  10583. new zerobin;
  10584. $content = ob_get_contents();
  10585. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10586. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10587. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10588. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10589. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10590. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10591. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10592. }
  10593. /**
  10594. * @runInSeparateProcess
  10595. */
  10596. public function testCreate131()
  10597. {
  10598. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10599. $_POST = self::$paste;
  10600. $_SERVER['REMOTE_ADDR'] = '::1';
  10601. sleep(3);
  10602. ob_start();
  10603. new zerobin;
  10604. $content = ob_get_contents();
  10605. $response = json_decode($content, true);
  10606. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  10607. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  10608. }
  10609. /**
  10610. * @runInSeparateProcess
  10611. */
  10612. public function testRead131()
  10613. {
  10614. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10615. $this->_model->create(self::$pasteid, self::$paste);
  10616. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10617. ob_start();
  10618. new zerobin;
  10619. $content = ob_get_contents();
  10620. $this->assertTag(
  10621. array(
  10622. 'id' => 'cipherdata',
  10623. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10624. ),
  10625. $content,
  10626. 'outputs data correctly'
  10627. );
  10628. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10629. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10630. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10631. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10632. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10633. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10634. }
  10635. /**
  10636. * @runInSeparateProcess
  10637. */
  10638. public function testDelete131()
  10639. {
  10640. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10641. $this->_model->create(self::$pasteid, self::$paste);
  10642. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10643. $_GET['pasteid'] = self::$pasteid;
  10644. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10645. ob_start();
  10646. new zerobin;
  10647. $content = ob_get_contents();
  10648. $this->assertTag(
  10649. array(
  10650. 'id' => 'status',
  10651. 'content' => 'Paste was properly deleted'
  10652. ),
  10653. $content,
  10654. 'outputs deleted status correctly'
  10655. );
  10656. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10657. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10658. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  10659. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  10660. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  10661. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10662. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10663. }
  10664. /**
  10665. * @runInSeparateProcess
  10666. */
  10667. public function testView132()
  10668. {
  10669. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10670. ob_start();
  10671. new zerobin;
  10672. $content = ob_get_contents();
  10673. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10674. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10675. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10676. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10677. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10678. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10679. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10680. }
  10681. /**
  10682. * @runInSeparateProcess
  10683. */
  10684. public function testCreate132()
  10685. {
  10686. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10687. $_POST = self::$paste;
  10688. $_SERVER['REMOTE_ADDR'] = '::1';
  10689. $_POST["opendiscussion"] = "neither 1 nor 0";
  10690. ob_start();
  10691. new zerobin;
  10692. $content = ob_get_contents();
  10693. $response = json_decode($content, true);
  10694. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  10695. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  10696. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10697. }
  10698. /**
  10699. * @runInSeparateProcess
  10700. */
  10701. public function testRead132()
  10702. {
  10703. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10704. $this->_model->create(self::$pasteid, self::$paste);
  10705. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10706. ob_start();
  10707. new zerobin;
  10708. $content = ob_get_contents();
  10709. $this->assertTag(
  10710. array(
  10711. 'id' => 'cipherdata',
  10712. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10713. ),
  10714. $content,
  10715. 'outputs data correctly'
  10716. );
  10717. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10718. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10719. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10720. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10721. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10722. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10723. }
  10724. /**
  10725. * @runInSeparateProcess
  10726. */
  10727. public function testDelete132()
  10728. {
  10729. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10730. $this->_model->create(self::$pasteid, self::$paste);
  10731. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10732. $_GET['pasteid'] = self::$pasteid;
  10733. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10734. ob_start();
  10735. new zerobin;
  10736. $content = ob_get_contents();
  10737. $this->assertTag(
  10738. array(
  10739. 'id' => 'status',
  10740. 'content' => 'Paste was properly deleted'
  10741. ),
  10742. $content,
  10743. 'outputs deleted status correctly'
  10744. );
  10745. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10746. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10747. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10748. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10749. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10750. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10751. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10752. }
  10753. /**
  10754. * @runInSeparateProcess
  10755. */
  10756. public function testView133()
  10757. {
  10758. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10759. ob_start();
  10760. new zerobin;
  10761. $content = ob_get_contents();
  10762. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10763. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10764. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10765. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10766. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10767. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10768. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10769. }
  10770. /**
  10771. * @runInSeparateProcess
  10772. */
  10773. public function testCreate133()
  10774. {
  10775. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10776. $_POST = self::$paste;
  10777. $_SERVER['REMOTE_ADDR'] = '::1';
  10778. sleep(3);
  10779. ob_start();
  10780. new zerobin;
  10781. $content = ob_get_contents();
  10782. $response = json_decode($content, true);
  10783. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  10784. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  10785. }
  10786. /**
  10787. * @runInSeparateProcess
  10788. */
  10789. public function testRead133()
  10790. {
  10791. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10792. $this->_model->create(self::$pasteid, self::$paste);
  10793. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10794. ob_start();
  10795. new zerobin;
  10796. $content = ob_get_contents();
  10797. $this->assertTag(
  10798. array(
  10799. 'id' => 'cipherdata',
  10800. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10801. ),
  10802. $content,
  10803. 'outputs data correctly'
  10804. );
  10805. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10806. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10807. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10808. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10809. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10810. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10811. }
  10812. /**
  10813. * @runInSeparateProcess
  10814. */
  10815. public function testDelete133()
  10816. {
  10817. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10818. $this->_model->create(self::$pasteid, self::$paste);
  10819. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10820. $_GET['pasteid'] = self::$pasteid;
  10821. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10822. ob_start();
  10823. new zerobin;
  10824. $content = ob_get_contents();
  10825. $this->assertTag(
  10826. array(
  10827. 'id' => 'status',
  10828. 'content' => 'Paste was properly deleted'
  10829. ),
  10830. $content,
  10831. 'outputs deleted status correctly'
  10832. );
  10833. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10834. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  10835. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10836. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10837. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10838. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10839. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10840. }
  10841. /**
  10842. * @runInSeparateProcess
  10843. */
  10844. public function testView134()
  10845. {
  10846. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10847. ob_start();
  10848. new zerobin;
  10849. $content = ob_get_contents();
  10850. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10851. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10852. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10853. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10854. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10855. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10856. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10857. }
  10858. /**
  10859. * @runInSeparateProcess
  10860. */
  10861. public function testCreate134()
  10862. {
  10863. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10864. $_POST = self::$paste;
  10865. $_SERVER['REMOTE_ADDR'] = '::1';
  10866. ob_start();
  10867. new zerobin;
  10868. $content = ob_get_contents();
  10869. $response = json_decode($content, true);
  10870. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  10871. }
  10872. /**
  10873. * @runInSeparateProcess
  10874. */
  10875. public function testRead134()
  10876. {
  10877. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10878. $this->_model->create(self::$pasteid, self::$paste);
  10879. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10880. ob_start();
  10881. new zerobin;
  10882. $content = ob_get_contents();
  10883. $this->assertTag(
  10884. array(
  10885. 'id' => 'cipherdata',
  10886. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10887. ),
  10888. $content,
  10889. 'outputs data correctly'
  10890. );
  10891. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10892. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10893. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10894. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10895. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10896. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10897. }
  10898. /**
  10899. * @runInSeparateProcess
  10900. */
  10901. public function testDelete134()
  10902. {
  10903. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10904. $this->_model->create(self::$pasteid, self::$paste);
  10905. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10906. $_GET['pasteid'] = self::$pasteid;
  10907. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10908. ob_start();
  10909. new zerobin;
  10910. $content = ob_get_contents();
  10911. $this->assertTag(
  10912. array(
  10913. 'id' => 'status',
  10914. 'content' => 'Paste was properly deleted'
  10915. ),
  10916. $content,
  10917. 'outputs deleted status correctly'
  10918. );
  10919. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  10920. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10921. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10922. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10923. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10924. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10925. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10926. }
  10927. /**
  10928. * @runInSeparateProcess
  10929. */
  10930. public function testView135()
  10931. {
  10932. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10933. ob_start();
  10934. new zerobin;
  10935. $content = ob_get_contents();
  10936. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10937. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10938. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10939. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10940. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  10941. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10942. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10943. }
  10944. /**
  10945. * @runInSeparateProcess
  10946. */
  10947. public function testCreate135()
  10948. {
  10949. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10950. $_POST = self::$paste;
  10951. $_SERVER['REMOTE_ADDR'] = '::1';
  10952. sleep(3);
  10953. ob_start();
  10954. new zerobin;
  10955. $content = ob_get_contents();
  10956. $response = json_decode($content, true);
  10957. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  10958. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  10959. }
  10960. /**
  10961. * @runInSeparateProcess
  10962. */
  10963. public function testRead135()
  10964. {
  10965. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10966. $this->_model->create(self::$pasteid, self::$paste);
  10967. $_SERVER['QUERY_STRING'] = self::$pasteid;
  10968. ob_start();
  10969. new zerobin;
  10970. $content = ob_get_contents();
  10971. $this->assertTag(
  10972. array(
  10973. 'id' => 'cipherdata',
  10974. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  10975. ),
  10976. $content,
  10977. 'outputs data correctly'
  10978. );
  10979. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  10980. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  10981. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  10982. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  10983. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  10984. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  10985. }
  10986. /**
  10987. * @runInSeparateProcess
  10988. */
  10989. public function testDelete135()
  10990. {
  10991. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  10992. $this->_model->create(self::$pasteid, self::$paste);
  10993. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  10994. $_GET['pasteid'] = self::$pasteid;
  10995. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  10996. ob_start();
  10997. new zerobin;
  10998. $content = ob_get_contents();
  10999. $this->assertTag(
  11000. array(
  11001. 'id' => 'status',
  11002. 'content' => 'Paste was properly deleted'
  11003. ),
  11004. $content,
  11005. 'outputs deleted status correctly'
  11006. );
  11007. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11008. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11009. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11010. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11011. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11012. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11013. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11014. }
  11015. /**
  11016. * @runInSeparateProcess
  11017. */
  11018. public function testView136()
  11019. {
  11020. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11021. ob_start();
  11022. new zerobin;
  11023. $content = ob_get_contents();
  11024. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11025. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11026. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11027. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11028. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11029. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11030. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11031. }
  11032. /**
  11033. * @runInSeparateProcess
  11034. */
  11035. public function testCreate136()
  11036. {
  11037. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11038. $_POST = self::$paste;
  11039. $_SERVER['REMOTE_ADDR'] = '::1';
  11040. $_POST["opendiscussion"] = "neither 1 nor 0";
  11041. ob_start();
  11042. new zerobin;
  11043. $content = ob_get_contents();
  11044. $response = json_decode($content, true);
  11045. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  11046. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  11047. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11048. }
  11049. /**
  11050. * @runInSeparateProcess
  11051. */
  11052. public function testRead136()
  11053. {
  11054. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11055. $this->_model->create(self::$pasteid, self::$paste);
  11056. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11057. ob_start();
  11058. new zerobin;
  11059. $content = ob_get_contents();
  11060. $this->assertTag(
  11061. array(
  11062. 'id' => 'cipherdata',
  11063. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11064. ),
  11065. $content,
  11066. 'outputs data correctly'
  11067. );
  11068. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11069. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11070. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11071. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11072. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11073. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11074. }
  11075. /**
  11076. * @runInSeparateProcess
  11077. */
  11078. public function testDelete136()
  11079. {
  11080. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11081. $this->_model->create(self::$pasteid, self::$paste);
  11082. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11083. $_GET['pasteid'] = self::$pasteid;
  11084. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11085. ob_start();
  11086. new zerobin;
  11087. $content = ob_get_contents();
  11088. $this->assertTag(
  11089. array(
  11090. 'id' => 'status',
  11091. 'content' => 'Paste was properly deleted'
  11092. ),
  11093. $content,
  11094. 'outputs deleted status correctly'
  11095. );
  11096. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11097. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11098. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11099. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11100. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11101. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11102. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11103. }
  11104. /**
  11105. * @runInSeparateProcess
  11106. */
  11107. public function testView137()
  11108. {
  11109. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11110. ob_start();
  11111. new zerobin;
  11112. $content = ob_get_contents();
  11113. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11114. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11115. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11116. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11117. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11118. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11119. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11120. }
  11121. /**
  11122. * @runInSeparateProcess
  11123. */
  11124. public function testCreate137()
  11125. {
  11126. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11127. $_POST = self::$paste;
  11128. $_SERVER['REMOTE_ADDR'] = '::1';
  11129. sleep(3);
  11130. ob_start();
  11131. new zerobin;
  11132. $content = ob_get_contents();
  11133. $response = json_decode($content, true);
  11134. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  11135. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  11136. }
  11137. /**
  11138. * @runInSeparateProcess
  11139. */
  11140. public function testRead137()
  11141. {
  11142. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11143. $this->_model->create(self::$pasteid, self::$paste);
  11144. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11145. ob_start();
  11146. new zerobin;
  11147. $content = ob_get_contents();
  11148. $this->assertTag(
  11149. array(
  11150. 'id' => 'cipherdata',
  11151. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11152. ),
  11153. $content,
  11154. 'outputs data correctly'
  11155. );
  11156. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11157. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11158. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11159. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11160. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11161. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11162. }
  11163. /**
  11164. * @runInSeparateProcess
  11165. */
  11166. public function testDelete137()
  11167. {
  11168. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11169. $this->_model->create(self::$pasteid, self::$paste);
  11170. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11171. $_GET['pasteid'] = self::$pasteid;
  11172. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11173. ob_start();
  11174. new zerobin;
  11175. $content = ob_get_contents();
  11176. $this->assertTag(
  11177. array(
  11178. 'id' => 'status',
  11179. 'content' => 'Paste was properly deleted'
  11180. ),
  11181. $content,
  11182. 'outputs deleted status correctly'
  11183. );
  11184. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11185. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11186. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11187. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11188. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11189. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11190. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11191. }
  11192. /**
  11193. * @runInSeparateProcess
  11194. */
  11195. public function testView138()
  11196. {
  11197. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11198. ob_start();
  11199. new zerobin;
  11200. $content = ob_get_contents();
  11201. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11202. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11203. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11204. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11205. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11206. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11207. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11208. }
  11209. /**
  11210. * @runInSeparateProcess
  11211. */
  11212. public function testCreate138()
  11213. {
  11214. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11215. $_POST = self::$paste;
  11216. $_SERVER['REMOTE_ADDR'] = '::1';
  11217. ob_start();
  11218. new zerobin;
  11219. $content = ob_get_contents();
  11220. $response = json_decode($content, true);
  11221. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11222. }
  11223. /**
  11224. * @runInSeparateProcess
  11225. */
  11226. public function testRead138()
  11227. {
  11228. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11229. $this->_model->create(self::$pasteid, self::$paste);
  11230. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11231. ob_start();
  11232. new zerobin;
  11233. $content = ob_get_contents();
  11234. $this->assertTag(
  11235. array(
  11236. 'id' => 'cipherdata',
  11237. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11238. ),
  11239. $content,
  11240. 'outputs data correctly'
  11241. );
  11242. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11243. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11244. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11245. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11246. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11247. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11248. }
  11249. /**
  11250. * @runInSeparateProcess
  11251. */
  11252. public function testDelete138()
  11253. {
  11254. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11255. $this->_model->create(self::$pasteid, self::$paste);
  11256. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11257. $_GET['pasteid'] = self::$pasteid;
  11258. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11259. ob_start();
  11260. new zerobin;
  11261. $content = ob_get_contents();
  11262. $this->assertTag(
  11263. array(
  11264. 'id' => 'status',
  11265. 'content' => 'Paste was properly deleted'
  11266. ),
  11267. $content,
  11268. 'outputs deleted status correctly'
  11269. );
  11270. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11271. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11272. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11273. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11274. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11275. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11276. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11277. }
  11278. /**
  11279. * @runInSeparateProcess
  11280. */
  11281. public function testView139()
  11282. {
  11283. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11284. ob_start();
  11285. new zerobin;
  11286. $content = ob_get_contents();
  11287. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11288. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11289. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11290. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11291. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11292. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11293. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11294. }
  11295. /**
  11296. * @runInSeparateProcess
  11297. */
  11298. public function testCreate139()
  11299. {
  11300. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11301. $_POST = self::$paste;
  11302. $_SERVER['REMOTE_ADDR'] = '::1';
  11303. sleep(3);
  11304. ob_start();
  11305. new zerobin;
  11306. $content = ob_get_contents();
  11307. $response = json_decode($content, true);
  11308. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  11309. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  11310. }
  11311. /**
  11312. * @runInSeparateProcess
  11313. */
  11314. public function testRead139()
  11315. {
  11316. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11317. $this->_model->create(self::$pasteid, self::$paste);
  11318. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11319. ob_start();
  11320. new zerobin;
  11321. $content = ob_get_contents();
  11322. $this->assertTag(
  11323. array(
  11324. 'id' => 'cipherdata',
  11325. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11326. ),
  11327. $content,
  11328. 'outputs data correctly'
  11329. );
  11330. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11331. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11332. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11333. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11334. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11335. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11336. }
  11337. /**
  11338. * @runInSeparateProcess
  11339. */
  11340. public function testDelete139()
  11341. {
  11342. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11343. $this->_model->create(self::$pasteid, self::$paste);
  11344. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11345. $_GET['pasteid'] = self::$pasteid;
  11346. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11347. ob_start();
  11348. new zerobin;
  11349. $content = ob_get_contents();
  11350. $this->assertTag(
  11351. array(
  11352. 'id' => 'status',
  11353. 'content' => 'Paste was properly deleted'
  11354. ),
  11355. $content,
  11356. 'outputs deleted status correctly'
  11357. );
  11358. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11359. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11360. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11361. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11362. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11363. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11364. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11365. }
  11366. /**
  11367. * @runInSeparateProcess
  11368. */
  11369. public function testView140()
  11370. {
  11371. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11372. ob_start();
  11373. new zerobin;
  11374. $content = ob_get_contents();
  11375. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11376. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11377. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11378. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11379. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11380. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11381. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11382. }
  11383. /**
  11384. * @runInSeparateProcess
  11385. */
  11386. public function testCreate140()
  11387. {
  11388. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11389. $_POST = self::$paste;
  11390. $_SERVER['REMOTE_ADDR'] = '::1';
  11391. $_POST["opendiscussion"] = "neither 1 nor 0";
  11392. ob_start();
  11393. new zerobin;
  11394. $content = ob_get_contents();
  11395. $response = json_decode($content, true);
  11396. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  11397. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  11398. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11399. }
  11400. /**
  11401. * @runInSeparateProcess
  11402. */
  11403. public function testRead140()
  11404. {
  11405. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11406. $this->_model->create(self::$pasteid, self::$paste);
  11407. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11408. ob_start();
  11409. new zerobin;
  11410. $content = ob_get_contents();
  11411. $this->assertTag(
  11412. array(
  11413. 'id' => 'cipherdata',
  11414. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11415. ),
  11416. $content,
  11417. 'outputs data correctly'
  11418. );
  11419. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11420. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11421. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11422. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11423. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11424. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11425. }
  11426. /**
  11427. * @runInSeparateProcess
  11428. */
  11429. public function testDelete140()
  11430. {
  11431. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11432. $this->_model->create(self::$pasteid, self::$paste);
  11433. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11434. $_GET['pasteid'] = self::$pasteid;
  11435. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11436. ob_start();
  11437. new zerobin;
  11438. $content = ob_get_contents();
  11439. $this->assertTag(
  11440. array(
  11441. 'id' => 'status',
  11442. 'content' => 'Paste was properly deleted'
  11443. ),
  11444. $content,
  11445. 'outputs deleted status correctly'
  11446. );
  11447. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11448. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11449. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11450. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11451. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11452. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11453. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11454. }
  11455. /**
  11456. * @runInSeparateProcess
  11457. */
  11458. public function testView141()
  11459. {
  11460. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11461. ob_start();
  11462. new zerobin;
  11463. $content = ob_get_contents();
  11464. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11465. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11466. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11467. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11468. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11469. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11470. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11471. }
  11472. /**
  11473. * @runInSeparateProcess
  11474. */
  11475. public function testCreate141()
  11476. {
  11477. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11478. $_POST = self::$paste;
  11479. $_SERVER['REMOTE_ADDR'] = '::1';
  11480. sleep(3);
  11481. ob_start();
  11482. new zerobin;
  11483. $content = ob_get_contents();
  11484. $response = json_decode($content, true);
  11485. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  11486. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  11487. }
  11488. /**
  11489. * @runInSeparateProcess
  11490. */
  11491. public function testRead141()
  11492. {
  11493. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11494. $this->_model->create(self::$pasteid, self::$paste);
  11495. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11496. ob_start();
  11497. new zerobin;
  11498. $content = ob_get_contents();
  11499. $this->assertTag(
  11500. array(
  11501. 'id' => 'cipherdata',
  11502. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11503. ),
  11504. $content,
  11505. 'outputs data correctly'
  11506. );
  11507. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11508. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11509. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11510. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11511. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11512. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11513. }
  11514. /**
  11515. * @runInSeparateProcess
  11516. */
  11517. public function testDelete141()
  11518. {
  11519. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11520. $this->_model->create(self::$pasteid, self::$paste);
  11521. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11522. $_GET['pasteid'] = self::$pasteid;
  11523. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11524. ob_start();
  11525. new zerobin;
  11526. $content = ob_get_contents();
  11527. $this->assertTag(
  11528. array(
  11529. 'id' => 'status',
  11530. 'content' => 'Paste was properly deleted'
  11531. ),
  11532. $content,
  11533. 'outputs deleted status correctly'
  11534. );
  11535. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11536. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11537. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11538. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11539. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11540. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11541. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11542. }
  11543. /**
  11544. * @runInSeparateProcess
  11545. */
  11546. public function testView142()
  11547. {
  11548. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11549. ob_start();
  11550. new zerobin;
  11551. $content = ob_get_contents();
  11552. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11553. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11554. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11555. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11556. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11557. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11558. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11559. }
  11560. /**
  11561. * @runInSeparateProcess
  11562. */
  11563. public function testCreate142()
  11564. {
  11565. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11566. $_POST = self::$paste;
  11567. $_SERVER['REMOTE_ADDR'] = '::1';
  11568. ob_start();
  11569. new zerobin;
  11570. $content = ob_get_contents();
  11571. $response = json_decode($content, true);
  11572. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11573. }
  11574. /**
  11575. * @runInSeparateProcess
  11576. */
  11577. public function testRead142()
  11578. {
  11579. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11580. $this->_model->create(self::$pasteid, self::$paste);
  11581. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11582. ob_start();
  11583. new zerobin;
  11584. $content = ob_get_contents();
  11585. $this->assertTag(
  11586. array(
  11587. 'id' => 'cipherdata',
  11588. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11589. ),
  11590. $content,
  11591. 'outputs data correctly'
  11592. );
  11593. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11594. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11595. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11596. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11597. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11598. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11599. }
  11600. /**
  11601. * @runInSeparateProcess
  11602. */
  11603. public function testDelete142()
  11604. {
  11605. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11606. $this->_model->create(self::$pasteid, self::$paste);
  11607. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11608. $_GET['pasteid'] = self::$pasteid;
  11609. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11610. ob_start();
  11611. new zerobin;
  11612. $content = ob_get_contents();
  11613. $this->assertTag(
  11614. array(
  11615. 'id' => 'status',
  11616. 'content' => 'Paste was properly deleted'
  11617. ),
  11618. $content,
  11619. 'outputs deleted status correctly'
  11620. );
  11621. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11622. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11623. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11624. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11625. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11626. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11627. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11628. }
  11629. /**
  11630. * @runInSeparateProcess
  11631. */
  11632. public function testView143()
  11633. {
  11634. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11635. ob_start();
  11636. new zerobin;
  11637. $content = ob_get_contents();
  11638. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11639. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11640. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11641. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11642. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  11643. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11644. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11645. }
  11646. /**
  11647. * @runInSeparateProcess
  11648. */
  11649. public function testCreate143()
  11650. {
  11651. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11652. $_POST = self::$paste;
  11653. $_SERVER['REMOTE_ADDR'] = '::1';
  11654. sleep(3);
  11655. ob_start();
  11656. new zerobin;
  11657. $content = ob_get_contents();
  11658. $response = json_decode($content, true);
  11659. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  11660. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  11661. }
  11662. /**
  11663. * @runInSeparateProcess
  11664. */
  11665. public function testRead143()
  11666. {
  11667. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11668. $this->_model->create(self::$pasteid, self::$paste);
  11669. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11670. ob_start();
  11671. new zerobin;
  11672. $content = ob_get_contents();
  11673. $this->assertTag(
  11674. array(
  11675. 'id' => 'cipherdata',
  11676. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11677. ),
  11678. $content,
  11679. 'outputs data correctly'
  11680. );
  11681. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11682. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11683. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11684. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11685. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11686. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11687. }
  11688. /**
  11689. * @runInSeparateProcess
  11690. */
  11691. public function testDelete143()
  11692. {
  11693. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11694. $this->_model->create(self::$pasteid, self::$paste);
  11695. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11696. $_GET['pasteid'] = self::$pasteid;
  11697. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11698. ob_start();
  11699. new zerobin;
  11700. $content = ob_get_contents();
  11701. $this->assertTag(
  11702. array(
  11703. 'id' => 'status',
  11704. 'content' => 'Paste was properly deleted'
  11705. ),
  11706. $content,
  11707. 'outputs deleted status correctly'
  11708. );
  11709. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11710. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11711. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  11712. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  11713. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  11714. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11715. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11716. }
  11717. /**
  11718. * @runInSeparateProcess
  11719. */
  11720. public function testView144()
  11721. {
  11722. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11723. ob_start();
  11724. new zerobin;
  11725. $content = ob_get_contents();
  11726. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11727. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11728. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11729. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11730. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  11731. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11732. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11733. }
  11734. /**
  11735. * @runInSeparateProcess
  11736. */
  11737. public function testCreate144()
  11738. {
  11739. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11740. $_POST = self::$paste;
  11741. $_SERVER['REMOTE_ADDR'] = '::1';
  11742. $_POST["opendiscussion"] = "neither 1 nor 0";
  11743. ob_start();
  11744. new zerobin;
  11745. $content = ob_get_contents();
  11746. $response = json_decode($content, true);
  11747. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  11748. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  11749. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11750. }
  11751. /**
  11752. * @runInSeparateProcess
  11753. */
  11754. public function testRead144()
  11755. {
  11756. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11757. $this->_model->create(self::$pasteid, self::$paste);
  11758. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11759. ob_start();
  11760. new zerobin;
  11761. $content = ob_get_contents();
  11762. $this->assertTag(
  11763. array(
  11764. 'id' => 'cipherdata',
  11765. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11766. ),
  11767. $content,
  11768. 'outputs data correctly'
  11769. );
  11770. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11771. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11772. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11773. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11774. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11775. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11776. }
  11777. /**
  11778. * @runInSeparateProcess
  11779. */
  11780. public function testDelete144()
  11781. {
  11782. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11783. $this->_model->create(self::$pasteid, self::$paste);
  11784. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11785. $_GET['pasteid'] = self::$pasteid;
  11786. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11787. ob_start();
  11788. new zerobin;
  11789. $content = ob_get_contents();
  11790. $this->assertTag(
  11791. array(
  11792. 'id' => 'status',
  11793. 'content' => 'Paste was properly deleted'
  11794. ),
  11795. $content,
  11796. 'outputs deleted status correctly'
  11797. );
  11798. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11799. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11800. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11801. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11802. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11803. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11804. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11805. }
  11806. /**
  11807. * @runInSeparateProcess
  11808. */
  11809. public function testView145()
  11810. {
  11811. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11812. ob_start();
  11813. new zerobin;
  11814. $content = ob_get_contents();
  11815. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11816. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11817. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11818. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11819. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  11820. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11821. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11822. }
  11823. /**
  11824. * @runInSeparateProcess
  11825. */
  11826. public function testCreate145()
  11827. {
  11828. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11829. $_POST = self::$paste;
  11830. $_SERVER['REMOTE_ADDR'] = '::1';
  11831. sleep(3);
  11832. ob_start();
  11833. new zerobin;
  11834. $content = ob_get_contents();
  11835. $response = json_decode($content, true);
  11836. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  11837. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  11838. }
  11839. /**
  11840. * @runInSeparateProcess
  11841. */
  11842. public function testRead145()
  11843. {
  11844. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11845. $this->_model->create(self::$pasteid, self::$paste);
  11846. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11847. ob_start();
  11848. new zerobin;
  11849. $content = ob_get_contents();
  11850. $this->assertTag(
  11851. array(
  11852. 'id' => 'cipherdata',
  11853. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11854. ),
  11855. $content,
  11856. 'outputs data correctly'
  11857. );
  11858. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11859. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11860. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11861. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11862. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11863. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11864. }
  11865. /**
  11866. * @runInSeparateProcess
  11867. */
  11868. public function testDelete145()
  11869. {
  11870. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11871. $this->_model->create(self::$pasteid, self::$paste);
  11872. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11873. $_GET['pasteid'] = self::$pasteid;
  11874. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11875. ob_start();
  11876. new zerobin;
  11877. $content = ob_get_contents();
  11878. $this->assertTag(
  11879. array(
  11880. 'id' => 'status',
  11881. 'content' => 'Paste was properly deleted'
  11882. ),
  11883. $content,
  11884. 'outputs deleted status correctly'
  11885. );
  11886. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11887. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  11888. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11889. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11890. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11891. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11892. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11893. }
  11894. /**
  11895. * @runInSeparateProcess
  11896. */
  11897. public function testView146()
  11898. {
  11899. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11900. ob_start();
  11901. new zerobin;
  11902. $content = ob_get_contents();
  11903. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11904. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11905. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11906. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11907. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  11908. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11909. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11910. }
  11911. /**
  11912. * @runInSeparateProcess
  11913. */
  11914. public function testCreate146()
  11915. {
  11916. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11917. $_POST = self::$paste;
  11918. $_SERVER['REMOTE_ADDR'] = '::1';
  11919. ob_start();
  11920. new zerobin;
  11921. $content = ob_get_contents();
  11922. $response = json_decode($content, true);
  11923. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  11924. }
  11925. /**
  11926. * @runInSeparateProcess
  11927. */
  11928. public function testRead146()
  11929. {
  11930. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11931. $this->_model->create(self::$pasteid, self::$paste);
  11932. $_SERVER['QUERY_STRING'] = self::$pasteid;
  11933. ob_start();
  11934. new zerobin;
  11935. $content = ob_get_contents();
  11936. $this->assertTag(
  11937. array(
  11938. 'id' => 'cipherdata',
  11939. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  11940. ),
  11941. $content,
  11942. 'outputs data correctly'
  11943. );
  11944. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11945. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11946. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11947. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11948. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11949. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11950. }
  11951. /**
  11952. * @runInSeparateProcess
  11953. */
  11954. public function testDelete146()
  11955. {
  11956. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11957. $this->_model->create(self::$pasteid, self::$paste);
  11958. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  11959. $_GET['pasteid'] = self::$pasteid;
  11960. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  11961. ob_start();
  11962. new zerobin;
  11963. $content = ob_get_contents();
  11964. $this->assertTag(
  11965. array(
  11966. 'id' => 'status',
  11967. 'content' => 'Paste was properly deleted'
  11968. ),
  11969. $content,
  11970. 'outputs deleted status correctly'
  11971. );
  11972. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  11973. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11974. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11975. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11976. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11977. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11978. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11979. }
  11980. /**
  11981. * @runInSeparateProcess
  11982. */
  11983. public function testView147()
  11984. {
  11985. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  11986. ob_start();
  11987. new zerobin;
  11988. $content = ob_get_contents();
  11989. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  11990. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  11991. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  11992. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  11993. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  11994. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  11995. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  11996. }
  11997. /**
  11998. * @runInSeparateProcess
  11999. */
  12000. public function testCreate147()
  12001. {
  12002. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12003. $_POST = self::$paste;
  12004. $_SERVER['REMOTE_ADDR'] = '::1';
  12005. sleep(3);
  12006. ob_start();
  12007. new zerobin;
  12008. $content = ob_get_contents();
  12009. $response = json_decode($content, true);
  12010. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12011. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12012. }
  12013. /**
  12014. * @runInSeparateProcess
  12015. */
  12016. public function testRead147()
  12017. {
  12018. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12019. $this->_model->create(self::$pasteid, self::$paste);
  12020. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12021. ob_start();
  12022. new zerobin;
  12023. $content = ob_get_contents();
  12024. $this->assertTag(
  12025. array(
  12026. 'id' => 'cipherdata',
  12027. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12028. ),
  12029. $content,
  12030. 'outputs data correctly'
  12031. );
  12032. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12033. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12034. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12035. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  12036. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12037. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12038. }
  12039. /**
  12040. * @runInSeparateProcess
  12041. */
  12042. public function testDelete147()
  12043. {
  12044. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12045. $this->_model->create(self::$pasteid, self::$paste);
  12046. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12047. $_GET['pasteid'] = self::$pasteid;
  12048. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12049. ob_start();
  12050. new zerobin;
  12051. $content = ob_get_contents();
  12052. $this->assertTag(
  12053. array(
  12054. 'id' => 'status',
  12055. 'content' => 'Paste was properly deleted'
  12056. ),
  12057. $content,
  12058. 'outputs deleted status correctly'
  12059. );
  12060. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12061. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12062. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12063. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12064. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  12065. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12066. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12067. }
  12068. /**
  12069. * @runInSeparateProcess
  12070. */
  12071. public function testView148()
  12072. {
  12073. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12074. ob_start();
  12075. new zerobin;
  12076. $content = ob_get_contents();
  12077. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12078. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12079. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12080. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12081. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12082. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12083. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12084. }
  12085. /**
  12086. * @runInSeparateProcess
  12087. */
  12088. public function testCreate148()
  12089. {
  12090. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12091. $_POST = self::$paste;
  12092. $_SERVER['REMOTE_ADDR'] = '::1';
  12093. $_POST["opendiscussion"] = "neither 1 nor 0";
  12094. ob_start();
  12095. new zerobin;
  12096. $content = ob_get_contents();
  12097. $response = json_decode($content, true);
  12098. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  12099. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  12100. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12101. }
  12102. /**
  12103. * @runInSeparateProcess
  12104. */
  12105. public function testRead148()
  12106. {
  12107. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12108. $this->_model->create(self::$pasteid, self::$paste);
  12109. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12110. ob_start();
  12111. new zerobin;
  12112. $content = ob_get_contents();
  12113. $this->assertTag(
  12114. array(
  12115. 'id' => 'cipherdata',
  12116. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12117. ),
  12118. $content,
  12119. 'outputs data correctly'
  12120. );
  12121. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12122. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12123. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12124. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12125. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12126. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12127. }
  12128. /**
  12129. * @runInSeparateProcess
  12130. */
  12131. public function testDelete148()
  12132. {
  12133. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12134. $this->_model->create(self::$pasteid, self::$paste);
  12135. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12136. $_GET['pasteid'] = self::$pasteid;
  12137. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12138. ob_start();
  12139. new zerobin;
  12140. $content = ob_get_contents();
  12141. $this->assertTag(
  12142. array(
  12143. 'id' => 'status',
  12144. 'content' => 'Paste was properly deleted'
  12145. ),
  12146. $content,
  12147. 'outputs deleted status correctly'
  12148. );
  12149. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12150. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12151. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12152. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12153. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12154. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12155. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12156. }
  12157. /**
  12158. * @runInSeparateProcess
  12159. */
  12160. public function testView149()
  12161. {
  12162. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12163. ob_start();
  12164. new zerobin;
  12165. $content = ob_get_contents();
  12166. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12167. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12168. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12169. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12170. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12171. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12172. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12173. }
  12174. /**
  12175. * @runInSeparateProcess
  12176. */
  12177. public function testCreate149()
  12178. {
  12179. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12180. $_POST = self::$paste;
  12181. $_SERVER['REMOTE_ADDR'] = '::1';
  12182. sleep(3);
  12183. ob_start();
  12184. new zerobin;
  12185. $content = ob_get_contents();
  12186. $response = json_decode($content, true);
  12187. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12188. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12189. }
  12190. /**
  12191. * @runInSeparateProcess
  12192. */
  12193. public function testRead149()
  12194. {
  12195. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12196. $this->_model->create(self::$pasteid, self::$paste);
  12197. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12198. ob_start();
  12199. new zerobin;
  12200. $content = ob_get_contents();
  12201. $this->assertTag(
  12202. array(
  12203. 'id' => 'cipherdata',
  12204. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12205. ),
  12206. $content,
  12207. 'outputs data correctly'
  12208. );
  12209. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12210. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12211. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12212. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12213. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12214. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12215. }
  12216. /**
  12217. * @runInSeparateProcess
  12218. */
  12219. public function testDelete149()
  12220. {
  12221. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12222. $this->_model->create(self::$pasteid, self::$paste);
  12223. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12224. $_GET['pasteid'] = self::$pasteid;
  12225. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12226. ob_start();
  12227. new zerobin;
  12228. $content = ob_get_contents();
  12229. $this->assertTag(
  12230. array(
  12231. 'id' => 'status',
  12232. 'content' => 'Paste was properly deleted'
  12233. ),
  12234. $content,
  12235. 'outputs deleted status correctly'
  12236. );
  12237. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12238. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12239. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12240. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12241. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12242. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12243. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12244. }
  12245. /**
  12246. * @runInSeparateProcess
  12247. */
  12248. public function testView150()
  12249. {
  12250. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12251. ob_start();
  12252. new zerobin;
  12253. $content = ob_get_contents();
  12254. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12255. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12256. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12257. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12258. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12259. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12260. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12261. }
  12262. /**
  12263. * @runInSeparateProcess
  12264. */
  12265. public function testCreate150()
  12266. {
  12267. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12268. $_POST = self::$paste;
  12269. $_SERVER['REMOTE_ADDR'] = '::1';
  12270. ob_start();
  12271. new zerobin;
  12272. $content = ob_get_contents();
  12273. $response = json_decode($content, true);
  12274. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12275. }
  12276. /**
  12277. * @runInSeparateProcess
  12278. */
  12279. public function testRead150()
  12280. {
  12281. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12282. $this->_model->create(self::$pasteid, self::$paste);
  12283. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12284. ob_start();
  12285. new zerobin;
  12286. $content = ob_get_contents();
  12287. $this->assertTag(
  12288. array(
  12289. 'id' => 'cipherdata',
  12290. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12291. ),
  12292. $content,
  12293. 'outputs data correctly'
  12294. );
  12295. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12296. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12297. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12298. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12299. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12300. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12301. }
  12302. /**
  12303. * @runInSeparateProcess
  12304. */
  12305. public function testDelete150()
  12306. {
  12307. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12308. $this->_model->create(self::$pasteid, self::$paste);
  12309. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12310. $_GET['pasteid'] = self::$pasteid;
  12311. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12312. ob_start();
  12313. new zerobin;
  12314. $content = ob_get_contents();
  12315. $this->assertTag(
  12316. array(
  12317. 'id' => 'status',
  12318. 'content' => 'Paste was properly deleted'
  12319. ),
  12320. $content,
  12321. 'outputs deleted status correctly'
  12322. );
  12323. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12324. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12325. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12326. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12327. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12328. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12329. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12330. }
  12331. /**
  12332. * @runInSeparateProcess
  12333. */
  12334. public function testView151()
  12335. {
  12336. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12337. ob_start();
  12338. new zerobin;
  12339. $content = ob_get_contents();
  12340. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12341. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12342. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12343. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12344. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12345. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12346. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12347. }
  12348. /**
  12349. * @runInSeparateProcess
  12350. */
  12351. public function testCreate151()
  12352. {
  12353. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12354. $_POST = self::$paste;
  12355. $_SERVER['REMOTE_ADDR'] = '::1';
  12356. sleep(3);
  12357. ob_start();
  12358. new zerobin;
  12359. $content = ob_get_contents();
  12360. $response = json_decode($content, true);
  12361. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12362. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12363. }
  12364. /**
  12365. * @runInSeparateProcess
  12366. */
  12367. public function testRead151()
  12368. {
  12369. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12370. $this->_model->create(self::$pasteid, self::$paste);
  12371. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12372. ob_start();
  12373. new zerobin;
  12374. $content = ob_get_contents();
  12375. $this->assertTag(
  12376. array(
  12377. 'id' => 'cipherdata',
  12378. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12379. ),
  12380. $content,
  12381. 'outputs data correctly'
  12382. );
  12383. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12384. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12385. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12386. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12387. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12388. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12389. }
  12390. /**
  12391. * @runInSeparateProcess
  12392. */
  12393. public function testDelete151()
  12394. {
  12395. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12396. $this->_model->create(self::$pasteid, self::$paste);
  12397. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12398. $_GET['pasteid'] = self::$pasteid;
  12399. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12400. ob_start();
  12401. new zerobin;
  12402. $content = ob_get_contents();
  12403. $this->assertTag(
  12404. array(
  12405. 'id' => 'status',
  12406. 'content' => 'Paste was properly deleted'
  12407. ),
  12408. $content,
  12409. 'outputs deleted status correctly'
  12410. );
  12411. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12412. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12413. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12414. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12415. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12416. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12417. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12418. }
  12419. /**
  12420. * @runInSeparateProcess
  12421. */
  12422. public function testView152()
  12423. {
  12424. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12425. ob_start();
  12426. new zerobin;
  12427. $content = ob_get_contents();
  12428. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12429. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12430. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12431. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12432. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12433. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12434. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12435. }
  12436. /**
  12437. * @runInSeparateProcess
  12438. */
  12439. public function testCreate152()
  12440. {
  12441. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12442. $_POST = self::$paste;
  12443. $_SERVER['REMOTE_ADDR'] = '::1';
  12444. $_POST["opendiscussion"] = "neither 1 nor 0";
  12445. ob_start();
  12446. new zerobin;
  12447. $content = ob_get_contents();
  12448. $response = json_decode($content, true);
  12449. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  12450. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  12451. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12452. }
  12453. /**
  12454. * @runInSeparateProcess
  12455. */
  12456. public function testRead152()
  12457. {
  12458. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12459. $this->_model->create(self::$pasteid, self::$paste);
  12460. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12461. ob_start();
  12462. new zerobin;
  12463. $content = ob_get_contents();
  12464. $this->assertTag(
  12465. array(
  12466. 'id' => 'cipherdata',
  12467. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12468. ),
  12469. $content,
  12470. 'outputs data correctly'
  12471. );
  12472. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12473. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12474. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12475. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12476. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12477. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12478. }
  12479. /**
  12480. * @runInSeparateProcess
  12481. */
  12482. public function testDelete152()
  12483. {
  12484. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12485. $this->_model->create(self::$pasteid, self::$paste);
  12486. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12487. $_GET['pasteid'] = self::$pasteid;
  12488. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12489. ob_start();
  12490. new zerobin;
  12491. $content = ob_get_contents();
  12492. $this->assertTag(
  12493. array(
  12494. 'id' => 'status',
  12495. 'content' => 'Paste was properly deleted'
  12496. ),
  12497. $content,
  12498. 'outputs deleted status correctly'
  12499. );
  12500. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12501. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12502. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12503. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12504. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12505. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12506. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12507. }
  12508. /**
  12509. * @runInSeparateProcess
  12510. */
  12511. public function testView153()
  12512. {
  12513. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12514. ob_start();
  12515. new zerobin;
  12516. $content = ob_get_contents();
  12517. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12518. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12519. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12520. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12521. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12522. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12523. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12524. }
  12525. /**
  12526. * @runInSeparateProcess
  12527. */
  12528. public function testCreate153()
  12529. {
  12530. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12531. $_POST = self::$paste;
  12532. $_SERVER['REMOTE_ADDR'] = '::1';
  12533. sleep(3);
  12534. ob_start();
  12535. new zerobin;
  12536. $content = ob_get_contents();
  12537. $response = json_decode($content, true);
  12538. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12539. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12540. }
  12541. /**
  12542. * @runInSeparateProcess
  12543. */
  12544. public function testRead153()
  12545. {
  12546. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12547. $this->_model->create(self::$pasteid, self::$paste);
  12548. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12549. ob_start();
  12550. new zerobin;
  12551. $content = ob_get_contents();
  12552. $this->assertTag(
  12553. array(
  12554. 'id' => 'cipherdata',
  12555. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12556. ),
  12557. $content,
  12558. 'outputs data correctly'
  12559. );
  12560. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12561. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12562. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12563. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12564. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12565. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12566. }
  12567. /**
  12568. * @runInSeparateProcess
  12569. */
  12570. public function testDelete153()
  12571. {
  12572. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12573. $this->_model->create(self::$pasteid, self::$paste);
  12574. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12575. $_GET['pasteid'] = self::$pasteid;
  12576. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12577. ob_start();
  12578. new zerobin;
  12579. $content = ob_get_contents();
  12580. $this->assertTag(
  12581. array(
  12582. 'id' => 'status',
  12583. 'content' => 'Paste was properly deleted'
  12584. ),
  12585. $content,
  12586. 'outputs deleted status correctly'
  12587. );
  12588. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12589. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12590. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12591. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12592. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12593. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12594. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12595. }
  12596. /**
  12597. * @runInSeparateProcess
  12598. */
  12599. public function testView154()
  12600. {
  12601. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12602. ob_start();
  12603. new zerobin;
  12604. $content = ob_get_contents();
  12605. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12606. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12607. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12608. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12609. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12610. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12611. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12612. }
  12613. /**
  12614. * @runInSeparateProcess
  12615. */
  12616. public function testCreate154()
  12617. {
  12618. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12619. $_POST = self::$paste;
  12620. $_SERVER['REMOTE_ADDR'] = '::1';
  12621. ob_start();
  12622. new zerobin;
  12623. $content = ob_get_contents();
  12624. $response = json_decode($content, true);
  12625. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12626. }
  12627. /**
  12628. * @runInSeparateProcess
  12629. */
  12630. public function testRead154()
  12631. {
  12632. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12633. $this->_model->create(self::$pasteid, self::$paste);
  12634. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12635. ob_start();
  12636. new zerobin;
  12637. $content = ob_get_contents();
  12638. $this->assertTag(
  12639. array(
  12640. 'id' => 'cipherdata',
  12641. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12642. ),
  12643. $content,
  12644. 'outputs data correctly'
  12645. );
  12646. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12647. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12648. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12649. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12650. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12651. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12652. }
  12653. /**
  12654. * @runInSeparateProcess
  12655. */
  12656. public function testDelete154()
  12657. {
  12658. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12659. $this->_model->create(self::$pasteid, self::$paste);
  12660. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12661. $_GET['pasteid'] = self::$pasteid;
  12662. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12663. ob_start();
  12664. new zerobin;
  12665. $content = ob_get_contents();
  12666. $this->assertTag(
  12667. array(
  12668. 'id' => 'status',
  12669. 'content' => 'Paste was properly deleted'
  12670. ),
  12671. $content,
  12672. 'outputs deleted status correctly'
  12673. );
  12674. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12675. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12676. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12677. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12678. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12679. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12680. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12681. }
  12682. /**
  12683. * @runInSeparateProcess
  12684. */
  12685. public function testView155()
  12686. {
  12687. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12688. ob_start();
  12689. new zerobin;
  12690. $content = ob_get_contents();
  12691. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12692. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12693. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12694. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12695. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12696. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12697. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12698. }
  12699. /**
  12700. * @runInSeparateProcess
  12701. */
  12702. public function testCreate155()
  12703. {
  12704. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12705. $_POST = self::$paste;
  12706. $_SERVER['REMOTE_ADDR'] = '::1';
  12707. sleep(3);
  12708. ob_start();
  12709. new zerobin;
  12710. $content = ob_get_contents();
  12711. $response = json_decode($content, true);
  12712. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12713. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12714. }
  12715. /**
  12716. * @runInSeparateProcess
  12717. */
  12718. public function testRead155()
  12719. {
  12720. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12721. $this->_model->create(self::$pasteid, self::$paste);
  12722. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12723. ob_start();
  12724. new zerobin;
  12725. $content = ob_get_contents();
  12726. $this->assertTag(
  12727. array(
  12728. 'id' => 'cipherdata',
  12729. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12730. ),
  12731. $content,
  12732. 'outputs data correctly'
  12733. );
  12734. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12735. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12736. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12737. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12738. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12739. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12740. }
  12741. /**
  12742. * @runInSeparateProcess
  12743. */
  12744. public function testDelete155()
  12745. {
  12746. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12747. $this->_model->create(self::$pasteid, self::$paste);
  12748. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12749. $_GET['pasteid'] = self::$pasteid;
  12750. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12751. ob_start();
  12752. new zerobin;
  12753. $content = ob_get_contents();
  12754. $this->assertTag(
  12755. array(
  12756. 'id' => 'status',
  12757. 'content' => 'Paste was properly deleted'
  12758. ),
  12759. $content,
  12760. 'outputs deleted status correctly'
  12761. );
  12762. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12763. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12764. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  12765. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  12766. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12767. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12768. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12769. }
  12770. /**
  12771. * @runInSeparateProcess
  12772. */
  12773. public function testView156()
  12774. {
  12775. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12776. ob_start();
  12777. new zerobin;
  12778. $content = ob_get_contents();
  12779. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12780. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12781. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12782. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12783. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12784. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12785. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12786. }
  12787. /**
  12788. * @runInSeparateProcess
  12789. */
  12790. public function testCreate156()
  12791. {
  12792. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12793. $_POST = self::$paste;
  12794. $_SERVER['REMOTE_ADDR'] = '::1';
  12795. $_POST["opendiscussion"] = "neither 1 nor 0";
  12796. ob_start();
  12797. new zerobin;
  12798. $content = ob_get_contents();
  12799. $response = json_decode($content, true);
  12800. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  12801. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  12802. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12803. }
  12804. /**
  12805. * @runInSeparateProcess
  12806. */
  12807. public function testRead156()
  12808. {
  12809. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12810. $this->_model->create(self::$pasteid, self::$paste);
  12811. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12812. ob_start();
  12813. new zerobin;
  12814. $content = ob_get_contents();
  12815. $this->assertTag(
  12816. array(
  12817. 'id' => 'cipherdata',
  12818. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12819. ),
  12820. $content,
  12821. 'outputs data correctly'
  12822. );
  12823. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12824. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12825. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12826. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12827. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12828. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12829. }
  12830. /**
  12831. * @runInSeparateProcess
  12832. */
  12833. public function testDelete156()
  12834. {
  12835. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12836. $this->_model->create(self::$pasteid, self::$paste);
  12837. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12838. $_GET['pasteid'] = self::$pasteid;
  12839. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12840. ob_start();
  12841. new zerobin;
  12842. $content = ob_get_contents();
  12843. $this->assertTag(
  12844. array(
  12845. 'id' => 'status',
  12846. 'content' => 'Paste was properly deleted'
  12847. ),
  12848. $content,
  12849. 'outputs deleted status correctly'
  12850. );
  12851. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12852. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12853. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12854. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12855. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12856. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12857. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12858. }
  12859. /**
  12860. * @runInSeparateProcess
  12861. */
  12862. public function testView157()
  12863. {
  12864. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12865. ob_start();
  12866. new zerobin;
  12867. $content = ob_get_contents();
  12868. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12869. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12870. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12871. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12872. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12873. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12874. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12875. }
  12876. /**
  12877. * @runInSeparateProcess
  12878. */
  12879. public function testCreate157()
  12880. {
  12881. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12882. $_POST = self::$paste;
  12883. $_SERVER['REMOTE_ADDR'] = '::1';
  12884. sleep(3);
  12885. ob_start();
  12886. new zerobin;
  12887. $content = ob_get_contents();
  12888. $response = json_decode($content, true);
  12889. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  12890. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  12891. }
  12892. /**
  12893. * @runInSeparateProcess
  12894. */
  12895. public function testRead157()
  12896. {
  12897. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12898. $this->_model->create(self::$pasteid, self::$paste);
  12899. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12900. ob_start();
  12901. new zerobin;
  12902. $content = ob_get_contents();
  12903. $this->assertTag(
  12904. array(
  12905. 'id' => 'cipherdata',
  12906. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12907. ),
  12908. $content,
  12909. 'outputs data correctly'
  12910. );
  12911. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12912. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12913. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12914. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12915. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12916. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12917. }
  12918. /**
  12919. * @runInSeparateProcess
  12920. */
  12921. public function testDelete157()
  12922. {
  12923. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12924. $this->_model->create(self::$pasteid, self::$paste);
  12925. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  12926. $_GET['pasteid'] = self::$pasteid;
  12927. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  12928. ob_start();
  12929. new zerobin;
  12930. $content = ob_get_contents();
  12931. $this->assertTag(
  12932. array(
  12933. 'id' => 'status',
  12934. 'content' => 'Paste was properly deleted'
  12935. ),
  12936. $content,
  12937. 'outputs deleted status correctly'
  12938. );
  12939. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  12940. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  12941. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12942. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12943. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12944. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12945. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12946. }
  12947. /**
  12948. * @runInSeparateProcess
  12949. */
  12950. public function testView158()
  12951. {
  12952. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12953. ob_start();
  12954. new zerobin;
  12955. $content = ob_get_contents();
  12956. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12957. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12958. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  12959. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  12960. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  12961. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  12962. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  12963. }
  12964. /**
  12965. * @runInSeparateProcess
  12966. */
  12967. public function testCreate158()
  12968. {
  12969. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12970. $_POST = self::$paste;
  12971. $_SERVER['REMOTE_ADDR'] = '::1';
  12972. ob_start();
  12973. new zerobin;
  12974. $content = ob_get_contents();
  12975. $response = json_decode($content, true);
  12976. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  12977. }
  12978. /**
  12979. * @runInSeparateProcess
  12980. */
  12981. public function testRead158()
  12982. {
  12983. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  12984. $this->_model->create(self::$pasteid, self::$paste);
  12985. $_SERVER['QUERY_STRING'] = self::$pasteid;
  12986. ob_start();
  12987. new zerobin;
  12988. $content = ob_get_contents();
  12989. $this->assertTag(
  12990. array(
  12991. 'id' => 'cipherdata',
  12992. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  12993. ),
  12994. $content,
  12995. 'outputs data correctly'
  12996. );
  12997. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  12998. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  12999. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13000. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13001. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  13002. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  13003. }
  13004. /**
  13005. * @runInSeparateProcess
  13006. */
  13007. public function testDelete158()
  13008. {
  13009. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13010. $this->_model->create(self::$pasteid, self::$paste);
  13011. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13012. $_GET['pasteid'] = self::$pasteid;
  13013. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13014. ob_start();
  13015. new zerobin;
  13016. $content = ob_get_contents();
  13017. $this->assertTag(
  13018. array(
  13019. 'id' => 'status',
  13020. 'content' => 'Paste was properly deleted'
  13021. ),
  13022. $content,
  13023. 'outputs deleted status correctly'
  13024. );
  13025. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13026. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13027. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13028. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13029. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13030. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  13031. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  13032. }
  13033. /**
  13034. * @runInSeparateProcess
  13035. */
  13036. public function testView159()
  13037. {
  13038. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13039. ob_start();
  13040. new zerobin;
  13041. $content = ob_get_contents();
  13042. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13043. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13044. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13045. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13046. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  13047. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  13048. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  13049. }
  13050. /**
  13051. * @runInSeparateProcess
  13052. */
  13053. public function testCreate159()
  13054. {
  13055. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13056. $_POST = self::$paste;
  13057. $_SERVER['REMOTE_ADDR'] = '::1';
  13058. sleep(3);
  13059. ob_start();
  13060. new zerobin;
  13061. $content = ob_get_contents();
  13062. $response = json_decode($content, true);
  13063. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13064. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13065. }
  13066. /**
  13067. * @runInSeparateProcess
  13068. */
  13069. public function testRead159()
  13070. {
  13071. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13072. $this->_model->create(self::$pasteid, self::$paste);
  13073. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13074. ob_start();
  13075. new zerobin;
  13076. $content = ob_get_contents();
  13077. $this->assertTag(
  13078. array(
  13079. 'id' => 'cipherdata',
  13080. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13081. ),
  13082. $content,
  13083. 'outputs data correctly'
  13084. );
  13085. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13086. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13087. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13088. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13089. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  13090. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  13091. }
  13092. /**
  13093. * @runInSeparateProcess
  13094. */
  13095. public function testDelete159()
  13096. {
  13097. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'page', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13098. $this->_model->create(self::$pasteid, self::$paste);
  13099. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13100. $_GET['pasteid'] = self::$pasteid;
  13101. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13102. ob_start();
  13103. new zerobin;
  13104. $content = ob_get_contents();
  13105. $this->assertTag(
  13106. array(
  13107. 'id' => 'status',
  13108. 'content' => 'Paste was properly deleted'
  13109. ),
  13110. $content,
  13111. 'outputs deleted status correctly'
  13112. );
  13113. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13114. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13115. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13116. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13117. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13118. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin\\.css#')), $content, 'outputs "page" stylesheet correctly');
  13119. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'removes "bootstrap" stylesheet correctly');
  13120. }
  13121. /**
  13122. * @runInSeparateProcess
  13123. */
  13124. public function testView160()
  13125. {
  13126. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13127. ob_start();
  13128. new zerobin;
  13129. $content = ob_get_contents();
  13130. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13131. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13132. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13133. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13134. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13135. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13136. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13137. }
  13138. /**
  13139. * @runInSeparateProcess
  13140. */
  13141. public function testCreate160()
  13142. {
  13143. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13144. $_POST = self::$paste;
  13145. $_SERVER['REMOTE_ADDR'] = '::1';
  13146. $_POST["opendiscussion"] = "neither 1 nor 0";
  13147. ob_start();
  13148. new zerobin;
  13149. $content = ob_get_contents();
  13150. $response = json_decode($content, true);
  13151. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  13152. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  13153. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  13154. }
  13155. /**
  13156. * @runInSeparateProcess
  13157. */
  13158. public function testRead160()
  13159. {
  13160. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13161. $this->_model->create(self::$pasteid, self::$paste);
  13162. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13163. ob_start();
  13164. new zerobin;
  13165. $content = ob_get_contents();
  13166. $this->assertTag(
  13167. array(
  13168. 'id' => 'cipherdata',
  13169. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13170. ),
  13171. $content,
  13172. 'outputs data correctly'
  13173. );
  13174. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13175. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13176. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13177. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13178. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13179. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13180. }
  13181. /**
  13182. * @runInSeparateProcess
  13183. */
  13184. public function testDelete160()
  13185. {
  13186. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13187. $this->_model->create(self::$pasteid, self::$paste);
  13188. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13189. $_GET['pasteid'] = self::$pasteid;
  13190. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13191. ob_start();
  13192. new zerobin;
  13193. $content = ob_get_contents();
  13194. $this->assertTag(
  13195. array(
  13196. 'id' => 'status',
  13197. 'content' => 'Paste was properly deleted'
  13198. ),
  13199. $content,
  13200. 'outputs deleted status correctly'
  13201. );
  13202. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13203. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13204. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13205. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13206. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13207. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13208. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13209. }
  13210. /**
  13211. * @runInSeparateProcess
  13212. */
  13213. public function testView161()
  13214. {
  13215. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13216. ob_start();
  13217. new zerobin;
  13218. $content = ob_get_contents();
  13219. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13220. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13221. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13222. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13223. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13224. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13225. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13226. }
  13227. /**
  13228. * @runInSeparateProcess
  13229. */
  13230. public function testCreate161()
  13231. {
  13232. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13233. $_POST = self::$paste;
  13234. $_SERVER['REMOTE_ADDR'] = '::1';
  13235. sleep(3);
  13236. ob_start();
  13237. new zerobin;
  13238. $content = ob_get_contents();
  13239. $response = json_decode($content, true);
  13240. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13241. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13242. }
  13243. /**
  13244. * @runInSeparateProcess
  13245. */
  13246. public function testRead161()
  13247. {
  13248. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13249. $this->_model->create(self::$pasteid, self::$paste);
  13250. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13251. ob_start();
  13252. new zerobin;
  13253. $content = ob_get_contents();
  13254. $this->assertTag(
  13255. array(
  13256. 'id' => 'cipherdata',
  13257. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13258. ),
  13259. $content,
  13260. 'outputs data correctly'
  13261. );
  13262. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13263. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13264. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13265. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13266. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13267. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13268. }
  13269. /**
  13270. * @runInSeparateProcess
  13271. */
  13272. public function testDelete161()
  13273. {
  13274. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13275. $this->_model->create(self::$pasteid, self::$paste);
  13276. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13277. $_GET['pasteid'] = self::$pasteid;
  13278. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13279. ob_start();
  13280. new zerobin;
  13281. $content = ob_get_contents();
  13282. $this->assertTag(
  13283. array(
  13284. 'id' => 'status',
  13285. 'content' => 'Paste was properly deleted'
  13286. ),
  13287. $content,
  13288. 'outputs deleted status correctly'
  13289. );
  13290. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13291. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13292. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13293. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13294. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13295. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13296. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13297. }
  13298. /**
  13299. * @runInSeparateProcess
  13300. */
  13301. public function testView162()
  13302. {
  13303. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13304. ob_start();
  13305. new zerobin;
  13306. $content = ob_get_contents();
  13307. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13308. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13309. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13310. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13311. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13312. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13313. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13314. }
  13315. /**
  13316. * @runInSeparateProcess
  13317. */
  13318. public function testCreate162()
  13319. {
  13320. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13321. $_POST = self::$paste;
  13322. $_SERVER['REMOTE_ADDR'] = '::1';
  13323. ob_start();
  13324. new zerobin;
  13325. $content = ob_get_contents();
  13326. $response = json_decode($content, true);
  13327. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  13328. }
  13329. /**
  13330. * @runInSeparateProcess
  13331. */
  13332. public function testRead162()
  13333. {
  13334. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13335. $this->_model->create(self::$pasteid, self::$paste);
  13336. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13337. ob_start();
  13338. new zerobin;
  13339. $content = ob_get_contents();
  13340. $this->assertTag(
  13341. array(
  13342. 'id' => 'cipherdata',
  13343. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13344. ),
  13345. $content,
  13346. 'outputs data correctly'
  13347. );
  13348. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13349. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13350. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13351. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13352. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13353. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13354. }
  13355. /**
  13356. * @runInSeparateProcess
  13357. */
  13358. public function testDelete162()
  13359. {
  13360. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13361. $this->_model->create(self::$pasteid, self::$paste);
  13362. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13363. $_GET['pasteid'] = self::$pasteid;
  13364. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13365. ob_start();
  13366. new zerobin;
  13367. $content = ob_get_contents();
  13368. $this->assertTag(
  13369. array(
  13370. 'id' => 'status',
  13371. 'content' => 'Paste was properly deleted'
  13372. ),
  13373. $content,
  13374. 'outputs deleted status correctly'
  13375. );
  13376. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13377. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13378. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13379. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13380. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13381. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13382. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13383. }
  13384. /**
  13385. * @runInSeparateProcess
  13386. */
  13387. public function testView163()
  13388. {
  13389. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13390. ob_start();
  13391. new zerobin;
  13392. $content = ob_get_contents();
  13393. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13394. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13395. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13396. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13397. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13398. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13399. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13400. }
  13401. /**
  13402. * @runInSeparateProcess
  13403. */
  13404. public function testCreate163()
  13405. {
  13406. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13407. $_POST = self::$paste;
  13408. $_SERVER['REMOTE_ADDR'] = '::1';
  13409. sleep(3);
  13410. ob_start();
  13411. new zerobin;
  13412. $content = ob_get_contents();
  13413. $response = json_decode($content, true);
  13414. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13415. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13416. }
  13417. /**
  13418. * @runInSeparateProcess
  13419. */
  13420. public function testRead163()
  13421. {
  13422. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13423. $this->_model->create(self::$pasteid, self::$paste);
  13424. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13425. ob_start();
  13426. new zerobin;
  13427. $content = ob_get_contents();
  13428. $this->assertTag(
  13429. array(
  13430. 'id' => 'cipherdata',
  13431. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13432. ),
  13433. $content,
  13434. 'outputs data correctly'
  13435. );
  13436. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13437. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13438. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13439. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13440. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13441. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13442. }
  13443. /**
  13444. * @runInSeparateProcess
  13445. */
  13446. public function testDelete163()
  13447. {
  13448. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13449. $this->_model->create(self::$pasteid, self::$paste);
  13450. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13451. $_GET['pasteid'] = self::$pasteid;
  13452. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13453. ob_start();
  13454. new zerobin;
  13455. $content = ob_get_contents();
  13456. $this->assertTag(
  13457. array(
  13458. 'id' => 'status',
  13459. 'content' => 'Paste was properly deleted'
  13460. ),
  13461. $content,
  13462. 'outputs deleted status correctly'
  13463. );
  13464. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13465. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13466. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13467. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13468. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  13469. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13470. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13471. }
  13472. /**
  13473. * @runInSeparateProcess
  13474. */
  13475. public function testView164()
  13476. {
  13477. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13478. ob_start();
  13479. new zerobin;
  13480. $content = ob_get_contents();
  13481. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13482. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13483. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13484. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13485. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13486. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13487. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13488. }
  13489. /**
  13490. * @runInSeparateProcess
  13491. */
  13492. public function testCreate164()
  13493. {
  13494. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13495. $_POST = self::$paste;
  13496. $_SERVER['REMOTE_ADDR'] = '::1';
  13497. $_POST["opendiscussion"] = "neither 1 nor 0";
  13498. ob_start();
  13499. new zerobin;
  13500. $content = ob_get_contents();
  13501. $response = json_decode($content, true);
  13502. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  13503. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  13504. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  13505. }
  13506. /**
  13507. * @runInSeparateProcess
  13508. */
  13509. public function testRead164()
  13510. {
  13511. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13512. $this->_model->create(self::$pasteid, self::$paste);
  13513. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13514. ob_start();
  13515. new zerobin;
  13516. $content = ob_get_contents();
  13517. $this->assertTag(
  13518. array(
  13519. 'id' => 'cipherdata',
  13520. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13521. ),
  13522. $content,
  13523. 'outputs data correctly'
  13524. );
  13525. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13526. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13527. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13528. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13529. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13530. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13531. }
  13532. /**
  13533. * @runInSeparateProcess
  13534. */
  13535. public function testDelete164()
  13536. {
  13537. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13538. $this->_model->create(self::$pasteid, self::$paste);
  13539. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13540. $_GET['pasteid'] = self::$pasteid;
  13541. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13542. ob_start();
  13543. new zerobin;
  13544. $content = ob_get_contents();
  13545. $this->assertTag(
  13546. array(
  13547. 'id' => 'status',
  13548. 'content' => 'Paste was properly deleted'
  13549. ),
  13550. $content,
  13551. 'outputs deleted status correctly'
  13552. );
  13553. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13554. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13555. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13556. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13557. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13558. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13559. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13560. }
  13561. /**
  13562. * @runInSeparateProcess
  13563. */
  13564. public function testView165()
  13565. {
  13566. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13567. ob_start();
  13568. new zerobin;
  13569. $content = ob_get_contents();
  13570. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13571. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13572. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13573. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13574. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13575. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13576. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13577. }
  13578. /**
  13579. * @runInSeparateProcess
  13580. */
  13581. public function testCreate165()
  13582. {
  13583. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13584. $_POST = self::$paste;
  13585. $_SERVER['REMOTE_ADDR'] = '::1';
  13586. sleep(3);
  13587. ob_start();
  13588. new zerobin;
  13589. $content = ob_get_contents();
  13590. $response = json_decode($content, true);
  13591. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13592. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13593. }
  13594. /**
  13595. * @runInSeparateProcess
  13596. */
  13597. public function testRead165()
  13598. {
  13599. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13600. $this->_model->create(self::$pasteid, self::$paste);
  13601. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13602. ob_start();
  13603. new zerobin;
  13604. $content = ob_get_contents();
  13605. $this->assertTag(
  13606. array(
  13607. 'id' => 'cipherdata',
  13608. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13609. ),
  13610. $content,
  13611. 'outputs data correctly'
  13612. );
  13613. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13614. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13615. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13616. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13617. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13618. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13619. }
  13620. /**
  13621. * @runInSeparateProcess
  13622. */
  13623. public function testDelete165()
  13624. {
  13625. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13626. $this->_model->create(self::$pasteid, self::$paste);
  13627. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13628. $_GET['pasteid'] = self::$pasteid;
  13629. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13630. ob_start();
  13631. new zerobin;
  13632. $content = ob_get_contents();
  13633. $this->assertTag(
  13634. array(
  13635. 'id' => 'status',
  13636. 'content' => 'Paste was properly deleted'
  13637. ),
  13638. $content,
  13639. 'outputs deleted status correctly'
  13640. );
  13641. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13642. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13643. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13644. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13645. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13646. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13647. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13648. }
  13649. /**
  13650. * @runInSeparateProcess
  13651. */
  13652. public function testView166()
  13653. {
  13654. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13655. ob_start();
  13656. new zerobin;
  13657. $content = ob_get_contents();
  13658. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13659. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13660. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13661. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13662. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13663. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13664. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13665. }
  13666. /**
  13667. * @runInSeparateProcess
  13668. */
  13669. public function testCreate166()
  13670. {
  13671. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13672. $_POST = self::$paste;
  13673. $_SERVER['REMOTE_ADDR'] = '::1';
  13674. ob_start();
  13675. new zerobin;
  13676. $content = ob_get_contents();
  13677. $response = json_decode($content, true);
  13678. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  13679. }
  13680. /**
  13681. * @runInSeparateProcess
  13682. */
  13683. public function testRead166()
  13684. {
  13685. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13686. $this->_model->create(self::$pasteid, self::$paste);
  13687. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13688. ob_start();
  13689. new zerobin;
  13690. $content = ob_get_contents();
  13691. $this->assertTag(
  13692. array(
  13693. 'id' => 'cipherdata',
  13694. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13695. ),
  13696. $content,
  13697. 'outputs data correctly'
  13698. );
  13699. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13700. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13701. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13702. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13703. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13704. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13705. }
  13706. /**
  13707. * @runInSeparateProcess
  13708. */
  13709. public function testDelete166()
  13710. {
  13711. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13712. $this->_model->create(self::$pasteid, self::$paste);
  13713. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13714. $_GET['pasteid'] = self::$pasteid;
  13715. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13716. ob_start();
  13717. new zerobin;
  13718. $content = ob_get_contents();
  13719. $this->assertTag(
  13720. array(
  13721. 'id' => 'status',
  13722. 'content' => 'Paste was properly deleted'
  13723. ),
  13724. $content,
  13725. 'outputs deleted status correctly'
  13726. );
  13727. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13728. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13729. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13730. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13731. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13732. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13733. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13734. }
  13735. /**
  13736. * @runInSeparateProcess
  13737. */
  13738. public function testView167()
  13739. {
  13740. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13741. ob_start();
  13742. new zerobin;
  13743. $content = ob_get_contents();
  13744. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13745. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13746. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13747. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13748. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13749. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13750. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13751. }
  13752. /**
  13753. * @runInSeparateProcess
  13754. */
  13755. public function testCreate167()
  13756. {
  13757. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13758. $_POST = self::$paste;
  13759. $_SERVER['REMOTE_ADDR'] = '::1';
  13760. sleep(3);
  13761. ob_start();
  13762. new zerobin;
  13763. $content = ob_get_contents();
  13764. $response = json_decode($content, true);
  13765. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13766. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13767. }
  13768. /**
  13769. * @runInSeparateProcess
  13770. */
  13771. public function testRead167()
  13772. {
  13773. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13774. $this->_model->create(self::$pasteid, self::$paste);
  13775. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13776. ob_start();
  13777. new zerobin;
  13778. $content = ob_get_contents();
  13779. $this->assertTag(
  13780. array(
  13781. 'id' => 'cipherdata',
  13782. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13783. ),
  13784. $content,
  13785. 'outputs data correctly'
  13786. );
  13787. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13788. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13789. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13790. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13791. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13792. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13793. }
  13794. /**
  13795. * @runInSeparateProcess
  13796. */
  13797. public function testDelete167()
  13798. {
  13799. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13800. $this->_model->create(self::$pasteid, self::$paste);
  13801. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13802. $_GET['pasteid'] = self::$pasteid;
  13803. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13804. ob_start();
  13805. new zerobin;
  13806. $content = ob_get_contents();
  13807. $this->assertTag(
  13808. array(
  13809. 'id' => 'status',
  13810. 'content' => 'Paste was properly deleted'
  13811. ),
  13812. $content,
  13813. 'outputs deleted status correctly'
  13814. );
  13815. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13816. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  13817. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  13818. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  13819. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13820. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13821. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13822. }
  13823. /**
  13824. * @runInSeparateProcess
  13825. */
  13826. public function testView168()
  13827. {
  13828. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13829. ob_start();
  13830. new zerobin;
  13831. $content = ob_get_contents();
  13832. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13833. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13834. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13835. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13836. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13837. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13838. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13839. }
  13840. /**
  13841. * @runInSeparateProcess
  13842. */
  13843. public function testCreate168()
  13844. {
  13845. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13846. $_POST = self::$paste;
  13847. $_SERVER['REMOTE_ADDR'] = '::1';
  13848. $_POST["opendiscussion"] = "neither 1 nor 0";
  13849. ob_start();
  13850. new zerobin;
  13851. $content = ob_get_contents();
  13852. $response = json_decode($content, true);
  13853. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  13854. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  13855. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  13856. }
  13857. /**
  13858. * @runInSeparateProcess
  13859. */
  13860. public function testRead168()
  13861. {
  13862. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13863. $this->_model->create(self::$pasteid, self::$paste);
  13864. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13865. ob_start();
  13866. new zerobin;
  13867. $content = ob_get_contents();
  13868. $this->assertTag(
  13869. array(
  13870. 'id' => 'cipherdata',
  13871. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13872. ),
  13873. $content,
  13874. 'outputs data correctly'
  13875. );
  13876. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13877. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13878. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13879. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13880. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13881. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13882. }
  13883. /**
  13884. * @runInSeparateProcess
  13885. */
  13886. public function testDelete168()
  13887. {
  13888. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13889. $this->_model->create(self::$pasteid, self::$paste);
  13890. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13891. $_GET['pasteid'] = self::$pasteid;
  13892. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13893. ob_start();
  13894. new zerobin;
  13895. $content = ob_get_contents();
  13896. $this->assertTag(
  13897. array(
  13898. 'id' => 'status',
  13899. 'content' => 'Paste was properly deleted'
  13900. ),
  13901. $content,
  13902. 'outputs deleted status correctly'
  13903. );
  13904. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13905. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13906. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13907. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13908. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13909. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13910. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13911. }
  13912. /**
  13913. * @runInSeparateProcess
  13914. */
  13915. public function testView169()
  13916. {
  13917. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13918. ob_start();
  13919. new zerobin;
  13920. $content = ob_get_contents();
  13921. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13922. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13923. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13924. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13925. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  13926. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13927. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13928. }
  13929. /**
  13930. * @runInSeparateProcess
  13931. */
  13932. public function testCreate169()
  13933. {
  13934. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13935. $_POST = self::$paste;
  13936. $_SERVER['REMOTE_ADDR'] = '::1';
  13937. sleep(3);
  13938. ob_start();
  13939. new zerobin;
  13940. $content = ob_get_contents();
  13941. $response = json_decode($content, true);
  13942. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  13943. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  13944. }
  13945. /**
  13946. * @runInSeparateProcess
  13947. */
  13948. public function testRead169()
  13949. {
  13950. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13951. $this->_model->create(self::$pasteid, self::$paste);
  13952. $_SERVER['QUERY_STRING'] = self::$pasteid;
  13953. ob_start();
  13954. new zerobin;
  13955. $content = ob_get_contents();
  13956. $this->assertTag(
  13957. array(
  13958. 'id' => 'cipherdata',
  13959. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  13960. ),
  13961. $content,
  13962. 'outputs data correctly'
  13963. );
  13964. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13965. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13966. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13967. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13968. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13969. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13970. }
  13971. /**
  13972. * @runInSeparateProcess
  13973. */
  13974. public function testDelete169()
  13975. {
  13976. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  13977. $this->_model->create(self::$pasteid, self::$paste);
  13978. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  13979. $_GET['pasteid'] = self::$pasteid;
  13980. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  13981. ob_start();
  13982. new zerobin;
  13983. $content = ob_get_contents();
  13984. $this->assertTag(
  13985. array(
  13986. 'id' => 'status',
  13987. 'content' => 'Paste was properly deleted'
  13988. ),
  13989. $content,
  13990. 'outputs deleted status correctly'
  13991. );
  13992. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  13993. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  13994. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  13995. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  13996. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  13997. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  13998. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  13999. }
  14000. /**
  14001. * @runInSeparateProcess
  14002. */
  14003. public function testView170()
  14004. {
  14005. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14006. ob_start();
  14007. new zerobin;
  14008. $content = ob_get_contents();
  14009. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14010. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14011. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14012. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14013. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14014. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14015. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14016. }
  14017. /**
  14018. * @runInSeparateProcess
  14019. */
  14020. public function testCreate170()
  14021. {
  14022. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14023. $_POST = self::$paste;
  14024. $_SERVER['REMOTE_ADDR'] = '::1';
  14025. ob_start();
  14026. new zerobin;
  14027. $content = ob_get_contents();
  14028. $response = json_decode($content, true);
  14029. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14030. }
  14031. /**
  14032. * @runInSeparateProcess
  14033. */
  14034. public function testRead170()
  14035. {
  14036. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14037. $this->_model->create(self::$pasteid, self::$paste);
  14038. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14039. ob_start();
  14040. new zerobin;
  14041. $content = ob_get_contents();
  14042. $this->assertTag(
  14043. array(
  14044. 'id' => 'cipherdata',
  14045. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14046. ),
  14047. $content,
  14048. 'outputs data correctly'
  14049. );
  14050. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14051. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14052. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14053. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14054. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14055. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14056. }
  14057. /**
  14058. * @runInSeparateProcess
  14059. */
  14060. public function testDelete170()
  14061. {
  14062. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14063. $this->_model->create(self::$pasteid, self::$paste);
  14064. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14065. $_GET['pasteid'] = self::$pasteid;
  14066. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14067. ob_start();
  14068. new zerobin;
  14069. $content = ob_get_contents();
  14070. $this->assertTag(
  14071. array(
  14072. 'id' => 'status',
  14073. 'content' => 'Paste was properly deleted'
  14074. ),
  14075. $content,
  14076. 'outputs deleted status correctly'
  14077. );
  14078. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14079. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14080. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14081. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14082. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14083. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14084. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14085. }
  14086. /**
  14087. * @runInSeparateProcess
  14088. */
  14089. public function testView171()
  14090. {
  14091. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14092. ob_start();
  14093. new zerobin;
  14094. $content = ob_get_contents();
  14095. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14096. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14097. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14098. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14099. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14100. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14101. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14102. }
  14103. /**
  14104. * @runInSeparateProcess
  14105. */
  14106. public function testCreate171()
  14107. {
  14108. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14109. $_POST = self::$paste;
  14110. $_SERVER['REMOTE_ADDR'] = '::1';
  14111. sleep(3);
  14112. ob_start();
  14113. new zerobin;
  14114. $content = ob_get_contents();
  14115. $response = json_decode($content, true);
  14116. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14117. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14118. }
  14119. /**
  14120. * @runInSeparateProcess
  14121. */
  14122. public function testRead171()
  14123. {
  14124. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14125. $this->_model->create(self::$pasteid, self::$paste);
  14126. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14127. ob_start();
  14128. new zerobin;
  14129. $content = ob_get_contents();
  14130. $this->assertTag(
  14131. array(
  14132. 'id' => 'cipherdata',
  14133. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14134. ),
  14135. $content,
  14136. 'outputs data correctly'
  14137. );
  14138. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14139. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14140. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14141. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14142. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14143. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14144. }
  14145. /**
  14146. * @runInSeparateProcess
  14147. */
  14148. public function testDelete171()
  14149. {
  14150. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14151. $this->_model->create(self::$pasteid, self::$paste);
  14152. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14153. $_GET['pasteid'] = self::$pasteid;
  14154. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14155. ob_start();
  14156. new zerobin;
  14157. $content = ob_get_contents();
  14158. $this->assertTag(
  14159. array(
  14160. 'id' => 'status',
  14161. 'content' => 'Paste was properly deleted'
  14162. ),
  14163. $content,
  14164. 'outputs deleted status correctly'
  14165. );
  14166. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14167. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14168. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14169. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14170. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14171. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14172. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14173. }
  14174. /**
  14175. * @runInSeparateProcess
  14176. */
  14177. public function testView172()
  14178. {
  14179. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14180. ob_start();
  14181. new zerobin;
  14182. $content = ob_get_contents();
  14183. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14184. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14185. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14186. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14187. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14188. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14189. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14190. }
  14191. /**
  14192. * @runInSeparateProcess
  14193. */
  14194. public function testCreate172()
  14195. {
  14196. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14197. $_POST = self::$paste;
  14198. $_SERVER['REMOTE_ADDR'] = '::1';
  14199. $_POST["opendiscussion"] = "neither 1 nor 0";
  14200. ob_start();
  14201. new zerobin;
  14202. $content = ob_get_contents();
  14203. $response = json_decode($content, true);
  14204. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  14205. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  14206. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14207. }
  14208. /**
  14209. * @runInSeparateProcess
  14210. */
  14211. public function testRead172()
  14212. {
  14213. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14214. $this->_model->create(self::$pasteid, self::$paste);
  14215. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14216. ob_start();
  14217. new zerobin;
  14218. $content = ob_get_contents();
  14219. $this->assertTag(
  14220. array(
  14221. 'id' => 'cipherdata',
  14222. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14223. ),
  14224. $content,
  14225. 'outputs data correctly'
  14226. );
  14227. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14228. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14229. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14230. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14231. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14232. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14233. }
  14234. /**
  14235. * @runInSeparateProcess
  14236. */
  14237. public function testDelete172()
  14238. {
  14239. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14240. $this->_model->create(self::$pasteid, self::$paste);
  14241. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14242. $_GET['pasteid'] = self::$pasteid;
  14243. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14244. ob_start();
  14245. new zerobin;
  14246. $content = ob_get_contents();
  14247. $this->assertTag(
  14248. array(
  14249. 'id' => 'status',
  14250. 'content' => 'Paste was properly deleted'
  14251. ),
  14252. $content,
  14253. 'outputs deleted status correctly'
  14254. );
  14255. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14256. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14257. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14258. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14259. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14260. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14261. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14262. }
  14263. /**
  14264. * @runInSeparateProcess
  14265. */
  14266. public function testView173()
  14267. {
  14268. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14269. ob_start();
  14270. new zerobin;
  14271. $content = ob_get_contents();
  14272. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14273. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14274. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14275. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14276. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14277. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14278. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14279. }
  14280. /**
  14281. * @runInSeparateProcess
  14282. */
  14283. public function testCreate173()
  14284. {
  14285. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14286. $_POST = self::$paste;
  14287. $_SERVER['REMOTE_ADDR'] = '::1';
  14288. sleep(3);
  14289. ob_start();
  14290. new zerobin;
  14291. $content = ob_get_contents();
  14292. $response = json_decode($content, true);
  14293. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14294. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14295. }
  14296. /**
  14297. * @runInSeparateProcess
  14298. */
  14299. public function testRead173()
  14300. {
  14301. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14302. $this->_model->create(self::$pasteid, self::$paste);
  14303. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14304. ob_start();
  14305. new zerobin;
  14306. $content = ob_get_contents();
  14307. $this->assertTag(
  14308. array(
  14309. 'id' => 'cipherdata',
  14310. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14311. ),
  14312. $content,
  14313. 'outputs data correctly'
  14314. );
  14315. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14316. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14317. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14318. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14319. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14320. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14321. }
  14322. /**
  14323. * @runInSeparateProcess
  14324. */
  14325. public function testDelete173()
  14326. {
  14327. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14328. $this->_model->create(self::$pasteid, self::$paste);
  14329. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14330. $_GET['pasteid'] = self::$pasteid;
  14331. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14332. ob_start();
  14333. new zerobin;
  14334. $content = ob_get_contents();
  14335. $this->assertTag(
  14336. array(
  14337. 'id' => 'status',
  14338. 'content' => 'Paste was properly deleted'
  14339. ),
  14340. $content,
  14341. 'outputs deleted status correctly'
  14342. );
  14343. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14344. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14345. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14346. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14347. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14348. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14349. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14350. }
  14351. /**
  14352. * @runInSeparateProcess
  14353. */
  14354. public function testView174()
  14355. {
  14356. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14357. ob_start();
  14358. new zerobin;
  14359. $content = ob_get_contents();
  14360. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14361. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14362. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14363. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14364. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14365. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14366. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14367. }
  14368. /**
  14369. * @runInSeparateProcess
  14370. */
  14371. public function testCreate174()
  14372. {
  14373. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14374. $_POST = self::$paste;
  14375. $_SERVER['REMOTE_ADDR'] = '::1';
  14376. ob_start();
  14377. new zerobin;
  14378. $content = ob_get_contents();
  14379. $response = json_decode($content, true);
  14380. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14381. }
  14382. /**
  14383. * @runInSeparateProcess
  14384. */
  14385. public function testRead174()
  14386. {
  14387. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14388. $this->_model->create(self::$pasteid, self::$paste);
  14389. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14390. ob_start();
  14391. new zerobin;
  14392. $content = ob_get_contents();
  14393. $this->assertTag(
  14394. array(
  14395. 'id' => 'cipherdata',
  14396. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14397. ),
  14398. $content,
  14399. 'outputs data correctly'
  14400. );
  14401. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14402. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14403. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14404. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14405. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14406. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14407. }
  14408. /**
  14409. * @runInSeparateProcess
  14410. */
  14411. public function testDelete174()
  14412. {
  14413. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14414. $this->_model->create(self::$pasteid, self::$paste);
  14415. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14416. $_GET['pasteid'] = self::$pasteid;
  14417. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14418. ob_start();
  14419. new zerobin;
  14420. $content = ob_get_contents();
  14421. $this->assertTag(
  14422. array(
  14423. 'id' => 'status',
  14424. 'content' => 'Paste was properly deleted'
  14425. ),
  14426. $content,
  14427. 'outputs deleted status correctly'
  14428. );
  14429. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14430. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14431. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14432. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14433. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14434. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14435. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14436. }
  14437. /**
  14438. * @runInSeparateProcess
  14439. */
  14440. public function testView175()
  14441. {
  14442. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14443. ob_start();
  14444. new zerobin;
  14445. $content = ob_get_contents();
  14446. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14447. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14448. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14449. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14450. $this->assertTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'preselects burn after reading option');
  14451. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14452. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14453. }
  14454. /**
  14455. * @runInSeparateProcess
  14456. */
  14457. public function testCreate175()
  14458. {
  14459. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14460. $_POST = self::$paste;
  14461. $_SERVER['REMOTE_ADDR'] = '::1';
  14462. sleep(3);
  14463. ob_start();
  14464. new zerobin;
  14465. $content = ob_get_contents();
  14466. $response = json_decode($content, true);
  14467. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14468. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14469. }
  14470. /**
  14471. * @runInSeparateProcess
  14472. */
  14473. public function testRead175()
  14474. {
  14475. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14476. $this->_model->create(self::$pasteid, self::$paste);
  14477. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14478. ob_start();
  14479. new zerobin;
  14480. $content = ob_get_contents();
  14481. $this->assertTag(
  14482. array(
  14483. 'id' => 'cipherdata',
  14484. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14485. ),
  14486. $content,
  14487. 'outputs data correctly'
  14488. );
  14489. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14490. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14491. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14492. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14493. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14494. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14495. }
  14496. /**
  14497. * @runInSeparateProcess
  14498. */
  14499. public function testDelete175()
  14500. {
  14501. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => true, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14502. $this->_model->create(self::$pasteid, self::$paste);
  14503. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14504. $_GET['pasteid'] = self::$pasteid;
  14505. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14506. ob_start();
  14507. new zerobin;
  14508. $content = ob_get_contents();
  14509. $this->assertTag(
  14510. array(
  14511. 'id' => 'status',
  14512. 'content' => 'Paste was properly deleted'
  14513. ),
  14514. $content,
  14515. 'outputs deleted status correctly'
  14516. );
  14517. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14518. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14519. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14520. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14521. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14522. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14523. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14524. }
  14525. /**
  14526. * @runInSeparateProcess
  14527. */
  14528. public function testView176()
  14529. {
  14530. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14531. ob_start();
  14532. new zerobin;
  14533. $content = ob_get_contents();
  14534. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14535. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14536. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14537. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14538. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14539. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14540. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14541. }
  14542. /**
  14543. * @runInSeparateProcess
  14544. */
  14545. public function testCreate176()
  14546. {
  14547. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14548. $_POST = self::$paste;
  14549. $_SERVER['REMOTE_ADDR'] = '::1';
  14550. $_POST["opendiscussion"] = "neither 1 nor 0";
  14551. ob_start();
  14552. new zerobin;
  14553. $content = ob_get_contents();
  14554. $response = json_decode($content, true);
  14555. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  14556. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  14557. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14558. }
  14559. /**
  14560. * @runInSeparateProcess
  14561. */
  14562. public function testRead176()
  14563. {
  14564. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14565. $this->_model->create(self::$pasteid, self::$paste);
  14566. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14567. ob_start();
  14568. new zerobin;
  14569. $content = ob_get_contents();
  14570. $this->assertTag(
  14571. array(
  14572. 'id' => 'cipherdata',
  14573. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14574. ),
  14575. $content,
  14576. 'outputs data correctly'
  14577. );
  14578. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14579. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14580. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14581. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14582. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14583. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14584. }
  14585. /**
  14586. * @runInSeparateProcess
  14587. */
  14588. public function testDelete176()
  14589. {
  14590. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14591. $this->_model->create(self::$pasteid, self::$paste);
  14592. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14593. $_GET['pasteid'] = self::$pasteid;
  14594. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14595. ob_start();
  14596. new zerobin;
  14597. $content = ob_get_contents();
  14598. $this->assertTag(
  14599. array(
  14600. 'id' => 'status',
  14601. 'content' => 'Paste was properly deleted'
  14602. ),
  14603. $content,
  14604. 'outputs deleted status correctly'
  14605. );
  14606. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14607. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14608. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14609. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14610. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14611. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14612. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14613. }
  14614. /**
  14615. * @runInSeparateProcess
  14616. */
  14617. public function testView177()
  14618. {
  14619. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14620. ob_start();
  14621. new zerobin;
  14622. $content = ob_get_contents();
  14623. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14624. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14625. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14626. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14627. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14628. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14629. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14630. }
  14631. /**
  14632. * @runInSeparateProcess
  14633. */
  14634. public function testCreate177()
  14635. {
  14636. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14637. $_POST = self::$paste;
  14638. $_SERVER['REMOTE_ADDR'] = '::1';
  14639. sleep(3);
  14640. ob_start();
  14641. new zerobin;
  14642. $content = ob_get_contents();
  14643. $response = json_decode($content, true);
  14644. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14645. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14646. }
  14647. /**
  14648. * @runInSeparateProcess
  14649. */
  14650. public function testRead177()
  14651. {
  14652. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14653. $this->_model->create(self::$pasteid, self::$paste);
  14654. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14655. ob_start();
  14656. new zerobin;
  14657. $content = ob_get_contents();
  14658. $this->assertTag(
  14659. array(
  14660. 'id' => 'cipherdata',
  14661. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14662. ),
  14663. $content,
  14664. 'outputs data correctly'
  14665. );
  14666. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14667. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14668. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14669. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14670. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14671. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14672. }
  14673. /**
  14674. * @runInSeparateProcess
  14675. */
  14676. public function testDelete177()
  14677. {
  14678. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14679. $this->_model->create(self::$pasteid, self::$paste);
  14680. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14681. $_GET['pasteid'] = self::$pasteid;
  14682. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14683. ob_start();
  14684. new zerobin;
  14685. $content = ob_get_contents();
  14686. $this->assertTag(
  14687. array(
  14688. 'id' => 'status',
  14689. 'content' => 'Paste was properly deleted'
  14690. ),
  14691. $content,
  14692. 'outputs deleted status correctly'
  14693. );
  14694. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14695. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14696. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14697. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14698. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14699. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14700. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14701. }
  14702. /**
  14703. * @runInSeparateProcess
  14704. */
  14705. public function testView178()
  14706. {
  14707. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14708. ob_start();
  14709. new zerobin;
  14710. $content = ob_get_contents();
  14711. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14712. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14713. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14714. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14715. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14716. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14717. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14718. }
  14719. /**
  14720. * @runInSeparateProcess
  14721. */
  14722. public function testCreate178()
  14723. {
  14724. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14725. $_POST = self::$paste;
  14726. $_SERVER['REMOTE_ADDR'] = '::1';
  14727. ob_start();
  14728. new zerobin;
  14729. $content = ob_get_contents();
  14730. $response = json_decode($content, true);
  14731. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14732. }
  14733. /**
  14734. * @runInSeparateProcess
  14735. */
  14736. public function testRead178()
  14737. {
  14738. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14739. $this->_model->create(self::$pasteid, self::$paste);
  14740. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14741. ob_start();
  14742. new zerobin;
  14743. $content = ob_get_contents();
  14744. $this->assertTag(
  14745. array(
  14746. 'id' => 'cipherdata',
  14747. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14748. ),
  14749. $content,
  14750. 'outputs data correctly'
  14751. );
  14752. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14753. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14754. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14755. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14756. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14757. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14758. }
  14759. /**
  14760. * @runInSeparateProcess
  14761. */
  14762. public function testDelete178()
  14763. {
  14764. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14765. $this->_model->create(self::$pasteid, self::$paste);
  14766. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14767. $_GET['pasteid'] = self::$pasteid;
  14768. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14769. ob_start();
  14770. new zerobin;
  14771. $content = ob_get_contents();
  14772. $this->assertTag(
  14773. array(
  14774. 'id' => 'status',
  14775. 'content' => 'Paste was properly deleted'
  14776. ),
  14777. $content,
  14778. 'outputs deleted status correctly'
  14779. );
  14780. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14781. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14782. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14783. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14784. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14785. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14786. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14787. }
  14788. /**
  14789. * @runInSeparateProcess
  14790. */
  14791. public function testView179()
  14792. {
  14793. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14794. ob_start();
  14795. new zerobin;
  14796. $content = ob_get_contents();
  14797. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14798. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14799. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14800. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14801. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14802. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14803. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14804. }
  14805. /**
  14806. * @runInSeparateProcess
  14807. */
  14808. public function testCreate179()
  14809. {
  14810. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14811. $_POST = self::$paste;
  14812. $_SERVER['REMOTE_ADDR'] = '::1';
  14813. sleep(3);
  14814. ob_start();
  14815. new zerobin;
  14816. $content = ob_get_contents();
  14817. $response = json_decode($content, true);
  14818. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14819. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14820. }
  14821. /**
  14822. * @runInSeparateProcess
  14823. */
  14824. public function testRead179()
  14825. {
  14826. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14827. $this->_model->create(self::$pasteid, self::$paste);
  14828. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14829. ob_start();
  14830. new zerobin;
  14831. $content = ob_get_contents();
  14832. $this->assertTag(
  14833. array(
  14834. 'id' => 'cipherdata',
  14835. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14836. ),
  14837. $content,
  14838. 'outputs data correctly'
  14839. );
  14840. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14841. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14842. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14843. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14844. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14845. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14846. }
  14847. /**
  14848. * @runInSeparateProcess
  14849. */
  14850. public function testDelete179()
  14851. {
  14852. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14853. $this->_model->create(self::$pasteid, self::$paste);
  14854. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14855. $_GET['pasteid'] = self::$pasteid;
  14856. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14857. ob_start();
  14858. new zerobin;
  14859. $content = ob_get_contents();
  14860. $this->assertTag(
  14861. array(
  14862. 'id' => 'status',
  14863. 'content' => 'Paste was properly deleted'
  14864. ),
  14865. $content,
  14866. 'outputs deleted status correctly'
  14867. );
  14868. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14869. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  14870. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  14871. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  14872. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'outputs prettify theme stylesheet correctly');
  14873. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14874. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14875. }
  14876. /**
  14877. * @runInSeparateProcess
  14878. */
  14879. public function testView180()
  14880. {
  14881. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14882. ob_start();
  14883. new zerobin;
  14884. $content = ob_get_contents();
  14885. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14886. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14887. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14888. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14889. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14890. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14891. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14892. }
  14893. /**
  14894. * @runInSeparateProcess
  14895. */
  14896. public function testCreate180()
  14897. {
  14898. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14899. $_POST = self::$paste;
  14900. $_SERVER['REMOTE_ADDR'] = '::1';
  14901. $_POST["opendiscussion"] = "neither 1 nor 0";
  14902. ob_start();
  14903. new zerobin;
  14904. $content = ob_get_contents();
  14905. $response = json_decode($content, true);
  14906. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  14907. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  14908. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  14909. }
  14910. /**
  14911. * @runInSeparateProcess
  14912. */
  14913. public function testRead180()
  14914. {
  14915. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14916. $this->_model->create(self::$pasteid, self::$paste);
  14917. $_SERVER['QUERY_STRING'] = self::$pasteid;
  14918. ob_start();
  14919. new zerobin;
  14920. $content = ob_get_contents();
  14921. $this->assertTag(
  14922. array(
  14923. 'id' => 'cipherdata',
  14924. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  14925. ),
  14926. $content,
  14927. 'outputs data correctly'
  14928. );
  14929. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14930. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14931. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14932. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14933. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14934. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14935. }
  14936. /**
  14937. * @runInSeparateProcess
  14938. */
  14939. public function testDelete180()
  14940. {
  14941. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14942. $this->_model->create(self::$pasteid, self::$paste);
  14943. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  14944. $_GET['pasteid'] = self::$pasteid;
  14945. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  14946. ob_start();
  14947. new zerobin;
  14948. $content = ob_get_contents();
  14949. $this->assertTag(
  14950. array(
  14951. 'id' => 'status',
  14952. 'content' => 'Paste was properly deleted'
  14953. ),
  14954. $content,
  14955. 'outputs deleted status correctly'
  14956. );
  14957. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  14958. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14959. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14960. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14961. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14962. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14963. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14964. }
  14965. /**
  14966. * @runInSeparateProcess
  14967. */
  14968. public function testView181()
  14969. {
  14970. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14971. ob_start();
  14972. new zerobin;
  14973. $content = ob_get_contents();
  14974. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  14975. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  14976. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  14977. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  14978. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  14979. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  14980. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  14981. }
  14982. /**
  14983. * @runInSeparateProcess
  14984. */
  14985. public function testCreate181()
  14986. {
  14987. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  14988. $_POST = self::$paste;
  14989. $_SERVER['REMOTE_ADDR'] = '::1';
  14990. sleep(3);
  14991. ob_start();
  14992. new zerobin;
  14993. $content = ob_get_contents();
  14994. $response = json_decode($content, true);
  14995. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  14996. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  14997. }
  14998. /**
  14999. * @runInSeparateProcess
  15000. */
  15001. public function testRead181()
  15002. {
  15003. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15004. $this->_model->create(self::$pasteid, self::$paste);
  15005. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15006. ob_start();
  15007. new zerobin;
  15008. $content = ob_get_contents();
  15009. $this->assertTag(
  15010. array(
  15011. 'id' => 'cipherdata',
  15012. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15013. ),
  15014. $content,
  15015. 'outputs data correctly'
  15016. );
  15017. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15018. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15019. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15020. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15021. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15022. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15023. }
  15024. /**
  15025. * @runInSeparateProcess
  15026. */
  15027. public function testDelete181()
  15028. {
  15029. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15030. $this->_model->create(self::$pasteid, self::$paste);
  15031. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15032. $_GET['pasteid'] = self::$pasteid;
  15033. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15034. ob_start();
  15035. new zerobin;
  15036. $content = ob_get_contents();
  15037. $this->assertTag(
  15038. array(
  15039. 'id' => 'status',
  15040. 'content' => 'Paste was properly deleted'
  15041. ),
  15042. $content,
  15043. 'outputs deleted status correctly'
  15044. );
  15045. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15046. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15047. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15048. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15049. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15050. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15051. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15052. }
  15053. /**
  15054. * @runInSeparateProcess
  15055. */
  15056. public function testView182()
  15057. {
  15058. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15059. ob_start();
  15060. new zerobin;
  15061. $content = ob_get_contents();
  15062. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15063. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15064. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15065. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15066. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15067. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15068. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15069. }
  15070. /**
  15071. * @runInSeparateProcess
  15072. */
  15073. public function testCreate182()
  15074. {
  15075. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15076. $_POST = self::$paste;
  15077. $_SERVER['REMOTE_ADDR'] = '::1';
  15078. ob_start();
  15079. new zerobin;
  15080. $content = ob_get_contents();
  15081. $response = json_decode($content, true);
  15082. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  15083. }
  15084. /**
  15085. * @runInSeparateProcess
  15086. */
  15087. public function testRead182()
  15088. {
  15089. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15090. $this->_model->create(self::$pasteid, self::$paste);
  15091. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15092. ob_start();
  15093. new zerobin;
  15094. $content = ob_get_contents();
  15095. $this->assertTag(
  15096. array(
  15097. 'id' => 'cipherdata',
  15098. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15099. ),
  15100. $content,
  15101. 'outputs data correctly'
  15102. );
  15103. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15104. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15105. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15106. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15107. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15108. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15109. }
  15110. /**
  15111. * @runInSeparateProcess
  15112. */
  15113. public function testDelete182()
  15114. {
  15115. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15116. $this->_model->create(self::$pasteid, self::$paste);
  15117. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15118. $_GET['pasteid'] = self::$pasteid;
  15119. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15120. ob_start();
  15121. new zerobin;
  15122. $content = ob_get_contents();
  15123. $this->assertTag(
  15124. array(
  15125. 'id' => 'status',
  15126. 'content' => 'Paste was properly deleted'
  15127. ),
  15128. $content,
  15129. 'outputs deleted status correctly'
  15130. );
  15131. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15132. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15133. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15134. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15135. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15136. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15137. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15138. }
  15139. /**
  15140. * @runInSeparateProcess
  15141. */
  15142. public function testView183()
  15143. {
  15144. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15145. ob_start();
  15146. new zerobin;
  15147. $content = ob_get_contents();
  15148. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15149. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15150. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15151. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15152. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15153. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15154. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15155. }
  15156. /**
  15157. * @runInSeparateProcess
  15158. */
  15159. public function testCreate183()
  15160. {
  15161. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15162. $_POST = self::$paste;
  15163. $_SERVER['REMOTE_ADDR'] = '::1';
  15164. sleep(3);
  15165. ob_start();
  15166. new zerobin;
  15167. $content = ob_get_contents();
  15168. $response = json_decode($content, true);
  15169. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  15170. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  15171. }
  15172. /**
  15173. * @runInSeparateProcess
  15174. */
  15175. public function testRead183()
  15176. {
  15177. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15178. $this->_model->create(self::$pasteid, self::$paste);
  15179. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15180. ob_start();
  15181. new zerobin;
  15182. $content = ob_get_contents();
  15183. $this->assertTag(
  15184. array(
  15185. 'id' => 'cipherdata',
  15186. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15187. ),
  15188. $content,
  15189. 'outputs data correctly'
  15190. );
  15191. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15192. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15193. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15194. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15195. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15196. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15197. }
  15198. /**
  15199. * @runInSeparateProcess
  15200. */
  15201. public function testDelete183()
  15202. {
  15203. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => 'sons-of-obsidian'), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15204. $this->_model->create(self::$pasteid, self::$paste);
  15205. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15206. $_GET['pasteid'] = self::$pasteid;
  15207. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15208. ob_start();
  15209. new zerobin;
  15210. $content = ob_get_contents();
  15211. $this->assertTag(
  15212. array(
  15213. 'id' => 'status',
  15214. 'content' => 'Paste was properly deleted'
  15215. ),
  15216. $content,
  15217. 'outputs deleted status correctly'
  15218. );
  15219. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15220. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15221. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15222. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15223. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15224. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15225. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15226. }
  15227. /**
  15228. * @runInSeparateProcess
  15229. */
  15230. public function testView184()
  15231. {
  15232. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15233. ob_start();
  15234. new zerobin;
  15235. $content = ob_get_contents();
  15236. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15237. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15238. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15239. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15240. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15241. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15242. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15243. }
  15244. /**
  15245. * @runInSeparateProcess
  15246. */
  15247. public function testCreate184()
  15248. {
  15249. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15250. $_POST = self::$paste;
  15251. $_SERVER['REMOTE_ADDR'] = '::1';
  15252. $_POST["opendiscussion"] = "neither 1 nor 0";
  15253. ob_start();
  15254. new zerobin;
  15255. $content = ob_get_contents();
  15256. $response = json_decode($content, true);
  15257. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  15258. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  15259. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  15260. }
  15261. /**
  15262. * @runInSeparateProcess
  15263. */
  15264. public function testRead184()
  15265. {
  15266. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15267. $this->_model->create(self::$pasteid, self::$paste);
  15268. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15269. ob_start();
  15270. new zerobin;
  15271. $content = ob_get_contents();
  15272. $this->assertTag(
  15273. array(
  15274. 'id' => 'cipherdata',
  15275. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15276. ),
  15277. $content,
  15278. 'outputs data correctly'
  15279. );
  15280. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15281. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15282. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15283. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15284. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15285. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15286. }
  15287. /**
  15288. * @runInSeparateProcess
  15289. */
  15290. public function testDelete184()
  15291. {
  15292. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15293. $this->_model->create(self::$pasteid, self::$paste);
  15294. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15295. $_GET['pasteid'] = self::$pasteid;
  15296. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15297. ob_start();
  15298. new zerobin;
  15299. $content = ob_get_contents();
  15300. $this->assertTag(
  15301. array(
  15302. 'id' => 'status',
  15303. 'content' => 'Paste was properly deleted'
  15304. ),
  15305. $content,
  15306. 'outputs deleted status correctly'
  15307. );
  15308. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15309. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15310. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15311. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15312. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15313. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15314. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15315. }
  15316. /**
  15317. * @runInSeparateProcess
  15318. */
  15319. public function testView185()
  15320. {
  15321. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15322. ob_start();
  15323. new zerobin;
  15324. $content = ob_get_contents();
  15325. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15326. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15327. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15328. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15329. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15330. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15331. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15332. }
  15333. /**
  15334. * @runInSeparateProcess
  15335. */
  15336. public function testCreate185()
  15337. {
  15338. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15339. $_POST = self::$paste;
  15340. $_SERVER['REMOTE_ADDR'] = '::1';
  15341. sleep(3);
  15342. ob_start();
  15343. new zerobin;
  15344. $content = ob_get_contents();
  15345. $response = json_decode($content, true);
  15346. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  15347. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  15348. }
  15349. /**
  15350. * @runInSeparateProcess
  15351. */
  15352. public function testRead185()
  15353. {
  15354. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15355. $this->_model->create(self::$pasteid, self::$paste);
  15356. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15357. ob_start();
  15358. new zerobin;
  15359. $content = ob_get_contents();
  15360. $this->assertTag(
  15361. array(
  15362. 'id' => 'cipherdata',
  15363. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15364. ),
  15365. $content,
  15366. 'outputs data correctly'
  15367. );
  15368. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15369. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15370. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15371. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15372. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15373. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15374. }
  15375. /**
  15376. * @runInSeparateProcess
  15377. */
  15378. public function testDelete185()
  15379. {
  15380. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15381. $this->_model->create(self::$pasteid, self::$paste);
  15382. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15383. $_GET['pasteid'] = self::$pasteid;
  15384. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15385. ob_start();
  15386. new zerobin;
  15387. $content = ob_get_contents();
  15388. $this->assertTag(
  15389. array(
  15390. 'id' => 'status',
  15391. 'content' => 'Paste was properly deleted'
  15392. ),
  15393. $content,
  15394. 'outputs deleted status correctly'
  15395. );
  15396. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15397. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15398. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15399. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15400. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15401. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15402. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15403. }
  15404. /**
  15405. * @runInSeparateProcess
  15406. */
  15407. public function testView186()
  15408. {
  15409. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15410. ob_start();
  15411. new zerobin;
  15412. $content = ob_get_contents();
  15413. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15414. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15415. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15416. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15417. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15418. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15419. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15420. }
  15421. /**
  15422. * @runInSeparateProcess
  15423. */
  15424. public function testCreate186()
  15425. {
  15426. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15427. $_POST = self::$paste;
  15428. $_SERVER['REMOTE_ADDR'] = '::1';
  15429. ob_start();
  15430. new zerobin;
  15431. $content = ob_get_contents();
  15432. $response = json_decode($content, true);
  15433. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  15434. }
  15435. /**
  15436. * @runInSeparateProcess
  15437. */
  15438. public function testRead186()
  15439. {
  15440. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15441. $this->_model->create(self::$pasteid, self::$paste);
  15442. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15443. ob_start();
  15444. new zerobin;
  15445. $content = ob_get_contents();
  15446. $this->assertTag(
  15447. array(
  15448. 'id' => 'cipherdata',
  15449. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15450. ),
  15451. $content,
  15452. 'outputs data correctly'
  15453. );
  15454. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15455. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15456. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15457. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15458. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15459. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15460. }
  15461. /**
  15462. * @runInSeparateProcess
  15463. */
  15464. public function testDelete186()
  15465. {
  15466. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15467. $this->_model->create(self::$pasteid, self::$paste);
  15468. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15469. $_GET['pasteid'] = self::$pasteid;
  15470. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15471. ob_start();
  15472. new zerobin;
  15473. $content = ob_get_contents();
  15474. $this->assertTag(
  15475. array(
  15476. 'id' => 'status',
  15477. 'content' => 'Paste was properly deleted'
  15478. ),
  15479. $content,
  15480. 'outputs deleted status correctly'
  15481. );
  15482. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15483. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15484. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15485. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15486. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15487. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15488. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15489. }
  15490. /**
  15491. * @runInSeparateProcess
  15492. */
  15493. public function testView187()
  15494. {
  15495. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15496. ob_start();
  15497. new zerobin;
  15498. $content = ob_get_contents();
  15499. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15500. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15501. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15502. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15503. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15504. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15505. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15506. }
  15507. /**
  15508. * @runInSeparateProcess
  15509. */
  15510. public function testCreate187()
  15511. {
  15512. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15513. $_POST = self::$paste;
  15514. $_SERVER['REMOTE_ADDR'] = '::1';
  15515. sleep(3);
  15516. ob_start();
  15517. new zerobin;
  15518. $content = ob_get_contents();
  15519. $response = json_decode($content, true);
  15520. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  15521. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  15522. }
  15523. /**
  15524. * @runInSeparateProcess
  15525. */
  15526. public function testRead187()
  15527. {
  15528. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15529. $this->_model->create(self::$pasteid, self::$paste);
  15530. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15531. ob_start();
  15532. new zerobin;
  15533. $content = ob_get_contents();
  15534. $this->assertTag(
  15535. array(
  15536. 'id' => 'cipherdata',
  15537. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15538. ),
  15539. $content,
  15540. 'outputs data correctly'
  15541. );
  15542. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15543. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15544. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15545. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15546. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15547. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15548. }
  15549. /**
  15550. * @runInSeparateProcess
  15551. */
  15552. public function testDelete187()
  15553. {
  15554. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => true, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15555. $this->_model->create(self::$pasteid, self::$paste);
  15556. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15557. $_GET['pasteid'] = self::$pasteid;
  15558. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15559. ob_start();
  15560. new zerobin;
  15561. $content = ob_get_contents();
  15562. $this->assertTag(
  15563. array(
  15564. 'id' => 'status',
  15565. 'content' => 'Paste was properly deleted'
  15566. ),
  15567. $content,
  15568. 'outputs deleted status correctly'
  15569. );
  15570. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15571. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15572. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'outputs prettify stylesheet correctly');
  15573. $this->assertTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'outputs prettify javascript correctly');
  15574. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15575. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15576. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15577. }
  15578. /**
  15579. * @runInSeparateProcess
  15580. */
  15581. public function testView188()
  15582. {
  15583. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15584. ob_start();
  15585. new zerobin;
  15586. $content = ob_get_contents();
  15587. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15588. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15589. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15590. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15591. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15592. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15593. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15594. }
  15595. /**
  15596. * @runInSeparateProcess
  15597. */
  15598. public function testCreate188()
  15599. {
  15600. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15601. $_POST = self::$paste;
  15602. $_SERVER['REMOTE_ADDR'] = '::1';
  15603. $_POST["opendiscussion"] = "neither 1 nor 0";
  15604. ob_start();
  15605. new zerobin;
  15606. $content = ob_get_contents();
  15607. $response = json_decode($content, true);
  15608. $this->assertEquals(1, $response["status"], 'when discussions are enabled, but invalid flag posted, fail to create paste');
  15609. $this->assertFalse($this->_model->exists(self::$pasteid), 'when discussions are enabled, but invalid flag posted, paste is not created');
  15610. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  15611. }
  15612. /**
  15613. * @runInSeparateProcess
  15614. */
  15615. public function testRead188()
  15616. {
  15617. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15618. $this->_model->create(self::$pasteid, self::$paste);
  15619. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15620. ob_start();
  15621. new zerobin;
  15622. $content = ob_get_contents();
  15623. $this->assertTag(
  15624. array(
  15625. 'id' => 'cipherdata',
  15626. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15627. ),
  15628. $content,
  15629. 'outputs data correctly'
  15630. );
  15631. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15632. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15633. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15634. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15635. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15636. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15637. }
  15638. /**
  15639. * @runInSeparateProcess
  15640. */
  15641. public function testDelete188()
  15642. {
  15643. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15644. $this->_model->create(self::$pasteid, self::$paste);
  15645. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15646. $_GET['pasteid'] = self::$pasteid;
  15647. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15648. ob_start();
  15649. new zerobin;
  15650. $content = ob_get_contents();
  15651. $this->assertTag(
  15652. array(
  15653. 'id' => 'status',
  15654. 'content' => 'Paste was properly deleted'
  15655. ),
  15656. $content,
  15657. 'outputs deleted status correctly'
  15658. );
  15659. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15660. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15661. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15662. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15663. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15664. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15665. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15666. }
  15667. /**
  15668. * @runInSeparateProcess
  15669. */
  15670. public function testView189()
  15671. {
  15672. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15673. ob_start();
  15674. new zerobin;
  15675. $content = ob_get_contents();
  15676. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15677. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15678. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15679. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15680. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15681. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15682. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15683. }
  15684. /**
  15685. * @runInSeparateProcess
  15686. */
  15687. public function testCreate189()
  15688. {
  15689. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15690. $_POST = self::$paste;
  15691. $_SERVER['REMOTE_ADDR'] = '::1';
  15692. sleep(3);
  15693. ob_start();
  15694. new zerobin;
  15695. $content = ob_get_contents();
  15696. $response = json_decode($content, true);
  15697. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  15698. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  15699. }
  15700. /**
  15701. * @runInSeparateProcess
  15702. */
  15703. public function testRead189()
  15704. {
  15705. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15706. $this->_model->create(self::$pasteid, self::$paste);
  15707. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15708. ob_start();
  15709. new zerobin;
  15710. $content = ob_get_contents();
  15711. $this->assertTag(
  15712. array(
  15713. 'id' => 'cipherdata',
  15714. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15715. ),
  15716. $content,
  15717. 'outputs data correctly'
  15718. );
  15719. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15720. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15721. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15722. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15723. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15724. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15725. }
  15726. /**
  15727. * @runInSeparateProcess
  15728. */
  15729. public function testDelete189()
  15730. {
  15731. $this->reset(array('main' => array('opendiscussion' => true, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15732. $this->_model->create(self::$pasteid, self::$paste);
  15733. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15734. $_GET['pasteid'] = self::$pasteid;
  15735. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15736. ob_start();
  15737. new zerobin;
  15738. $content = ob_get_contents();
  15739. $this->assertTag(
  15740. array(
  15741. 'id' => 'status',
  15742. 'content' => 'Paste was properly deleted'
  15743. ),
  15744. $content,
  15745. 'outputs deleted status correctly'
  15746. );
  15747. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15748. $this->assertNotTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs enabled discussion correctly');
  15749. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15750. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15751. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15752. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15753. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15754. }
  15755. /**
  15756. * @runInSeparateProcess
  15757. */
  15758. public function testView190()
  15759. {
  15760. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15761. ob_start();
  15762. new zerobin;
  15763. $content = ob_get_contents();
  15764. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15765. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15766. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15767. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15768. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15769. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15770. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15771. }
  15772. /**
  15773. * @runInSeparateProcess
  15774. */
  15775. public function testCreate190()
  15776. {
  15777. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15778. $_POST = self::$paste;
  15779. $_SERVER['REMOTE_ADDR'] = '::1';
  15780. ob_start();
  15781. new zerobin;
  15782. $content = ob_get_contents();
  15783. $response = json_decode($content, true);
  15784. $this->assertEquals(1, $response["status"], 'when traffic limit is on and we do not wait, fail to create paste');
  15785. }
  15786. /**
  15787. * @runInSeparateProcess
  15788. */
  15789. public function testRead190()
  15790. {
  15791. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15792. $this->_model->create(self::$pasteid, self::$paste);
  15793. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15794. ob_start();
  15795. new zerobin;
  15796. $content = ob_get_contents();
  15797. $this->assertTag(
  15798. array(
  15799. 'id' => 'cipherdata',
  15800. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15801. ),
  15802. $content,
  15803. 'outputs data correctly'
  15804. );
  15805. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15806. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15807. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15808. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15809. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15810. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15811. }
  15812. /**
  15813. * @runInSeparateProcess
  15814. */
  15815. public function testDelete190()
  15816. {
  15817. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 10, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15818. $this->_model->create(self::$pasteid, self::$paste);
  15819. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15820. $_GET['pasteid'] = self::$pasteid;
  15821. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15822. ob_start();
  15823. new zerobin;
  15824. $content = ob_get_contents();
  15825. $this->assertTag(
  15826. array(
  15827. 'id' => 'status',
  15828. 'content' => 'Paste was properly deleted'
  15829. ),
  15830. $content,
  15831. 'outputs deleted status correctly'
  15832. );
  15833. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15834. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15835. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15836. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15837. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15838. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15839. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15840. }
  15841. /**
  15842. * @runInSeparateProcess
  15843. */
  15844. public function testView191()
  15845. {
  15846. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15847. ob_start();
  15848. new zerobin;
  15849. $content = ob_get_contents();
  15850. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15851. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15852. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15853. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15854. $this->assertNotTag(array('id' => 'burnafterreading', 'attributes' => array('checked' => 'checked')), $content, 'burn after reading option is unchecked');
  15855. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15856. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15857. }
  15858. /**
  15859. * @runInSeparateProcess
  15860. */
  15861. public function testCreate191()
  15862. {
  15863. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15864. $_POST = self::$paste;
  15865. $_SERVER['REMOTE_ADDR'] = '::1';
  15866. sleep(3);
  15867. ob_start();
  15868. new zerobin;
  15869. $content = ob_get_contents();
  15870. $response = json_decode($content, true);
  15871. $this->assertEquals(0, $response["status"], 'when traffic limit is on and we wait, successfully create paste');
  15872. $this->assertTrue($this->_model->exists($response["id"]), 'when traffic limit is on and we wait, paste exists after posting data');
  15873. }
  15874. /**
  15875. * @runInSeparateProcess
  15876. */
  15877. public function testRead191()
  15878. {
  15879. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15880. $this->_model->create(self::$pasteid, self::$paste);
  15881. $_SERVER['QUERY_STRING'] = self::$pasteid;
  15882. ob_start();
  15883. new zerobin;
  15884. $content = ob_get_contents();
  15885. $this->assertTag(
  15886. array(
  15887. 'id' => 'cipherdata',
  15888. 'content' => htmlspecialchars(json_encode(self::$paste), ENT_NOQUOTES)
  15889. ),
  15890. $content,
  15891. 'outputs data correctly'
  15892. );
  15893. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15894. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15895. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15896. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15897. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15898. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15899. }
  15900. /**
  15901. * @runInSeparateProcess
  15902. */
  15903. public function testDelete191()
  15904. {
  15905. $this->reset(array('main' => array('opendiscussion' => false, 'syntaxhighlighting' => false, 'burnafterreadingselected' => false, 'sizelimit' => 2097152, 'template' => 'bootstrap', 'base64version' => '2.1.9', 'syntaxhighlightingtheme' => NULL), 'expire' => array('default' => '1month'), 'expire_options' => array('5min' => '300', '10min' => '600', '1hour' => '3600', '1day' => '86400', '1week' => '604800', '1month' => '2592000', '1year' => '31536000', 'never' => '0'), 'expire_labels' => array('5min' => '5 minutes', '10min' => '10 minutes', '1hour' => '1 hour', '1day' => '1 day', '1week' => '1 week', '1month' => '1 month', '1year' => '1 year', 'never' => 'Never'), 'traffic' => array('limit' => 2, 'dir' => '../data'), 'model' => array('class' => 'zerobin_data'), 'model_options' => array('dir' => '../data')));
  15906. $this->_model->create(self::$pasteid, self::$paste);
  15907. $this->assertTrue($this->_model->exists(self::$pasteid), 'paste exists before deleting data');
  15908. $_GET['pasteid'] = self::$pasteid;
  15909. $_GET['deletetoken'] = hash_hmac('sha1', self::$pasteid, serversalt::get());
  15910. ob_start();
  15911. new zerobin;
  15912. $content = ob_get_contents();
  15913. $this->assertTag(
  15914. array(
  15915. 'id' => 'status',
  15916. 'content' => 'Paste was properly deleted'
  15917. ),
  15918. $content,
  15919. 'outputs deleted status correctly'
  15920. );
  15921. $this->assertFalse($this->_model->exists(self::$pasteid), 'paste successfully deleted');
  15922. $this->assertTag(array('id' => 'opendiscussion', 'attributes' => array('disabled' => 'disabled')), $content, 'outputs disabled discussion correctly');
  15923. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/prettify\\.css#')), $content, 'removes prettify stylesheet correctly');
  15924. $this->assertNotTag(array('tag' => 'script', 'attributes' => array('type' => 'text/javascript', 'src' => 'regexp:#js/prettify\\.js#')), $content, 'removes prettify javascript correctly');
  15925. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/prettify/sons-of-obsidian\\.css#')), $content, 'removes prettify theme stylesheet correctly');
  15926. $this->assertNotTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/zerobin.css#')), $content, 'removes "page" stylesheet correctly');
  15927. $this->assertTag(array('tag' => 'link', 'attributes' => array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => 'regexp:#css/bootstrap/bootstrap-\\d[\\d\\.]+\\d\\.css#')), $content, 'outputs "bootstrap" stylesheet correctly');
  15928. }
  15929. }