annotate php/test.html @ 2931:465084b9c6dc

#228 Implementation
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 11 Sep 2017 17:19:27 +0100
parents 8424c62a8c97
children 95f507064bf2
rev   line source
nicholas@2930 1 <html lang="en">
nicholas@2930 2
nicholas@2930 3 <head>
nicholas@2930 4 <meta http-equiv="content-type" content="text/html; charset=utf-8">
nicholas@2930 5
nicholas@2930 6
nicholas@2930 7 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
nicholas@2930 8 Remove this if you use the .htaccess -->
nicholas@2930 9 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
nicholas@2930 10
nicholas@2930 11 <title>Web Audio Evaluation Tool</title>
nicholas@2930 12 <meta name="description" content="" />
nicholas@2930 13 <meta name="author" content="" />
nicholas@2930 14
nicholas@2930 15 <!-- Load up the default core JS and CSS files-->
nicholas@2930 16 <link rel='stylesheet' type='text/css' href='../css/core.css'>
nicholas@2930 17 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.css" integrity="sha256-Flo6sV8k+IPfHh6Hx97ReUJDLOwIwvhdGlKOz3UgHRE=" crossorigin="anonymous" />
nicholas@2930 18 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
nicholas@2930 19 <!-- Use jQuery hosted from Google CDN -->
nicholas@2930 20 <!--<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>-->
nicholas@2930 21 <script type="text/javascript" src="../js/showdown.min.js"></script>
nicholas@2930 22 <script type="text/javascript" src="../js/jquery-2.1.4.js"></script>
nicholas@2930 23 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
nicholas@2930 24 <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.1.2/chai.min.js" integrity="sha256-iP6sMGdjKeRM2DuED2Lsi/n7MNTKhGpkhuSdCHXIgYc=" crossorigin="anonymous"></script>
nicholas@2930 25 <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/3.5.2/mocha.min.js" integrity="sha256-rw/35Nx9y5f+fLTdO7Tipm6ju+tRGwnplU1CJyPM3nE=" crossorigin="anonymous"></script>
nicholas@2930 26 <script>
nicholas@2930 27 mocha.setup('bdd');
nicholas@2930 28 var expect = chai.expect;
nicholas@2930 29 var should = chai.should();
nicholas@2930 30 var key1;
nicholas@2930 31 describe("requestKey.php", function() {
nicholas@2930 32 it("should give a key", function(done) {
nicholas@2930 33 var xhr = new XMLHttpRequest();
nicholas@2930 34 xhr.open("GET", "requestKey.php");
nicholas@2930 35 xhr.onload = function() {
nicholas@2930 36 var doc = xhr.response;
nicholas@2930 37 var state = doc.querySelector("state").textContent;
nicholas@2930 38 key1 = doc.querySelector("key").textContent;
nicholas@2930 39 expect(state).to.equal("OK");
nicholas@2930 40 done();
nicholas@2930 41 }
nicholas@2930 42 xhr.responseType = "document";
nicholas@2930 43 xhr.send();
nicholas@2930 44 });
nicholas@2931 45 it("should create an empty file with that key", function(done) {
nicholas@2931 46 var xhr = new XMLHttpRequest();
nicholas@2931 47 xhr.open("GET", "../saves/save-" + key1 + ".xml");
nicholas@2931 48 xhr.onload = function() {
nicholas@2931 49 var parser = new DOMParser();
nicholas@2931 50 doc = parser.parseFromString(xhr.responseText, "text/xml");
nicholas@2931 51 var state = doc.querySelector("waetresult").getAttribute("key");
nicholas@2931 52 expect(state).to.equal(key1);
nicholas@2931 53 done();
nicholas@2931 54 }
nicholas@2931 55 xhr.responseType = "";
nicholas@2931 56 xhr.send();
nicholas@2931 57 });
nicholas@2930 58 it("should give a different key on second request", function(done) {
nicholas@2930 59 var xhr = new XMLHttpRequest();
nicholas@2930 60 xhr.open("GET", "requestKey.php");
nicholas@2930 61 xhr.onload = function() {
nicholas@2930 62 var doc = xhr.response;
nicholas@2930 63 var state = doc.querySelector("state").textContent;
nicholas@2930 64 var key = doc.querySelector("key").textContent;
nicholas@2930 65 expect(key).not.to.equal(key1);
nicholas@2930 66 done();
nicholas@2930 67 }
nicholas@2930 68 xhr.responseType = "document";
nicholas@2930 69 xhr.send();
nicholas@2930 70 });
nicholas@2930 71 });
nicholas@2930 72 describe("save.php", function() {
nicholas@2930 73 it("should return an empty file on empty payload", function(done) {
nicholas@2930 74 var xhr = new XMLHttpRequest();
nicholas@2930 75 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests");
nicholas@2930 76 xhr.onload = function() {
nicholas@2930 77 var doc = xhr.response;
nicholas@2930 78 var state = doc.querySelector("message").textContent;
nicholas@2930 79 var file = doc.querySelector("file");
nicholas@2930 80 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\"");
nicholas@2930 81 expect(file.getAttribute("bytes")).to.equal("0");
nicholas@2930 82 expect(state).to.equal("OK");
nicholas@2930 83 done();
nicholas@2930 84 }
nicholas@2930 85 xhr.responseType = "document";
nicholas@2930 86 xhr.send();
nicholas@2930 87 });
nicholas@2931 88 it("should return a file on payload save", function(done) {
nicholas@2930 89 var xhr = new XMLHttpRequest();
nicholas@2930 90 xhr.open("POST", "save.php?key=" + key1 + "&saveFilenamePrefix=tests");
nicholas@2930 91 xhr.onload = function() {
nicholas@2930 92 var doc = xhr.response;
nicholas@2930 93 var state = doc.querySelector("message").textContent;
nicholas@2930 94 var file = doc.querySelector("file");
nicholas@2930 95 expect(file.textContent).to.equal("\"saves/tests-" + key1 + ".xml\"");
nicholas@2930 96 expect(file.getAttribute("bytes")).not.to.equal("0");
nicholas@2930 97 expect(state).to.equal("OK");
nicholas@2930 98 done();
nicholas@2930 99 }
nicholas@2930 100 xhr.responseType = "document";
nicholas@2930 101 xhr.send("<xml></xml>");
nicholas@2930 102 });
nicholas@2930 103 });
nicholas@2930 104 window.onload = function() {
nicholas@2930 105 mocha.run();
nicholas@2930 106 }
nicholas@2930 107
nicholas@2930 108 </script>
nicholas@2930 109 </head>
nicholas@2930 110
nicholas@2930 111 <body class="container">
nicholas@2930 112 <div>
nicholas@2930 113 <h1>WAET PHP Server Tests</h1>
nicholas@2930 114 <p class="lead">This page will test your PHP server for any implementation issues.</p>
nicholas@2931 115 <p>Make sure your <span>saves</span> directory is clean before testing and that you empty it afterwards as intermediary files will be made there.</p>
nicholas@2930 116
nicholas@2930 117 </div>
nicholas@2930 118 <div id="mocha"></div>
nicholas@2930 119 </body>
nicholas@2930 120
nicholas@2930 121 </html>