Created
October 9, 2014 14:25
-
-
Save labra/1f8ed2a054936bbdd4cc to your computer and use it in GitHub Desktop.
Ejercicio PHP: curso
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 'curso.php'; | |
class CursoTest extends PHPUnit_Framework_TestCase | |
{ | |
function test_create_class() { | |
$c = new Curso('Algebra'); | |
$this->assertTrue(is_a($c, 'Curso')); | |
} | |
function test_curso_vacio() { | |
$c = new Curso('Algebra'); | |
try { | |
$media = $c->media(); | |
} catch (Exception $e) { | |
return; // OK | |
} | |
$this->fail("it should throw exception"); | |
} | |
function test_curso_inserta_nota() { | |
try { | |
$c = new Curso('Algebra'); | |
$c->ponNota(234, 2.0); | |
$nota = $c->getNota(234); | |
$this->assertEquals(2.0, $nota, '', 0.001); | |
} catch (Exception $e) { | |
$this->fail($e->getMessage()); | |
} | |
} | |
function test_curso_3_alumnos() { | |
try { | |
$c = new Curso('Algebra'); | |
$c->ponNota(234, 2.0); | |
$c->ponNota(235, 1.0); | |
$c->ponNota(236, 3.0); | |
$this->assertEquals(2.0, $c->media(), '', 0.001); | |
} catch (Exception $e) { | |
$this->fail($e->getMessage()); | |
} | |
} | |
function test_curso_3_veces_mismo_alumno() { | |
try { | |
$c = new Curso('Algebra'); | |
$c->ponNota(234, 2.0); | |
$c->ponNota(234, 1.0); | |
$c->ponNota(234, 3.0); | |
$this->assertEquals(3.0, $c->media(), '', 0.001); | |
} catch (Exception $e) { | |
$this->fail($e->getMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment