Commit 61432a0c by William Torres

fixed test

parent ac37ccfb
<?php
namespace Sisoft\Temperature;
use External\Service;
class Temperature
{
private $service;
public function __construct(Service $service)
{
$this->service = $service;
}
public function average()
{
$total = 0;
for ($i = 0; $i < 3; $i++) {
$total += $this->service->leerTemperatura();
}
return $total / 3;
}
}
<?php <?php
namespace Tests; namespace Tests;
use InvalidArgumentException; use InvalidArgumentException;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Sisoft\Calculadora\Operaciones; use Sisoft\Calculadora\Operaciones;
use Sisoft\Excepciones\MiPrimeraExcepcion; use Sisoft\Excepciones\MiPrimeraExcepcion;
//TDD importante estudiar //TDD importante estudiar
class OperacionesTests extends TestCase class OperacionesTest extends TestCase
{ {
private $op; private $op;
......
<?php
namespace Tests;
use \Mockery;
use Sisoft\Temperature\Temperature;
class TemperatureTest extends \PHPUnit\Framework\TestCase
{
public function testGetsAverageTemperatureFromThreeServiceReadings()
{
$service = Mockery::mock('External\Service');
$service->shouldReceive('leerTemperatura')
->times(3)
->andReturn(12, 10, 14);
$temperature = new Temperature($service);
$this->assertEquals(12, $temperature->average());
}
}
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