Thursday, June 12, 2014

wrong db used for Unit tests

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello everybody,


I have a Cake App running on 2.5.1. I am using Unittests.

At one point I have a similar operation necessary for 3 Models all
linked by HABTM to the same 4th model. To avoid 3 times the similar
methods in 3 models I implemented the methods in the 4th model and use
variable variable names.

So far it is fine. But when I let my tests run I get "NotFoundException
Invalid Media Id: 2" and by debugging I found out that at this point the
apps are not using my default test db.

here is the method:
public function updateTags(array $aTags, $other_id, $sOtherId,
$sOtherModel, $sLinkModel)
{
if (!$this->{$sLinkModel}->{$sOtherModel}->exists($other_id)) {
$this->{$sLinkModel}->{$sOtherModel}->recursive = -1;
$res = $this->{$sLinkModel}->{$sOtherModel}->find('all');
debug($res);
throw new NotFoundException(__('Invalid '.$sOtherModel.' Id:
'.$other_id));
}
.....


I am not using the default fixture setup, but the Fixturize Plugin by
burzum https://github.com/burzum/cakephp-fixturize which sped up my unit
tests considerably.
So I have this testseed db, which is inserted in my test db. That works
generally fine just in this case things seem to get mixed up.


Thank you for any help at this point!

Calamity Jane
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlOZaE4ACgkQbOdiIJzHNKEPgQCeN7QgY1ZHj3JlWhUvlc5xZI6W
HAwAoLqreuxOVPfWVKntxpTfIrTjQ/7Y
=Jr8w
-----END PGP SIGNATURE-----

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: