Ajustes

Ajustes
parent 5241b0fa
<?php
namespace Sisoft\Calculadora;
use InvalidArgumentException;
use Sisoft\Excepciones\MiPrimeraExcepcion;
//cuidado con adicionar parametros
//para probar en el git bash vendor/bin/phpunit tests/OperacionesTests.php --colors
class Operaciones {
class Operaciones
{
public function sumar($parametro1, $parametro2)
{
......@@ -30,5 +33,4 @@ class Operaciones {
}
return ($parametro1 / $parametro2);
}
}
\ No newline at end of file
}
<?php
namespace Tests;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Sisoft\Calculadora\Operaciones;
use Sisoft\Excepciones\MiPrimeraExcepcion;
//TDD importante estudiar
class OperacionesTests extends TestCase {
private $op;
public function setup(): void
{
$this->op = new Operaciones();
}
public function testSumarConDosValores()
{
$this->assertSame(7, $this->op->sumar('2', '5'));
}
public function testSumarConValoresNulos()
{
$this->expectException(MiPrimeraExcepcion::class);
$this->op->sumar(NULL, NULL);
}
public function testSumarConValoresVarchar()
{
$this->expectException(InvalidArgumentException::class);
$this->op->sumar("dos", "siete");
}
public function testDividirConDosValores()
{
$this->expectException(InvalidArgumentException::class);
$this->assertEquals(8, $this->op->dividir(6, 0));
/* next class
$payload = [
'first_name' => $this->faker->firstName,
'last_name' => $this->faker->lastName,
'email' => $this->faker->email
];
$this->json('post', 'api/user', $payload)
->assertStatus(Response::HTTP_CREATED)
->assertJsonStructure(
[
'message' => [
'id',
'first_name',
'last_name',
'email',
'created_at',]]);
*/
}
}
......@@ -4,14 +4,16 @@ use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Sisoft\Calculadora\Operaciones;
use Sisoft\Excepciones\MiPrimeraExcepcion;
//TDD importante estudiar
class OperacionesTests extends TestCase {
class OperacionesTests extends TestCase
{
private $op;
public function setup(): void
{
$this->op = new Operaciones();
$this->op = new Operaciones();
}
public function testSumarConDosValores()
......@@ -22,7 +24,7 @@ class OperacionesTests extends TestCase {
public function testSumarConValoresNulos()
{
$this->expectException(MiPrimeraExcepcion::class);
$this->op->sumar(NULL, NULL);
$this->op->sumar(null, null);
}
public function testSumarConValoresVarchar()
......@@ -54,5 +56,4 @@ class OperacionesTests extends TestCase {
*/
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment