Skip to content

Commit

Permalink
add strict_types in UTs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogiovinazzi committed Nov 15, 2021
1 parent f0a3242 commit 293efb1
Show file tree
Hide file tree
Showing 19 changed files with 222 additions and 205 deletions.
5 changes: 3 additions & 2 deletions tests/Comodojo/Foundation/Base/ConfigurationLoaderTest.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\Base;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\Base;

use \Comodojo\Foundation\Base\ConfigurationLoader;
use \PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -27,5 +29,4 @@ public function testConfiguration()
{
$this->assertEquals(300, $this->config->get("routing-table-ttl"));
}

}
14 changes: 3 additions & 11 deletions tests/Comodojo/Foundation/Base/ConfigurationTest.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\Base;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\Base;

use \Comodojo\Foundation\Base\Configuration;
use \PHPUnit\Framework\TestCase;
Expand All @@ -24,14 +26,12 @@ protected function setUp(): void
];

$this->config = new Configuration($test_values);

}

protected function tearDown(): void
{

unset($this->config);

}

public function testGetSetDelete()
Expand All @@ -52,7 +52,6 @@ public function testGetSetDelete()
$remove = $this->config->get("t");

$this->assertNull($remove);

}

public function testGetAll()
Expand All @@ -64,7 +63,6 @@ public function testGetAll()

$this->assertEquals($config["c"], 42);
$this->assertEquals($config["a"]["a"], 'lorem');

}

public function testHas()
Expand All @@ -75,7 +73,6 @@ public function testHas()
$this->assertTrue($this->config->isDefined('a'));

$this->assertFalse($this->config->has('z'));

}

public function testWholeDelete()
Expand All @@ -84,7 +81,6 @@ public function testWholeDelete()
$this->assertTrue($result = $this->config->delete());

$this->assertFalse($this->config->isDefined('a'));

}

public function testMerge()
Expand All @@ -96,7 +92,6 @@ public function testMerge()

$this->assertFalse($this->config->get('a'));
$this->assertTrue($this->config->get('b'));

}

public function testSelectiveCrud()
Expand All @@ -122,7 +117,6 @@ public function testSelectiveCrud()
$this->assertArrayNotHasKey('amet', $ac_value);

$this->assertFalse($this->config->has("a.c.amet"));

}

public function testStaticConstructor()
Expand All @@ -133,7 +127,5 @@ public function testStaticConstructor()
$this->assertInstanceOf('\\Comodojo\\Foundation\\Base\\Configuration', $config);
$this->assertEquals("is", $config->get("this"));
$this->assertIsArray($config->get("a"));

}

}
7 changes: 3 additions & 4 deletions tests/Comodojo/Foundation/Base/ParametersTraitTest.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Dispatcher\Tests\Components;
<?php declare(strict_types=1);

namespace Comodojo\Dispatcher\Tests\Components;

use \Comodojo\Foundation\Base\ParametersTrait;
use \PHPUnit\Framework\TestCase;
Expand All @@ -16,7 +18,6 @@ protected function setUp(): void
{

$this->set($this->param, $this->value);

}

public function testParameters()
Expand All @@ -43,7 +44,5 @@ public function testParameters()
$params = $this->get();

$this->assertEquals(0, count($params));

}

}
15 changes: 6 additions & 9 deletions tests/Comodojo/Foundation/Base/VersionTest.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\Base;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\Base;

use Comodojo\Foundation\Tests\Mock\Version;
use \Comodojo\Foundation\Base\ConfigurationLoader;
Expand All @@ -12,9 +14,9 @@ class VersionTest extends TestCase
protected $name = 'Heart of Gold';
protected $description = 'The first spacecraft to make use of the Infinite Improbability Drive';
protected $version = '42';
protected $ascii = "/r/n _ __ /r/n".
"|_| _ _ ___|_ _ _|_ /__ _ | _|/r/n".
"| |(/_(_| | |_ (_) | \_|(_) | (_|/r/n";
protected $ascii = "/r/n _ __ /r/n" .
"|_| _ _ ___|_ _ _|_ /__ _ | _|/r/n" .
"| |(/_(_| | |_ (_) | \_|(_) | (_|/r/n";

protected $template = "{name} + {description} + {version}";

Expand All @@ -27,14 +29,12 @@ protected function setUp(): void
$this->config = ConfigurationLoader::load($config_file, [
'base-path' => $basepath,
]);

}

protected function tearDown(): void
{

unset($this->config);

}

public function testVersion()
Expand All @@ -46,7 +46,6 @@ public function testVersion()
$this->assertEquals($this->description, $version->getDescription());
$this->assertEquals($this->version, $version->getVersion());
$this->assertEquals($this->ascii, $version->getAscii());

}

public function testVersionConfigurationOverride()
Expand All @@ -56,7 +55,5 @@ public function testVersionConfigurationOverride()

$this->assertEquals('42 is the new black', $version->getName());
$this->assertEquals($this->description, $version->getDescription());

}

}
11 changes: 7 additions & 4 deletions tests/Comodojo/Foundation/DataAccess/MockPdModel.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\DataAccess;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\DataAccess;

use \Comodojo\Foundation\DataAccess\Model;

Expand All @@ -18,7 +20,8 @@
* THE SOFTWARE.
*/

class MockPdModel extends Model {
class MockPdModel extends Model
{

protected int $mode = self::PROTECTDATA;

Expand All @@ -27,8 +30,8 @@ class MockPdModel extends Model {
"answer" => 42
];

public function mockSetRaw($name, $value) {
public function mockSetRaw($name, $value)
{
return $this->setRaw($name, $value);
}

}
11 changes: 7 additions & 4 deletions tests/Comodojo/Foundation/DataAccess/MockRoModel.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\DataAccess;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\DataAccess;

use \Comodojo\Foundation\DataAccess\Model;

Expand All @@ -18,7 +20,8 @@
* THE SOFTWARE.
*/

class MockRoModel extends Model {
class MockRoModel extends Model
{

protected int $mode = self::READONLY;

Expand All @@ -27,8 +30,8 @@ class MockRoModel extends Model {
"answer" => 42
];

public function mockSetRaw($name, $value) {
public function mockSetRaw($name, $value)
{
return $this->setRaw($name, $value);
}

}
8 changes: 5 additions & 3 deletions tests/Comodojo/Foundation/DataAccess/MockRwModel.php
@@ -1,4 +1,6 @@
<?php namespace Comodojo\Foundation\Tests\DataAccess;
<?php declare(strict_types=1);

namespace Comodojo\Foundation\Tests\DataAccess;

use \Comodojo\Foundation\DataAccess\Model;

Expand All @@ -18,13 +20,13 @@
* THE SOFTWARE.
*/

class MockRwModel extends Model {
class MockRwModel extends Model
{

protected int $mode = self::READWRITE;

protected array $data = [
"question" => "Ultimate Question of Life, The Universe, and Everything",
"answer" => 42
];

}

0 comments on commit 293efb1

Please sign in to comment.