mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Split up tests
This commit is contained in:
parent
2b8c38f474
commit
85dd4a6d97
|
|
@ -64,14 +64,12 @@ class AssetManagerTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(2, $manager->count());
|
||||
|
||||
/* Test remove */
|
||||
$rem = $manager->remove('myAsset');
|
||||
self::assertTrue($rem);
|
||||
self::assertTrue($manager->remove('myAsset'));
|
||||
self::assertEquals(1, $manager->count());
|
||||
|
||||
self::assertNull($manager->get('myAsset'));
|
||||
|
||||
$rem = $manager->remove('myAsset');
|
||||
self::assertFalse($rem);
|
||||
self::assertFalse($manager->remove('myAsset'));
|
||||
self::assertEquals(1, $manager->count());
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,28 @@ namespace phpOMS\tests;
|
|||
|
||||
class ExtensionTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testExtension()
|
||||
public function testExtensionMbstring()
|
||||
{
|
||||
self::assertTrue(extension_loaded('mbstring'));
|
||||
}
|
||||
|
||||
public function testExtensionCurl()
|
||||
{
|
||||
self::assertTrue(extension_loaded('curl'));
|
||||
}
|
||||
|
||||
public function testExtensionImap()
|
||||
{
|
||||
self::assertTrue(extension_loaded('imap'));
|
||||
}
|
||||
|
||||
public function testExtensionPdo()
|
||||
{
|
||||
self::assertTrue(extension_loaded('pdo'));
|
||||
}
|
||||
|
||||
public function testExtensionGD()
|
||||
{
|
||||
self::assertTrue(extension_loaded('gd') || extension_loaded('gd2'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,37 +32,75 @@ class ComplexTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(2, $cpl->im());
|
||||
}
|
||||
|
||||
public function testBasics()
|
||||
public function testAdd()
|
||||
{
|
||||
$cpl1 = new Complex(2, 3);
|
||||
$cpl2 = new Complex(3, 4);
|
||||
|
||||
self::assertEquals('5.00 + 7.00i', $cpl1->add($cpl2)->render());
|
||||
self::assertEquals('6.00 + 3.00i', $cpl1->add(4)->render());
|
||||
}
|
||||
|
||||
public function testSub()
|
||||
{
|
||||
$cpl1 = new Complex(2, 3);
|
||||
$cpl2 = new Complex(3, 4);
|
||||
|
||||
self::assertEquals('-1.00 - 1.00i', $cpl1->sub($cpl2)->render());
|
||||
self::assertEquals('-2.00 + 3.00i', $cpl1->sub(4)->render());
|
||||
}
|
||||
|
||||
public function testMult()
|
||||
{
|
||||
$cpl1 = new Complex(2, 3);
|
||||
$cpl2 = new Complex(3, 4);
|
||||
|
||||
self::assertEquals('-6.00 + 17.00i', $cpl1->mult($cpl2)->render());
|
||||
self::assertEquals('8.00 + 12.00i', $cpl1->mult(4)->render());
|
||||
}
|
||||
|
||||
public function testDiv()
|
||||
{
|
||||
$cpl1 = new Complex(2, 3);
|
||||
$cpl2 = new Complex(3, 4);
|
||||
|
||||
self::assertEquals('0.72 + 0.04i', $cpl1->div($cpl2)->render(2));
|
||||
self::assertEquals('0.50 + 0.75i', $cpl1->div(4)->render(2));
|
||||
}
|
||||
|
||||
public function testSpecial()
|
||||
public function testConjugate()
|
||||
{
|
||||
$cpl = new Complex(4, 3);
|
||||
|
||||
self::assertEquals('4 - 3i', $cpl->conjugate()->render(0));
|
||||
}
|
||||
|
||||
public function testReciprocal()
|
||||
{
|
||||
$cpl = new Complex(4, 3);
|
||||
|
||||
self::assertEquals('0.16 - 0.12i', $cpl->reciprocal()->render(2));
|
||||
}
|
||||
|
||||
public function testPower()
|
||||
{
|
||||
$cpl = new Complex(4, 3);
|
||||
|
||||
self::assertEquals('7.00 + 24.00i', $cpl->square()->render());
|
||||
self::assertEquals('7.00 + 24.00i', $cpl->pow(2)->render());
|
||||
self::assertEquals('-44.00 + 117.00i', $cpl->pow(3)->render());
|
||||
}
|
||||
|
||||
public function testAbs()
|
||||
{
|
||||
$cpl = new Complex(4, 3);
|
||||
|
||||
self::assertEquals(5, $cpl->abs(), '', 0.01);
|
||||
}
|
||||
|
||||
public function testSqrt()
|
||||
{
|
||||
$cpl = new Complex(4, 3);
|
||||
self::assertEquals('2.12 + 0.71i', $cpl->sqrt()->render());
|
||||
|
||||
$cpl2 = new Complex(-1, 3);
|
||||
|
|
|
|||
|
|
@ -17,16 +17,22 @@ use phpOMS\Math\Number\Integer;
|
|||
|
||||
class IntegerTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testInteger()
|
||||
public function testIsInteger()
|
||||
{
|
||||
self::assertTrue(Integer::isInteger(4));
|
||||
self::assertFalse(Integer::isInteger(1.0));
|
||||
self::assertFalse(Integer::isInteger('3'));
|
||||
}
|
||||
|
||||
public function testFactorization()
|
||||
{
|
||||
self::assertArraySubset([2, 2, 5, 5], Integer::trialFactorization(100));
|
||||
self::assertArraySubset([2], Integer::trialFactorization(2));
|
||||
self::assertEquals([], Integer::trialFactorization(1));
|
||||
}
|
||||
|
||||
public function testOther()
|
||||
{
|
||||
self::assertEquals(101, Integer::pollardsRho(10403, 2, 1, 2, 2));
|
||||
|
||||
self::assertEquals([59, 101], Integer::fermatFactor(5959));
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use phpOMS\Math\Number\Natural;
|
|||
|
||||
class NaturalTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
public function testNatural()
|
||||
public function testIsNatural()
|
||||
{
|
||||
self::assertTrue(Natural::isNatural(1235));
|
||||
self::assertTrue(Natural::isNatural(0));
|
||||
|
|
|
|||
|
|
@ -37,7 +37,10 @@ class NumbersTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertTrue(Numbers::isSquare(81));
|
||||
self::assertTrue(Numbers::isSquare(6561));
|
||||
self::assertFalse(Numbers::isSquare(5545348));
|
||||
}
|
||||
|
||||
public function testZeroCounting()
|
||||
{
|
||||
self::assertEquals(3, Numbers::countTrailingZeros(1000));
|
||||
self::assertEquals(5, Numbers::countTrailingZeros(12300000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class CommitTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertInstanceOf('\DateTime', $commit->getDate());
|
||||
}
|
||||
|
||||
public function testGetSet()
|
||||
public function testAddRemoveFile()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
|
|
@ -51,23 +51,54 @@ class CommitTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals([
|
||||
'/some/file/path2' => []
|
||||
], $commit->getFiles());
|
||||
}
|
||||
|
||||
public function testMessage()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setMessage('My Message');
|
||||
self::assertEquals('My Message', $commit->getMessage());
|
||||
}
|
||||
|
||||
public function testAuthor()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setAuthor(new Author('Orange'));
|
||||
self::assertEquals('Orange', $commit->getAuthor()->getName());
|
||||
}
|
||||
|
||||
public function testBranch()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setBranch(new Branch('develop'));
|
||||
self::assertEquals('develop', $commit->getBranch()->getName());
|
||||
}
|
||||
|
||||
public function testTag()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setTag(new Tag('1.0.0'));
|
||||
self::assertEquals('1.0.0', $commit->getTag()->getName());
|
||||
}
|
||||
|
||||
public function testDate()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setDate($date = new \DateTime('now'));
|
||||
self::assertEquals($date->format('Y-m-d'), $commit->getDate()->format('Y-m-d'));
|
||||
}
|
||||
|
||||
public function testRepository()
|
||||
{
|
||||
$commit = new Commit();
|
||||
|
||||
$commit->setRepository(new Repository(realpath(__DIR__ . '/../../../')));
|
||||
self::assertEquals(realpath(__DIR__ . '/../../../'), $commit->getRepository()->getPath());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user