{"id":13560182,"url":"https://github.com/cwingrav/CIModelTester","last_synced_at":"2025-04-03T15:31:44.768Z","repository":{"id":28878841,"uuid":"32403323","full_name":"cwingrav/CIModelTester","owner":"cwingrav","description":"A CodeIgniter interactive model tester web interface. Directly call your model functionality for testing and debugging.","archived":false,"fork":false,"pushed_at":"2015-11-07T11:29:03.000Z","size":1388,"stargazers_count":11,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-02-15T12:34:17.186Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cwingrav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-17T15:48:38.000Z","updated_at":"2022-05-09T15:12:04.000Z","dependencies_parsed_at":"2022-07-24T12:02:01.938Z","dependency_job_id":null,"html_url":"https://github.com/cwingrav/CIModelTester","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwingrav%2FCIModelTester","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwingrav%2FCIModelTester/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwingrav%2FCIModelTester/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cwingrav%2FCIModelTester/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cwingrav","download_url":"https://codeload.github.com/cwingrav/CIModelTester/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247028004,"owners_count":20871634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T13:00:39.084Z","updated_at":"2025-04-03T15:31:39.757Z","avatar_url":"https://github.com/cwingrav.png","language":"PHP","readme":"# CIModelTester\nA CodeIgniter interactive model tester web interface. Directly call your model functionality for testing and debugging.\n\n## Usage\nLoad in your browser: `http://\u003cmydomain\u003e/index.php/CIModelTester`. You'll see the main CIModelTester page.\n\n\u003cimg src='imgs/mainpage.png' width='300px' /\u003e\n\nThen, click on a model to see the model page. \n\n\u003cimg src='imgs/modelpage.png' width='300px' /\u003e\n\nFrom here, type parameters into the fields to pass data to a method.  In the image below, the model `RecData_model` has method `getUserInterests` with one parameter `uid`. When I enter `2`, it returns the one interest of that user and displays the return value of the method as JSON (i.e. CIModelTester uses ajax to call your method and passes the data as JSON). Note: methods that take arrays can be called with brackets. i.e. [1,2,3] would be equivalent to php's `array(1,2,3)`.\n\n\u003cimg src='imgs/amethod.png' width='300px' /\u003e\n\nNOTE: If you use proper code documentation, it even prints the comments! You can toggle the comments on, as they are off by default. \nNOTE2: The `toggle` button collapses the returned data after a query. Sometimes the return is long so I added this in. \nNOTE3: The `unit test` button goes directly to the unit test case for that method. If it does not exist, it will tell you.\n\n\n## Installation\n\n### Quick Install\n* Put `modeltester.php` into your controllers directory.\n\n### For Tailored Use\n* Put `modeltester.php` into your CodeIgnite 'libraries' folder. \n* Create a new controller `MyModelTester.php` in your 'controllers' folder, passing in an array of the models you wish to test. ex \"`array('model1_model','model2_model')`\".\n```\n\u003c?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');\nrequire_once(APPPATH.'libraries/modeltester.php');\nclass MyModelTester extends CIModelTester {\n    public function __construct() {\n        parent::__construct(array(...my controllers here...));}}\n?\u003e\n```\n* That's it! Load it up at http://\u003cmydomain\u003e/index.php/MyModelTester\n\n\n## Unit Testing Models\n\nYou can write CodeIngniter unit tests for your models and run them via this interface. Open the model and click 'run unit tests'. It will load the APPDATA/models/tests/test_[modelname].php file and execute the tests. If this file does not exist, it gives you sample data to get started writing one and tells you the directory location to put it. (NOTE: For models in subdirectories, create your 'tests' directory in those subdirectories. Nifty huh...)\n\n### Testing Methods Run\nThis runs a generic test and searches for method-specific tests.\n* test()   - always called.\n* onExit() - called at the end of running your model. \n* test_\\[method\\]() - the test method for you to implement. Returned values are displayed after the CodeIgniter unit test information. Use the pack_ret function to format any data in this method for return.\n\n### Default Unit Test\nHere's what the suggested unit test is for my 'content_model.php' file, where I wrote one empty test for the method test_getUnderReviewStats.\n\n\u003cimg src='imgs/unit_test_output.png' width='300px' /\u003e\n\n## How it works?\n\nIt sends an Ajax call to CIModelTester-\u003emodel_test and returns the results in JSON to your page. Nifty.\n\n## Security Concerns\n\n!GOOD HEAVENS YES! This is like handing the keys to your application to anyone that finds this controller. DON'T PUT INTO PRODUCTION CODE! To mitigate this risk, it does not function if you set your CodeIgniter project state to anything other than 'development' or 'testing' and you can turn it off by setting the second parameter to CIModelTester to be false.\n\nAlso, for unit tests, only runs in 'testing' environment.\n","funding_links":[],"categories":["Model"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwingrav%2FCIModelTester","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcwingrav%2FCIModelTester","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcwingrav%2FCIModelTester/lists"}