unit testing delete issue.

2013-07-15 Thread James Pence
In a project with HABTM (Has And Belongs To Many) connected through a join 
table that is also a model. I am trying to delete an instance of the model.
The delete works fine within the app.

However once trying to run the controller action from a unit test, the 
connection to the test is reset and the unit tests are stopped.

The code surrounding the call to the delete is fine and the test only hangs 
once it is trying to delete the model instance.
Any Idea what might be causing this?

-- 
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+unsubscr...@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/groups/opt_out.




Auth login failing

2013-07-15 Thread lowpass
I need some help in determining why my login is failing suddenly. It was
working fine, then I began adding ACL. It still worked then suddenly no
joy. Back-tracking hasn't uncovered where things went wrong and now I'm
thoroughly confused.

public function login() {
debug($this->request->data);
}

gives:

array(
'User' => array(
'password' => '*',
'username' => 'user'
)
)

I know that Auth would in the past empty out the password field upon
failure; is this new that it replaces the value with asterisks? When I put
a print_r($_POST, true) in webroot/index.php everything looks fine.

In any case, does anyone have a suggestion for why this is happening at
all? I'd be most grateful for any suggestions.

FWIW, these both give the same result:
debug(Security::hash('foo', 'sha1', true));
debug($this->Auth->password('foo'));

My Auth config:

'Auth' => array(
'loginAction' => array(
'plugin' => false,
'admin' => false,
'controller' => 'users',
'action' => 'login'
),
'autoRedirect' => true,
'loginRedirect' => array(
'admin' => 1,
'plugin' => 'Pages',
'controller' => 'pages',
'action' => 'display'
),
'logoutRedirect' => array(
'admin' => 0,
'plugin' => 'Pages',
'controller' => 'pages',
'action' => 'display'
),
'authenticate' => array(
'Form' => array(
'fields' => array(
'username' => 'username',
'password' => 'password'
)
)
),
'authorize' => array(
'Actions' => array('actionPath' => 'controllers')
),
'loginError' => 'No matching user found.',
'authError' => 'Please log in'
)

> select * from acos limit 1;
+-+---+---+-+-+--+--+
| id  | parent_id | model | foreign_key | alias   | lft  | rght |
+-+---+---+-+-+--+--+
| 339 |  NULL | NULL  |NULL | controllers |1 |  172 |
+-+---+---+-+-+--+--+

> select * from aros;
++---+---+-+---+--+--+
| id | parent_id | model | foreign_key | alias | lft  | rght |
++---+---+-+---+--+--+
|  6 |  NULL | Role  |   6 | NULL  |1 |2 |
|  7 |  NULL | Role  |   7 | NULL  |3 |4 |
|  8 |  NULL | Role  |   8 | NULL  |5 |6 |
|  9 |  NULL | Role  |   9 | NULL  |7 |8 |
++---+---+-+---+--+--+

-- 
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+unsubscr...@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/groups/opt_out.




Re: Using PHP date function in Models

2013-07-15 Thread Renan Gonçalves
In that case use SQL functions instead. e.g.: NOW

You can do this:
'datestart >= NOW()'


On Mon, Jul 15, 2013 at 5:12 PM, euromark  wrote:

> Jep, as you experienced you cannot use dynamic stuff in the "static" part
> of php classes
> You need to overwrite constructor for this.
>
>
> Am Montag, 15. Juli 2013 16:55:23 UTC+2 schrieb WhyNotSmile:
>
>> In my Model, I'm trying to associate 2 different things with a Course,
>> using hasMany.  The idea is that there are 'Courseinstances', which are
>> just sets of dates on which the Course runs, and 'Courseinstancesupcoming',
>> which are future dates only.  I came up with the following (in Course.php):
>>
>>> public $hasMany = array(
>>>  'Courseinstance' => array(
>>> 'className' => 'Courseinstance',
>>> 'foreignKey'=> 'course_id',
>>>  'order' => 'datestart ASC'
>>> ),
>>> 'Courseinstanceupcoming' => array(
>>>  'className' => 'Courseinstance',
>>> 'foreignKey'=> 'course_id',
>>> 'order' => 'datestart ASC',
>>>  'conditions' => array(
>>> 'datestart > ' => date('Y-m-d H:i:s')
>>>)
>>> )
>>> );
>>
>>
>> Now, I'm not sure if this is a good thing to be even trying to do, but
>> when I run it, I get the following error:
>>
>> *Error: *syntax error, unexpected '(', expecting ',' or ';'
>>> *File: *C:\wamp\www\RNNI\site\**app\Model\Course.php
>>
>>
>> I tried various things, but got the same error.  Then I tried adding the
>> following line:
>>
>>
>> var $date = date('Y-m-d H:i:s');
>>
>>
>> and this is now throwing an error instead (same error, but now on this
>> line instead of the hasMany line).
>>
>>
>> If I do
>>
>>
>> var $date = 'testing';
>>
>>
>>
>> instead, it copes fine.  Is there something which prevents me from using
>> the PHP date() function in a model in this way?
>>
>>
>> And if anyone can suggest a solution to the initial problem of having 2
>> types of objects in the hasMany, that'd also be good, but it's not so
>> urgent, as I can work around that one.
>>
>>
>> Thanks in advance for any help!
>>
>  --
> 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+unsubscr...@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/groups/opt_out.
>
>
>



-- 
Renan Gonçalves aka renan.saddam
Software Engineer at TrueServer B.V.
CakePHP Core Developer

W: renangoncalves.com
T: twitter.com/renan_saddam
M: +31 (0)6 4662 1860
L: Amsterdam, The Netherlands

-- 
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+unsubscr...@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/groups/opt_out.




Re: Using PHP date function in Models

2013-07-15 Thread euromark
Jep, as you experienced you cannot use dynamic stuff in the "static" part 
of php classes
You need to overwrite constructor for this.


Am Montag, 15. Juli 2013 16:55:23 UTC+2 schrieb WhyNotSmile:
>
> In my Model, I'm trying to associate 2 different things with a Course, 
> using hasMany.  The idea is that there are 'Courseinstances', which are 
> just sets of dates on which the Course runs, and 'Courseinstancesupcoming', 
> which are future dates only.  I came up with the following (in Course.php):
>
>> public $hasMany = array(
>> 'Courseinstance' => array(
>> 'className' => 'Courseinstance',
>> 'foreignKey'=> 'course_id',
>> 'order' => 'datestart ASC'
>> ),
>> 'Courseinstanceupcoming' => array(
>> 'className' => 'Courseinstance',
>> 'foreignKey'=> 'course_id',
>> 'order' => 'datestart ASC',
>> 'conditions' => array(
>> 'datestart > ' => date('Y-m-d H:i:s')
>>)
>> )
>> );
>
>
> Now, I'm not sure if this is a good thing to be even trying to do, but 
> when I run it, I get the following error:
>
> *Error: *syntax error, unexpected '(', expecting ',' or ';'
>> *File: *C:\wamp\www\RNNI\site\app\Model\Course.php 
>
>
> I tried various things, but got the same error.  Then I tried adding the 
> following line:
>
>
> var $date = date('Y-m-d H:i:s');
>
>
> and this is now throwing an error instead (same error, but now on this 
> line instead of the hasMany line).
>
>
> If I do 
>
>
> var $date = 'testing';
>
>  
>
> instead, it copes fine.  Is there something which prevents me from using 
> the PHP date() function in a model in this way?
>
>
> And if anyone can suggest a solution to the initial problem of having 2 
> types of objects in the hasMany, that'd also be good, but it's not so 
> urgent, as I can work around that one.
>
>
> Thanks in advance for any help!
>

-- 
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+unsubscr...@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/groups/opt_out.




Re: Double baseurl in Cakephp Authentication tutorial

2013-07-15 Thread Frank de Graaf (Phally)
Hi,

There has been a bug fix recently regarding that particular issue. Please 
update to the latest master branch and try again.

You can find it here: https://github.com/cakephp/cakephp

Bugfix commit: 
https://github.com/cakephp/cakephp/commit/1d18a4f702e75daba10e5003c1c8661b6c8e410c#commitcomment-3632609

Op zondag 14 juli 2013 05:34:42 UTC+2 schreef Sen het volgende:
>
> Hi all,
>
> I'm new with cakephp and right now testing authentication tutorial, why 
> the return url when using Auth.redirect() always return double baseurl, my 
> testing url is like this : http://localhost/cakeblog and when it redirect 
> after login success (previous page was posts/add), it always return 
> http://localhost/cakeblog/cakeblog/posts/add (double cakeblog). Any help 
> ? Tks.
>
>   public function login() {
> if ($this->request->is('post')) {
>   if ($this->Auth->login()) {
> $this->redirect($this->Auth->redirectUrl());
>   } else {
> $this->Session->setFlash(__('Invalid username or password. Please 
> try again.'));
>   }
> }
>   }
>   
>
>

-- 
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+unsubscr...@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/groups/opt_out.




Using PHP date function in Models

2013-07-15 Thread WhyNotSmile
In my Model, I'm trying to associate 2 different things with a Course, 
using hasMany.  The idea is that there are 'Courseinstances', which are 
just sets of dates on which the Course runs, and 'Courseinstancesupcoming', 
which are future dates only.  I came up with the following (in Course.php):

> public $hasMany = array(
> 'Courseinstance' => array(
> 'className' => 'Courseinstance',
> 'foreignKey'=> 'course_id',
> 'order' => 'datestart ASC'
> ),
> 'Courseinstanceupcoming' => array(
> 'className' => 'Courseinstance',
> 'foreignKey'=> 'course_id',
> 'order' => 'datestart ASC',
> 'conditions' => array(
> 'datestart > ' => date('Y-m-d H:i:s')
>)
> )
> );


Now, I'm not sure if this is a good thing to be even trying to do, but when 
I run it, I get the following error:

*Error: *syntax error, unexpected '(', expecting ',' or ';'
> *File: *C:\wamp\www\RNNI\site\app\Model\Course.php 


I tried various things, but got the same error.  Then I tried adding the 
following line:


var $date = date('Y-m-d H:i:s');


and this is now throwing an error instead (same error, but now on this line 
instead of the hasMany line).


If I do 


var $date = 'testing';

 

instead, it copes fine.  Is there something which prevents me from using 
the PHP date() function in a model in this way?


And if anyone can suggest a solution to the initial problem of having 2 
types of objects in the hasMany, that'd also be good, but it's not so 
urgent, as I can work around that one.


Thanks in advance for any help!

-- 
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+unsubscr...@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/groups/opt_out.