refactor: Cleanup git state - commit all staged changes
Major refactoring cleanup: - Add new controller architecture (class-controller-*.php) - Add new settings-v2 UI (views/settings-v2/) - Add new CSS architecture (agentic-sidebar.css, tokens) - Add esbuild build pipeline (scripts/build.js, package.json) - Add composer dependencies (vendor/) - Add frontend src directory (assets/js/src/index.jsx) - Add documentation files - Remove old/obsolete files (class-settings.php, old CSS) This commits all pending changes from previous refactoring efforts.
This commit is contained in:
40
tests/README.md
Normal file
40
tests/README.md
Normal file
@@ -0,0 +1,40 @@
|
||||
# Unit Tests
|
||||
|
||||
## Setup
|
||||
|
||||
```bash
|
||||
# Install dependencies
|
||||
composer install
|
||||
|
||||
# Run all tests
|
||||
./vendor/bin/phpunit
|
||||
|
||||
# Run specific test file
|
||||
./vendor/bin/phpunit tests/test-model-registry.php
|
||||
|
||||
# Run with testdox output
|
||||
./vendor/bin/phpunit --testdox
|
||||
|
||||
# Generate coverage report
|
||||
./vendor/bin/phpunit --testdox --coverage-html coverage
|
||||
```
|
||||
|
||||
## Test Structure
|
||||
|
||||
| File | Class Under Test | Coverage |
|
||||
|------|-----------------|----------|
|
||||
| `test-model-registry.php` | `WPAW_Model_Registry` | Model defaults, validation, display names |
|
||||
|
||||
## Adding Tests
|
||||
|
||||
1. Create a new file in `tests/` with the naming convention `test-{class-name}.php`
|
||||
2. Class name should be `Test_{ClassName}` extending `PHPUnit\Framework\TestCase`
|
||||
3. Add the class require to `tests/bootstrap.php` if the class is not autoloaded
|
||||
4. Run tests to verify
|
||||
|
||||
## Running Without Composer
|
||||
|
||||
If PHPUnit is installed globally:
|
||||
```bash
|
||||
phpunit --bootstrap tests/bootstrap.php tests/
|
||||
```
|
||||
404
tests/bootstrap.php
Normal file
404
tests/bootstrap.php
Normal file
@@ -0,0 +1,404 @@
|
||||
<?php
|
||||
/**
|
||||
* PHPUnit Bootstrap
|
||||
*
|
||||
* Sets up the minimal WordPress environment for testing.
|
||||
*
|
||||
* @package WP_Agentic_Writer
|
||||
*/
|
||||
|
||||
// Define plugin constants if not already defined.
|
||||
if (!defined('WPAW_PLUGIN_DIR')) {
|
||||
define('WPAW_PLUGIN_DIR', dirname(__DIR__) . '/');
|
||||
}
|
||||
|
||||
if (!defined('WP_AGENTIC_WRITER_URL')) {
|
||||
define('WP_AGENTIC_WRITER_URL', 'http://localhost/');
|
||||
}
|
||||
|
||||
// WordPress stub functions.
|
||||
if (!function_exists('wp_json_encode')) {
|
||||
function wp_json_encode($data, $options = 0, $depth = 512) {
|
||||
return json_encode($data, $options, $depth);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_parse_args')) {
|
||||
function wp_parse_args($args, $defaults = []) {
|
||||
if (is_array($args)) {
|
||||
return array_merge($defaults, $args);
|
||||
}
|
||||
parse_str($args, $r);
|
||||
return array_merge($defaults, $r);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sanitize_text_field')) {
|
||||
function sanitize_text_field($str) {
|
||||
return trim(strip_tags($str));
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('sanitize_textarea_field')) {
|
||||
function sanitize_textarea_field($str) {
|
||||
return sanitize_text_field($str);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('untrailingslashit')) {
|
||||
function untrailingslashit($str) {
|
||||
return rtrim($str, '/\\');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('trailingslashit')) {
|
||||
function trailingslashit($str) {
|
||||
return rtrim($str, '/\\') . '/';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_option')) {
|
||||
function get_option($key, $default = false) {
|
||||
static $options = [];
|
||||
return $options[$key] ?? $default;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('update_option')) {
|
||||
function update_option($key, $value) {
|
||||
static $options = [];
|
||||
$options[$key] = $value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_post_meta')) {
|
||||
function get_post_meta($post_id, $key = '', $single = false) {
|
||||
static $meta = [];
|
||||
if ($key === '') {
|
||||
return $meta[$post_id] ?? [];
|
||||
}
|
||||
if ($single) {
|
||||
return $meta[$post_id][$key][0] ?? '';
|
||||
}
|
||||
return $meta[$post_id][$key] ?? [];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_transient')) {
|
||||
function get_transient($key) {
|
||||
static $transients = [];
|
||||
return $transients[$key] ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('set_transient')) {
|
||||
function set_transient($key, $value, $expiration = 0) {
|
||||
static $transients = [];
|
||||
$transients[$key] = $value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('delete_transient')) {
|
||||
function delete_transient($key) {
|
||||
static $transients = [];
|
||||
unset($transients[$key]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_remote_post')) {
|
||||
function wp_remote_post($url, $args = []) {
|
||||
return new WP_Error('http_request_failed', 'cURL error 7: Failed to connect to host');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_remote_get')) {
|
||||
function wp_remote_get($url, $args = []) {
|
||||
return new WP_Error('http_request_failed', 'cURL error 7: Failed to connect to host');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_remote_retrieve_response_code')) {
|
||||
function wp_remote_retrieve_response_code($response) {
|
||||
if (is_wp_error($response)) {
|
||||
return 0;
|
||||
}
|
||||
return $response['response']['code'] ?? 200;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_remote_retrieve_body')) {
|
||||
function wp_remote_retrieve_body($response) {
|
||||
if (is_wp_error($response)) {
|
||||
return '';
|
||||
}
|
||||
return $response['body'] ?? '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_strip_all_tags')) {
|
||||
function wp_strip_all_tags($string) {
|
||||
return strip_tags($string);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('__')) {
|
||||
function __($text, $domain = 'default') {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('esc_html__')) {
|
||||
function esc_html__($text, $domain = 'default') {
|
||||
return esc_html($text);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('esc_attr__')) {
|
||||
function esc_attr__($text, $domain = 'default') {
|
||||
return esc_attr($text);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('esc_html')) {
|
||||
function esc_html($text) {
|
||||
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('esc_attr')) {
|
||||
function esc_attr($text) {
|
||||
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('esc_url')) {
|
||||
function esc_url($url) {
|
||||
return filter_var($url, FILTER_SANITIZE_URL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_wp_error')) {
|
||||
function is_wp_error($thing) {
|
||||
return $thing instanceof WP_Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_send_json_success')) {
|
||||
function wp_send_json_success($data = null, $status = null) {
|
||||
echo json_encode(['success' => true, 'data' => $data]);
|
||||
if ($status) {
|
||||
http_response_code($status);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_send_json_error')) {
|
||||
function wp_send_json_error($data = null, $status = null) {
|
||||
echo json_encode(['success' => false, 'data' => $data]);
|
||||
if ($status) {
|
||||
http_response_code($status);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('current_time')) {
|
||||
function current_time($type) {
|
||||
return time();
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_cache_get')) {
|
||||
function wp_cache_get($key, $group = '') {
|
||||
static $cache = [];
|
||||
return $cache[$group][$key] ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_cache_set')) {
|
||||
function wp_cache_set($key, $data, $group = '', $expire = 0) {
|
||||
static $cache = [];
|
||||
$cache[$group][$key] = $data;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_cache_delete')) {
|
||||
function wp_cache_delete($key, $group = '') {
|
||||
static $cache = [];
|
||||
unset($cache[$group][$key]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('did_action')) {
|
||||
function did_action($hook) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('add_action')) {
|
||||
function add_action($hook, $callback, $priority = 10, $accepted_args = 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('add_filter')) {
|
||||
function add_filter($hook, $callback, $priority = 10, $accepted_args = 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('apply_filters')) {
|
||||
function apply_filters($tag, $value) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('doing_action')) {
|
||||
function doing_action($hook) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_die')) {
|
||||
function wp_die($message = '', $title = '', $args = []) {
|
||||
echo $message;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('error_log')) {
|
||||
function error_log($message) {
|
||||
fwrite(STDERR, $message . PHP_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wpautop')) {
|
||||
function wpautop($text) {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_user_by')) {
|
||||
function get_user_by($field, $value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_current_user_id')) {
|
||||
function get_current_user_id() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('current_user_can')) {
|
||||
function current_user_can($capability, ...$args) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('is_user_logged_in')) {
|
||||
function is_user_logged_in() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_post')) {
|
||||
function get_post($post) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_post_type')) {
|
||||
function get_post_type($post = null) {
|
||||
return 'post';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_the_title')) {
|
||||
function get_the_title($post = 0) {
|
||||
return 'Test Post';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('get_post_status')) {
|
||||
function get_post_status($post = null) {
|
||||
return 'publish';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('wp_kses_post')) {
|
||||
function wp_kses_post($string) {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('mb_substr')) {
|
||||
function mb_substr($str, $start, $length = null) {
|
||||
if ($length === null) {
|
||||
return substr($str, $start);
|
||||
}
|
||||
return substr($str, $start, $length);
|
||||
}
|
||||
}
|
||||
|
||||
// WP_Error stub class.
|
||||
class WP_Error {
|
||||
public $errors = [];
|
||||
public $error_data = [];
|
||||
|
||||
public function __construct($code = '', $message = '', $data = '') {
|
||||
if (!empty($code)) {
|
||||
$this->errors[$code] = [$message];
|
||||
$this->error_data[$code] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_error_code() {
|
||||
$codes = $this->get_error_codes();
|
||||
return $codes[0] ?? '';
|
||||
}
|
||||
|
||||
public function get_error_message($code = '') {
|
||||
if (empty($code)) {
|
||||
$code = $this->get_error_code();
|
||||
}
|
||||
return $this->errors[$code][0] ?? '';
|
||||
}
|
||||
|
||||
public function get_error_codes() {
|
||||
return array_keys($this->errors);
|
||||
}
|
||||
|
||||
public function get_error_data($code = '') {
|
||||
if (empty($code)) {
|
||||
$code = $this->get_error_code();
|
||||
}
|
||||
return $this->error_data[$code] ?? '';
|
||||
}
|
||||
|
||||
public function add($code, $message, $data = '') {
|
||||
$this->errors[$code][] = $message;
|
||||
if (!empty($data)) {
|
||||
$this->error_data[$code] = $data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WP_Post stub class.
|
||||
class WP_Post {
|
||||
public $ID = 0;
|
||||
public $post_author = 1;
|
||||
public $post_title = '';
|
||||
public $post_content = '';
|
||||
public $post_status = 'publish';
|
||||
public $post_type = 'post';
|
||||
}
|
||||
|
||||
// Load the plugin files we want to test.
|
||||
require_once WPAW_PLUGIN_DIR . 'includes/class-model-registry.php';
|
||||
269
tests/test-model-registry.php
Normal file
269
tests/test-model-registry.php
Normal file
@@ -0,0 +1,269 @@
|
||||
<?php
|
||||
/**
|
||||
* Tests for WPAW_Model_Registry
|
||||
*
|
||||
* @package WP_Agentic_Writer
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test case for WPAW_Model_Registry.
|
||||
*/
|
||||
class Test_Model_Registry extends PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* Test that get_registry returns a non-empty array.
|
||||
*/
|
||||
public function testGetRegistryReturnsArray()
|
||||
{
|
||||
$registry = WPAW_Model_Registry::get_registry();
|
||||
$this->assertIsArray($registry);
|
||||
$this->assertNotEmpty($registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that all task defaults return valid model IDs.
|
||||
*/
|
||||
public function testTaskDefaultsReturnValidModelIds()
|
||||
{
|
||||
$defaults = WPAW_Model_Registry::get_task_defaults();
|
||||
|
||||
$this->assertIsArray($defaults);
|
||||
|
||||
// Expected task types
|
||||
$expectedTasks = [
|
||||
"chat",
|
||||
"clarity",
|
||||
"planning",
|
||||
"writing",
|
||||
"execution",
|
||||
"refinement",
|
||||
"analysis",
|
||||
"summarize",
|
||||
"image",
|
||||
];
|
||||
|
||||
foreach ($expectedTasks as $task) {
|
||||
$this->assertArrayHasKey($task, $defaults, "Missing task: $task");
|
||||
$this->assertNotEmpty(
|
||||
$defaults[$task],
|
||||
"Empty default for task: $task",
|
||||
);
|
||||
$this->assertIsString(
|
||||
$defaults[$task],
|
||||
"Default must be string for task: $task",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that get_default_model returns valid model IDs.
|
||||
*/
|
||||
public function testGetDefaultModelReturnsValidId()
|
||||
{
|
||||
$tasks = [
|
||||
WPAW_Model_Registry::TASK_CHAT,
|
||||
WPAW_Model_Registry::TASK_CLARITY,
|
||||
WPAW_Model_Registry::TASK_PLANNING,
|
||||
WPAW_Model_Registry::TASK_WRITING,
|
||||
WPAW_Model_Registry::TASK_EXECUTION,
|
||||
WPAW_Model_Registry::TASK_REFINEMENT,
|
||||
WPAW_Model_Registry::TASK_ANALYSIS,
|
||||
WPAW_Model_Registry::TASK_SUMMARIZE,
|
||||
WPAW_Model_Registry::TASK_IMAGE,
|
||||
];
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
$model = WPAW_Model_Registry::get_default_model($task);
|
||||
$this->assertNotEmpty($model, "Empty model for task: $task");
|
||||
$this->assertIsString(
|
||||
$model,
|
||||
"Model must be string for task: $task",
|
||||
);
|
||||
// Model IDs should contain a slash (provider/model format)
|
||||
$this->assertStringContainsString(
|
||||
"/",
|
||||
$model,
|
||||
"Invalid model ID format for task: $task",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fallback model resolution.
|
||||
*/
|
||||
public function testFallbackModelResolvesCorrectly()
|
||||
{
|
||||
// Known tasks with fallbacks
|
||||
$tasks = ["chat", "writing", "refinement", "image"];
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
$fallback = WPAW_Model_Registry::get_fallback_model($task);
|
||||
$default = WPAW_Model_Registry::get_default_model($task);
|
||||
|
||||
$this->assertNotEmpty($fallback, "Empty fallback for task: $task");
|
||||
// Fallback should be different from default (or same if only one model exists)
|
||||
$this->assertIsString(
|
||||
$fallback,
|
||||
"Fallback must be string for task: $task",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unknown task falls back to chat defaults.
|
||||
*/
|
||||
public function testUnknownTaskFallsBackToChat()
|
||||
{
|
||||
$unknownTask = "unknown_task_xyz";
|
||||
$chatDefault = WPAW_Model_Registry::get_default_model("chat");
|
||||
|
||||
$model = WPAW_Model_Registry::get_default_model($unknownTask);
|
||||
$fallback = WPAW_Model_Registry::get_fallback_model($unknownTask);
|
||||
|
||||
$this->assertEquals(
|
||||
$chatDefault,
|
||||
$model,
|
||||
"Unknown task should fall back to chat default",
|
||||
);
|
||||
$this->assertEquals(
|
||||
$chatDefault,
|
||||
$fallback,
|
||||
"Unknown task fallback should also be chat default",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test model validation.
|
||||
*/
|
||||
public function testIsValidModel()
|
||||
{
|
||||
// Valid models from registry
|
||||
$this->assertTrue(
|
||||
WPAW_Model_Registry::is_valid_model("google/gemini-2.5-flash"),
|
||||
"gemini-2.5-flash should be valid",
|
||||
);
|
||||
$this->assertTrue(
|
||||
WPAW_Model_Registry::is_valid_model("anthropic/claude-3.5-haiku"),
|
||||
"claude-3.5-haiku should be valid",
|
||||
);
|
||||
$this->assertTrue(
|
||||
WPAW_Model_Registry::is_valid_model("google/gemini-2.0-flash-exp"),
|
||||
"gemini-2.0-flash-exp fallback should be valid",
|
||||
);
|
||||
|
||||
// Invalid models
|
||||
$this->assertFalse(
|
||||
WPAW_Model_Registry::is_valid_model("nonexistent/model"),
|
||||
"Unknown model should be invalid",
|
||||
);
|
||||
$this->assertFalse(
|
||||
WPAW_Model_Registry::is_valid_model(""),
|
||||
"Empty model should be invalid",
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test model display name generation.
|
||||
*/
|
||||
public function testGetModelDisplayName()
|
||||
{
|
||||
// Known display names
|
||||
$this->assertEquals(
|
||||
"Google Gemini 2.5 Flash",
|
||||
WPAW_Model_Registry::get_model_display_name(
|
||||
"google/gemini-2.5-flash",
|
||||
),
|
||||
);
|
||||
$this->assertEquals(
|
||||
"Anthropic Claude 3.5 Haiku",
|
||||
WPAW_Model_Registry::get_model_display_name(
|
||||
"anthropic/claude-3.5-haiku",
|
||||
),
|
||||
);
|
||||
|
||||
// Generated display names
|
||||
$displayName = WPAW_Model_Registry::get_model_display_name(
|
||||
"provider/test-model-v2",
|
||||
);
|
||||
$this->assertNotEmpty($displayName);
|
||||
$this->assertIsString($displayName);
|
||||
// Should capitalize provider and model
|
||||
$this->assertStringContainsString("Provider", $displayName);
|
||||
$this->assertStringContainsString("Test", $displayName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test empty model ID returns Unknown Model.
|
||||
*/
|
||||
public function testEmptyModelDisplayName()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"Unknown Model",
|
||||
WPAW_Model_Registry::get_model_display_name(""),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test activation defaults format.
|
||||
*/
|
||||
public function testGetActivationDefaults()
|
||||
{
|
||||
$defaults = WPAW_Model_Registry::get_activation_defaults();
|
||||
|
||||
$this->assertIsArray($defaults);
|
||||
$this->assertArrayHasKey("planning_model", $defaults);
|
||||
$this->assertArrayHasKey("execution_model", $defaults);
|
||||
$this->assertArrayHasKey("image_model", $defaults);
|
||||
|
||||
// Should return valid model IDs
|
||||
$this->assertNotEmpty($defaults["planning_model"]);
|
||||
$this->assertNotEmpty($defaults["execution_model"]);
|
||||
$this->assertNotEmpty($defaults["image_model"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test frontend data format.
|
||||
*/
|
||||
public function testGetFrontendData()
|
||||
{
|
||||
$data = WPAW_Model_Registry::get_frontend_data();
|
||||
|
||||
$this->assertIsArray($data);
|
||||
$this->assertNotEmpty($data);
|
||||
|
||||
// Should have default and label for each task
|
||||
foreach ($data as $task => $taskData) {
|
||||
$this->assertArrayHasKey(
|
||||
"default",
|
||||
$taskData,
|
||||
"Missing 'default' for task: $task",
|
||||
);
|
||||
$this->assertArrayHasKey(
|
||||
"label",
|
||||
$taskData,
|
||||
"Missing 'label' for task: $task",
|
||||
);
|
||||
$this->assertNotEmpty($taskData["default"]);
|
||||
$this->assertNotEmpty($taskData["label"]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test image_models are present in registry.
|
||||
*/
|
||||
public function testImageModelsInRegistry()
|
||||
{
|
||||
$registry = WPAW_Model_Registry::get_registry();
|
||||
|
||||
$this->assertArrayHasKey("image_models", $registry);
|
||||
$this->assertIsArray($registry["image_models"]);
|
||||
$this->assertNotEmpty($registry["image_models"]);
|
||||
|
||||
// Each image model should have a display name
|
||||
foreach ($registry["image_models"] as $modelId => $displayName) {
|
||||
$this->assertIsString($modelId);
|
||||
$this->assertIsString($displayName);
|
||||
$this->assertNotEmpty($displayName);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user