Skip to content

Commit

Permalink
adapt phpunit for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
he426100 authored and he426100 committed Jan 12, 2024
1 parent 3e80730 commit bbc6a95
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions tests/phpunit/CoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public function testStr()

public function testRepr()
{
$os = PyCore::import("os");
$repr = PyCore::repr($os->uname());
$this->assertStringContainsString('posix.uname_result', $repr);
$platform = PyCore::import("platform");
$repr = PyCore::repr($platform->uname());
$this->assertStringContainsString('uname_result', $repr);
}

public function testId()
Expand All @@ -37,9 +37,9 @@ public function testId()

public function testType()
{
$os = PyCore::import("os");
$this->assertEquals("<class 'module'>", PyCore::type($os));
$this->assertEquals("<class 'posix.uname_result'>", PyCore::type($os->uname()));
$platform = PyCore::import("platform");
$this->assertEquals("<class 'module'>", PyCore::type($platform));
$this->assertEquals("<class 'platform.uname_result'>", PyCore::type($platform->uname()));

$dict = new PyDict();
$this->assertEquals("<class 'dict'>", PyCore::type($dict));
Expand All @@ -56,17 +56,17 @@ function testHash()

function testHasAttr()
{
$os = PyCore::import("os");
$this->assertTrue(PyCore::hasattr($os, 'uname'));
$this->assertFalse(PyCore::hasattr($os, 'not_exists'));
$platform = PyCore::import("platform");
$this->assertTrue(PyCore::hasattr($platform, 'uname'));
$this->assertFalse(PyCore::hasattr($platform, 'not_exists'));
}

function testLen()
{
$os = PyCore::import("os");
$uname = $os->uname();
$this->assertEquals(5, PyCore::len($uname));
$this->assertGreaterThan(100, strlen(PyCore::str($uname)));
$platform = PyCore::import("platform");
$uname = $platform->uname();
$this->assertGreaterThan(5, PyCore::len($uname));
$this->assertGreaterThan(90, strlen(PyCore::str($uname)));

$n = 14;
$list = new PyList;
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/IterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class IterTest extends TestCase
{
function testIter()
{
$os = PyCore::import('os');
$uname = $os->uname();
$platform = PyCore::import('platform');
$uname = $platform->uname();

$iter = PyCore::iter($uname);
$this->assertTrue($iter instanceof PyIter);
Expand All @@ -17,7 +17,7 @@ function testIter()
$list[] = PyCore::scalar($next);
}
$this->assertIsArray($list);
$this->assertEquals(count($list), 5);
$this->assertGreaterThanOrEqual(5, count($list));
}

function testNewIter()
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit/ModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class ModuleTest extends TestCase
{
public function testImport()
{
$os = PyLoader::import('os');
$uname = $os->uname();
$this->assertEquals($uname->sysname, 'Linux');
$platform = PyLoader::import('platform');
$uname = $platform->uname();
$this->assertStringContainsStringIgnoringCase([PHP_OS, 'WIN'][str_starts_with(PHP_OS, 'WIN')], (string)$uname->system);
}

public function testNewObject()
Expand Down

0 comments on commit bbc6a95

Please sign in to comment.