feat(structure): add region/city structure model with validation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
44
viator-collector/tests/run.php
Normal file
44
viator-collector/tests/run.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
* Minimal test runner for the WordPress-free parts of the plugin.
|
||||
*
|
||||
* php tests/run.php
|
||||
*/
|
||||
|
||||
define( 'ABSPATH', __DIR__ . '/' );
|
||||
|
||||
require_once dirname( __DIR__ ) . '/includes/class-vc-structure.php';
|
||||
|
||||
function vc_assert_same( $expected, $actual, $msg = '' ) {
|
||||
if ( $expected !== $actual ) {
|
||||
throw new Exception( $msg . "\n expected: " . var_export( $expected, true ) . "\n actual: " . var_export( $actual, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
function vc_assert_contains( $needle, array $errors ) {
|
||||
if ( ! in_array( $needle, $errors, true ) ) {
|
||||
throw new Exception( 'Missing error: ' . $needle . "\n got: " . var_export( $errors, true ) );
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( glob( __DIR__ . '/test-*.php' ) as $file ) {
|
||||
require_once $file;
|
||||
}
|
||||
|
||||
$passed = 0;
|
||||
$failed = 0;
|
||||
foreach ( get_defined_functions()['user'] as $fn ) {
|
||||
if ( 0 !== strpos( $fn, 'test_' ) ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$fn();
|
||||
$passed++;
|
||||
} catch ( Throwable $e ) {
|
||||
$failed++;
|
||||
echo 'FAIL ' . $fn . ': ' . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
echo $passed . ' passed, ' . $failed . " failed\n";
|
||||
exit( $failed ? 1 : 0 );
|
||||
Reference in New Issue
Block a user