Skip to content

Instantly share code, notes, and snippets.

@labra
Created October 9, 2014 12:40
Show Gist options
  • Save labra/0430c8f00db9f4198421 to your computer and use it in GitHub Desktop.
Save labra/0430c8f00db9f4198421 to your computer and use it in GitHub Desktop.
Ejercicio PHP: factores primos
<?php
require_once 'primos.php';
class PrimosTest extends PHPUnit_Framework_TestCase
{
function test_create_class() {
$a = new Primos();
$this->assertTrue(is_a($a, 'Primos'));
}
// ...
/**
* @dataProvider factoresProvider
*/
public function testFactores($n, $esperados) {
$p = new Primos();
$this->assertEquals($esperados, $p->factores($n));
}
public function factoresProvider()
{
return array(
array(1, [1]),
array(2, [1,2]),
array(3, [1,3]),
array(4, [1,2,2]),
array(5, [1,5]),
array(6, [1,2,3]),
array(24, [1,2,2,2,3]),
array(25, [1,5,5]),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment