Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to load a model inside modules/../model #355

Closed
ayokay123 opened this issue Jan 21, 2021 · 15 comments
Closed

how to load a model inside modules/../model #355

ayokay123 opened this issue Jan 21, 2021 · 15 comments

Comments

@ayokay123
Copy link

ayokay123 commented Jan 21, 2021

hey, when i try to load public

function setUp()
{
     $this->resetInstance();
     $this->CI->load->model(i want to acces model in modules/foo/models/foo_model);
     $this->obj = $this->CI->???;
}

i can only find the models in application/models i can't find models in application/modules/.../models

@ayokay123 ayokay123 changed the title always returning an empty string or null how to load a model inside modules/../model Jan 22, 2021
@kenjis
Copy link
Owner

kenjis commented Jan 24, 2021

CodeIgniter cannot load models not in application/models.

@ayokay123
Copy link
Author

should i copie the application/tests folder in each folder inside /modules ?? can that work

@kenjis
Copy link
Owner

kenjis commented Jan 25, 2021

You have to dig into how do you load the model in the modules folder.
And implement the logic into ci-phpunit-test.

I don't remember how CodeIgniter-HMVC does it.

@ayokay123
Copy link
Author

do you have any links or resources i could use ?? because i have searched alot with no success

@kenjis
Copy link
Owner

kenjis commented Jan 27, 2021

Read CodeIgniter-HMVC code to find out how it loads a model in the modules folder.

@ayokay123
Copy link
Author

ayokay123 commented Jan 28, 2021

i have this method line 197 https://github.com/xttrust/codeigniter-modular-extensions-hmvc-fixed/blob/master/third_party/MX/Loader.php where exactly can i implement it in ci-phpunit-test

@ayokay123
Copy link
Author

Error: Call to undefined method MY_Loader::get_details()

@kenjis
Copy link
Owner

kenjis commented Jan 28, 2021

@ayokay123 What's your environment?

  • OS
  • PHP
  • PHPUnit
  • CodeIgniter
  • HMVC

@ayokay123
Copy link
Author

os: ubuntu (im using docker for the project)
php:7.2
phpunit:7
ci: 3.1.3
hmvc not sure

@kenjis
Copy link
Owner

kenjis commented Jan 28, 2021

@kenjis
Copy link
Owner

kenjis commented Jan 29, 2021

@ayokay123
I've updated my sample repository, and worked the following test case:
https://github.com/kenjis/ci-hmvc-ci-phpunit-test/blob/master/application/tests/modules/welcome/models/Foo_model_test.php

@ayokay123
Copy link
Author

thank you very much, it works now

@ayokay123
Copy link
Author

i have another question if you can help .Can i ignore a database when i do migration in TestCase?

@kenjis kenjis closed this as completed Jan 29, 2021
@kenjis
Copy link
Owner

kenjis commented Jan 29, 2021

@ayokay123 File another issue for another question.
And Please explain what you want to do as detailed as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants