1
0

Added DB Access + Error page

This commit is contained in:
2014-05-12 10:11:20 +02:00
parent 3efba81ebc
commit ffdc17efd5
124 changed files with 6346 additions and 82 deletions

View File

@@ -0,0 +1,57 @@
<?php
class CommentTest extends CDbTestCase
{
/**
* We use both 'Post' and 'Comment' fixtures.
* @see CWebTestCase::fixtures
*/
public $fixtures=array(
'posts'=>'Post',
'comments'=>'Comment',
);
public function testFindRecentComments()
{
$this->assertEquals(array(), Comment::model()->findRecentComments());
$comment=new Comment;
$comment->setAttributes(array(
'content'=>'comment 1',
'status'=>Comment::STATUS_APPROVED,
'create_time'=>time(),
'author'=>'me',
'email'=>'me@example.com',
'post_id'=>$this->posts['sample1']['id'],
),false);
$this->assertTrue($comment->save(false));
$this->assertEquals(1,$comment->id);
$comments=Comment::model()->findRecentComments();
$this->assertEquals(1,count($comments));
$this->assertEquals($comment->attributes, $comments[0]->attributes);
}
public function testApprove()
{
$comment=new Comment;
$comment->setAttributes(array(
'content'=>'comment 1',
'status'=>Comment::STATUS_PENDING,
'create_time'=>time(),
'author'=>'me',
'email'=>'me@example.com',
'post_id'=>$this->posts['sample1']['id'],
),false);
$this->assertTrue($comment->save(false));
$comment=Comment::model()->findByPk($comment->id);
$this->assertTrue($comment instanceof Comment);
$this->assertEquals(Comment::STATUS_PENDING,$comment->status);
$comment->approve();
$this->assertEquals(Comment::STATUS_APPROVED,$comment->status);
$comment=Comment::model()->findByPk($comment->id);
$this->assertEquals(Comment::STATUS_APPROVED,$comment->status);
}
}

View File

@@ -0,0 +1,13 @@
<?php
class LookupTest extends CDbTestCase
{
public $fixtures=array(
'lookups'=>'Lookup',
);
public function testCreate()
{
}
}

View File

@@ -0,0 +1,18 @@
<?php
class PostTest extends CDbTestCase
{
/**
* We use both 'Post' and 'Comment' fixtures.
* @see CWebTestCase::fixtures
*/
public $fixtures=array(
'posts'=>'Post',
'comments'=>'Comment',
);
public function testSave()
{
// write code here to test post saving method
}
}

View File

@@ -0,0 +1,13 @@
<?php
class TagTest extends CDbTestCase
{
public $fixtures=array(
'tags'=>'Tag',
);
public function testCreate()
{
}
}

View File

@@ -0,0 +1,24 @@
<?php
class UserTest extends CDbTestCase
{
public $fixtures=array(
'users'=>'User',
);
public function testValidatePassword()
{
$this->assertTrue($this->users(0)->validatePassword('demo'));
$this->assertFalse($this->users(0)->validatePassword('wrong'));
}
public function testChangePassword()
{
$user=$this->users(0);
$user->password=$user->hashPassword('newpwd');
$this->assertFalse($user->validatePassword('demo'));
$this->assertTrue($user->validatePassword('newpwd'));
}
}