model/rating.php
class Rating extends AppModel {

        var $name = 'Rating';
        var $validate = array(
                'score' => array(
                        'numeric' => array(
                    'rule' => 'numeric',
                    'message' => 'numeric score only'
                ),
                'between' => array(
                    'rule' => array('between', 1, 5),
                    'message' => '1 - 5 only'
                ),
            )
        );
}
test/models/rating.test.php:
        function testScoreRange() {
            $this->data = array(
                        'score'  => 10,
                        'url_id'  => 10,
            );
            $this->Rating->create();
            $this->Rating->set($this->data);
            $result = $this->Rating->save();

            $this->assertFalse($result);

        }

On 7月22日, 下午1時57分, Joe <[email protected]> wrote:
> same here
>
> On 7月10日, 下午5時03分, williamn <[email protected]> wrote:
>
>
>
> > Hi all,
>
> > Did this ever happened to anyone here? :)
>
> > On Jun 7, 8:14 pm, williamn <[email protected]> wrote:
>
> > > Hi all,
>
> > > I have a simple model like below
>
> > > class Department extends AppModel {
>
> > >         var $name = 'Department';
> > >         var $validate = array(
> > >                 'code' => array('notempty'),
> > >                 'name' => array('notempty'),
> > >                 'abbreviation' => array('notempty'),
> > >                 'phone_num' => array('notempty')
> > >         );
>
> > > }
>
> > > and create a simpletestlike this
>
> > > function testInvalidCreate() {
> > >         $this->Department->create();
> > >         $this->assertFalse($this->Department->save());
>
> > > }
>
> > > correct me if I'm wrong, $this->Department->save() should return false
> > > right? but in my case it returning an array.
>
> > > Any suggestion?
>
> > > Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to