Created
October 9, 2014 13:48
-
-
Save labra/de3923e1e4753bd1756b to your computer and use it in GitHub Desktop.
Ejercicio PHP: Corrector test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| require_once 'corrector.php'; | |
| class CorrectorTest extends PHPUnit_Framework_TestCase { | |
| private $examen, $evaluacion, $resultado, $corrector ; | |
| function __construct() { | |
| $this->examen = json_decode('[ | |
| {"pregunta": 1, "correcta": "a"}, | |
| {"pregunta": 2, "correcta": "b"}]',true) ; | |
| $this->evaluacion = | |
| json_decode('[ {"alumno" : 2456, | |
| "respuestas" : [{ "pregunta" : 1, "respuesta" : "a"}, | |
| { "pregunta" : 2, "respuesta" : "b"}]}, | |
| {"alumno" : 4321, | |
| "respuestas" : [{ "pregunta": 1, "respuesta": "b"}, | |
| { "pregunta": 2, "respuesta": "b"}]}, | |
| {"alumno": 6789, | |
| "respuestas": [{ "pregunta": 1, "respuesta": "b"}, | |
| { "pregunta": 2, "respuesta": "a"}]} | |
| ]',true) ; | |
| $this->resultado = json_decode(' | |
| [ {"alumno": 2456, "nota": 2}, | |
| {"alumno": 4321, "nota": 0.75}, | |
| {"alumno": 6789, "nota": -0.5} | |
| ]',true); | |
| $this->respuestas = json_decode(' | |
| [{ "pregunta": 1, "respuesta": "b"}, | |
| { "pregunta": 2, "respuesta": "a"}]',true); | |
| $this->corrector = new Corrector(); | |
| } | |
| function test_not_null_resultado() { | |
| $this->assertNotNull($this->resultado); | |
| } | |
| function test_not_null_examen() { | |
| $this->assertNotNull($this->examen); | |
| } | |
| function test_not_null_evaluacion() { | |
| $this->assertNotNull($this->evaluacion); | |
| } | |
| function test_corrector() { | |
| $devuelto = $this->corrector->corrige($this->examen,$this->evaluacion); | |
| $this->assertEquals($this->resultado, $devuelto); | |
| } | |
| function test_busca1() { | |
| $this->assertEquals("b",$this->corrector->busca(1,$this->respuestas)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment