Public Access
033e948c79
Generic: Repo Health / Scripts governance (push) Blocked by required conditions
Generic: Repo Health / Repository health (push) Blocked by required conditions
Generic: Repo Health / Report Issues (push) Blocked by required conditions
Platform: mokoplatform CI / Gate 2: Unit Tests (8.1) (pull_request) Blocked by required conditions
Platform: mokoplatform CI / Gate 2: Unit Tests (8.2) (pull_request) Blocked by required conditions
Platform: mokoplatform CI / Gate 2: Unit Tests (8.3) (pull_request) Blocked by required conditions
Platform: mokoplatform CI / Gate 3: Self-Health Check (pull_request) Blocked by required conditions
Platform: mokoplatform CI / Gate 4: Governance (pull_request) Blocked by required conditions
Platform: mokoplatform CI / Gate 5: Template Integrity (pull_request) Blocked by required conditions
Platform: mokoplatform CI / CI Summary (pull_request) Blocked by required conditions
Universal: PR Check / Build RC Package (pull_request) Blocked by required conditions
Universal: PR Check / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Scripts governance (pull_request) Blocked by required conditions
Generic: Repo Health / Repository health (pull_request) Blocked by required conditions
Generic: Repo Health / Report Issues (pull_request) Blocked by required conditions
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Universal: PR Check / Branch Policy (pull_request) Failing after 2s
Generic: Repo Health / Access control (pull_request) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Failing after 7s
Universal: Security Audit / Dependency Audit (pull_request) Successful in 7s
Universal: Auto Version Bump / Version Bump (push) Successful in 14s
Platform: mokoplatform CI / Gate 1: Code Quality (pull_request) Failing after 1m8s
- Add `security:advisories` command — cross-repo CVE scanner via composer audit with checkpoint resumability, severity filtering, and auto-issue creation - Rewrite `manifest:read` to use Gitea manifest API as primary source with auto-detection fallback from source tree (no more manifest.xml dependency) - Rename MokoStandards namespace → MokoCli across all files - Rename MokoEnterprise namespace → MokoCli across all files - Rename MokoStandardsParser class → ManifestParser - Fix composer.json autoload paths: src/ → source/
142 lines
3.8 KiB
PHP
142 lines
3.8 KiB
PHP
<?php
|
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MokoCli\Tests\Unit;
|
|
|
|
use MokoCli\ConfigValidator;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class ConfigValidatorTest extends TestCase
|
|
{
|
|
private ConfigValidator $validator;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->validator = new ConfigValidator();
|
|
}
|
|
|
|
public function testValidConfigPasses(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'name' => ['type' => 'string'],
|
|
'version' => ['type' => 'string'],
|
|
],
|
|
'required' => ['name'],
|
|
];
|
|
|
|
$config = ['name' => 'MyProject', 'version' => '1.0'];
|
|
|
|
$this->assertTrue($this->validator->validate($config, $schema));
|
|
$this->assertEmpty($this->validator->getErrors());
|
|
}
|
|
|
|
public function testMissingRequiredField(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'name' => ['type' => 'string'],
|
|
],
|
|
'required' => ['name'],
|
|
];
|
|
|
|
$this->assertFalse($this->validator->validate([], $schema));
|
|
$this->assertStringContainsString(
|
|
'required',
|
|
$this->validator->getErrors()[0]
|
|
);
|
|
}
|
|
|
|
public function testEnumValidation(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'type' => [
|
|
'type' => 'string',
|
|
'enum' => ['component', 'module', 'plugin'],
|
|
],
|
|
],
|
|
];
|
|
|
|
$valid = ['type' => 'component'];
|
|
$this->assertTrue($this->validator->validate($valid, $schema));
|
|
|
|
$invalid = ['type' => 'banana'];
|
|
$this->assertFalse($this->validator->validate($invalid, $schema));
|
|
}
|
|
|
|
public function testNestedObjectValidation(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'db' => [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'host' => ['type' => 'string'],
|
|
'port' => ['type' => 'integer'],
|
|
],
|
|
'required' => ['host'],
|
|
],
|
|
],
|
|
];
|
|
|
|
$valid = ['db' => ['host' => 'localhost', 'port' => 3306]];
|
|
$this->assertTrue($this->validator->validate($valid, $schema));
|
|
|
|
$invalid = ['db' => ['port' => 3306]];
|
|
$this->assertFalse($this->validator->validate($invalid, $schema));
|
|
}
|
|
|
|
public function testUnknownPropertiesWarn(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'name' => ['type' => 'string'],
|
|
],
|
|
];
|
|
|
|
$config = ['name' => 'ok', 'extra' => 'unknown'];
|
|
$this->assertTrue($this->validator->validate($config, $schema));
|
|
$this->assertNotEmpty($this->validator->getWarnings());
|
|
}
|
|
|
|
public function testTypeMismatch(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'count' => ['type' => 'integer'],
|
|
],
|
|
];
|
|
|
|
$invalid = ['count' => 'not-a-number'];
|
|
$this->assertFalse($this->validator->validate($invalid, $schema));
|
|
}
|
|
|
|
public function testStringMinLength(): void
|
|
{
|
|
$schema = [
|
|
'type' => 'object',
|
|
'properties' => [
|
|
'name' => ['type' => 'string', 'minLength' => 3],
|
|
],
|
|
];
|
|
|
|
$short = ['name' => 'ab'];
|
|
$this->assertFalse($this->validator->validate($short, $schema));
|
|
|
|
$ok = ['name' => 'abc'];
|
|
$this->assertTrue($this->validator->validate($ok, $schema));
|
|
}
|
|
}
|