Using Views in database over a legacy database

2008-09-18 Thread Laurent Bois

Hi

We currently have a data model with table names that don't follow
CakePHP conventions.
As we do with Rails, one technique to use (when application is read-
only, and that's our case) is to create views in database over this
legacy tables.
First i did this.
Then i wanted to unit test my new renamed data model.
- i've recreated my models using renamed keys in my views.
- i've recreated my test cases.

After first test launched, what i see for the first model, is that the
Testing framework create my test tables with the keys of the table,
mapped by my view.
And fixtures couldn't be loaded, and test is not run.

here my legacy table :
SL01 :
 N_NUME_CLIE varchar(6)
 L_CONN_NOM  varchar(40)
 L_CONN_PASS varchar(40)

Here my view Users
Create view Users as select n_nume_clie id, l_conn_nom, l_conn_pass
from sl01;

Here the trace in my test case (creation of the table for testing):
CREATE TABLE `test_utilisateur_tests` ( `N_NUME_CLIE` varchar(6) NOT
NULL, `L_CONN_NOM` varchar(40) NOT NULL, `L_CONN_PASS` varchar(40) NOT
NULL );

It seems to be a problem with the SimpleTest framework

Does CakePHP support Models mapping database Views?
Thanks

Laurent

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Testing a Model with Associations

2008-09-09 Thread Laurent Bois

Hello again

I solved my problem.

Now i'm trying to unit Test a (child) model M_child having a belongsTo
relation to M_parent.

I encounter problem when i test a find method written in the child
model.
I thought , with a recursive value set to 1 (by default), i would get
in my resultset one line of my parent model...but no  , i just get the
lines of the child model.
How could i test my belongsTo relation?

Regards

Laurent

On Sep 8, 4:46 pm, Laurent Bois <[EMAIL PROTECTED]> wrote:
> Hello
>
> I'm newbie for CakePHP, and have been working for 2,5y with Rails.
> We currently have an application developed from scratch by another
> team... the code is not very maintainable, and i'd like to refactore
> it in order to use Cake.
> Before really playing with controllers, views , i wanted to unittest
> all my models, having relations between them.
>
> I just have a question about how to use assertTrue in one pass totest
> the resultset coming from a query on my Model1, having a hasMany
> relation to Model2
>
> When my Model1 did not have any relation i could do :
> $conditions = array(
> 'id' => 1
> );
> $result = $this->Model1Test->find($conditions, array('id', 'title'));
> $expected = array(
> array('Model1Test' => array( 'id' => 1, 'title' => 'First
> Article' ))
> );
>
> $this->assertEqual($result, $expected);
>
> Now Model1 as a relation hasMany to Model2, i'd like to be able to add
> Model2's rows in my $expected variable...
>
> Thanks
>
> L

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Testing a Model with Associations

2008-09-08 Thread Laurent Bois

Hello

I'm newbie for CakePHP, and have been working for 2,5y with Rails.
We currently have an application developed from scratch by another
team... the code is not very maintainable, and i'd like to refactore
it in order to use Cake.
Before really playing with controllers, views , i wanted to unit test
all my models, having relations between them.

I just have a question about how to use assertTrue in one pass to test
the resultset coming from a query on my Model1, having a hasMany
relation to Model2

When my Model1 did not have any relation i could do :
$conditions = array(
'id' => 1
);
$result = $this->Model1Test->find($conditions, array('id', 'title'));
$expected = array(
array('Model1Test' => array( 'id' => 1, 'title' => 'First
Article' ))
);

$this->assertEqual($result, $expected);

Now Model1 as a relation hasMany to Model2, i'd like to be able to add
Model2's rows in my $expected variable...

Thanks

L

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---