# Weird bug while testing models

**URL:** <https://discourse.cakephp.org/t/weird-bug-while-testing-models/10644>\
**Category:** Need Help\
**Created:** [September 27, 2022, 7:47pm UTC](https://discourse.cakephp.org/t/weird-bug-while-testing-models/10644 "2022-09-27T19:47:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gonzalo](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@Gonzalo](https://discourse.cakephp.org/u/Gonzalo)\
**Post date:** [September 27, 2022, 7:47pm UTC](https://discourse.cakephp.org/t/weird-bug-while-testing-models/10644/1 "2022-09-27T19:47:05Z")

</div>

Im trying to create Tests for models on Cakephp 2.10 and i encountered this situation:

I load my fixtures like this:

```auto
public $fixtures = [
        'app.test_model_one',
        'app.test_model_two',
        'app.test_model_three',
        'app.test_model_four'
]
public $autoFixtures = false;

```

and the i do the setUp

```auto
    public function setUp() {
        parent::setUp();

        $this->ModelOne = ClassRegistry::init('ModelOne');
        $this->ModelOne->useTable = 'test_model_one';

        $this->ModelTwo = ClassRegistry::init('ModelTwo');
        $this->ModelTwo->useTable = 'test_model_two';
        ...
    }

```

ModelOne has a belongsTo relation with all the other models, so i can bring the desired data using the containable behavior.

The things is, the first time my test runs it works as it should. But when i run it a second time it doesnt work.

After searching why this was happening i encoutered that my `$this->ModelOne->find()` method it was not using the `test_model_two` table on the query, and it was using the model\_two table. Any idea why this is happening ?

---

<div class="post-metadata">

**Author:** ![Gonzalo](https://avatars.discourse-cdn.com/v4/letter/g/4bbf92/32.png) [@Gonzalo](https://discourse.cakephp.org/u/Gonzalo)\
**Post date:** [September 28, 2022, 6:29pm UTC](https://discourse.cakephp.org/t/weird-bug-while-testing-models/10644/2 "2022-09-28T18:29:16Z")

</div>

just fixed it, my test database had tables, so i just dropped them all and i just use the fixtures.
