Skip to content

Commit 5bf86cb

Browse files
committed
Preparing test
1 parent 3b5a520 commit 5bf86cb

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
._*
22
.DS_Store
3-
.sass-cache
3+
.sass-cache
4+
composer.lock
5+
vendor

Inp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public function __construct(mixed $value)
5252
$this->dateTime = new DateTime("now");
5353
if(is_string($value) || is_numeric($value)) {
5454
$this->length = $this->getLength($value);
55+
$this->getStr = new Str($this->value);
5556
}
56-
$this->getStr = new Str((string)$this->value);
5757
}
5858

5959
/**

composer.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
"require": {
1919
"php": ">=8.0",
2020
"maplephp/dto": "^1.0"
21+
},
22+
"require-dev": {
23+
"maplephp/unitary": "^1.0"
24+
},
25+
"replace": {
26+
"maplephp/validate": "self.version"
2127
},
2228
"autoload": {
2329
"psr-4": {

tests/unitary-test.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env php
2+
<?php
3+
/**
4+
* This is how a template test file should look like but
5+
* when used in MaplePHP framework you can skip the "bash code" at top and the "autoload file"!
6+
*/
7+
use MaplePHP\Unitary\Unit;
8+
9+
if (!class_exists(Unit::class)) {
10+
$dir = realpath(dirname(__FILE__)."/..");
11+
if(is_file("$dir/vendor/autoload.php")) {
12+
require_once("$dir/vendor/autoload.php");
13+
} else {
14+
die("Please run 'composer install' before running the example test suite");
15+
}
16+
}
17+
18+
// If you add true to Unit it will run in quite mode
19+
// and only report if it finds any errors!
20+
$unit = new Unit(true);
21+
22+
// Add a title to your tests (not required)
23+
$unit->addTitle("Testing MaplePHP Unitary library!");
24+
$unit->add("Checking data type", function($inst) {
25+
26+
$inst->add("Lorem ipsum dolor", [
27+
"string" => [],
28+
"length" => [1,200]
29+
30+
])->add(92928, [
31+
"int" => []
32+
33+
])->add("Lorem", [
34+
"string" => [],
35+
"length" => function($valid) {
36+
return $valid->length(1, 50);
37+
}
38+
], "The length is not correct!");
39+
40+
});
41+
42+
$unit->execute();
43+

0 commit comments

Comments
 (0)