Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Updated documentation for Soft Delete tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
predominant committed Oct 29, 2010
1 parent f7d9983 commit 8510fe4
Showing 1 changed file with 50 additions and 7 deletions.
57 changes: 50 additions & 7 deletions tests/cases/behaviors/soft_delete.test.php
@@ -1,30 +1,64 @@
<?php
/**
* Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright 2009-2010, Cake Development Corporation (http://cakedc.com)
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/

App::import('Behavior', 'Utils.SoftDelete');

/**
* SoftDelete Test Behavior
**/
* SoftDeleteTestBehavior
*
* @package default
* @author Predominant
*/
class SoftDeleteTestBehavior extends SoftDeleteBehavior {
}

/**
* SoftDeleted Post
* SoftDeletedPost
*
* @package utils
* @subpackage utils.tests.cases.behaviors
*/
class SoftDeletedPost extends CakeTestModel {

/**
* Use Table
*
* @var string
*/
public $useTable = 'posts';

/**
* Behaviors
*
* @var array
*/
public $actsAs = array('SoftDeleteTest');

/**
* Alias
*
* @var string
*/
public $alias = 'Post';
}

/**
* SoftDelete Test case
*/
class SoftDeleteTest extends CakeTestCase {

/**
* fixtures property
*
* @var array
* @access public
*/
public $fixtures = array('plugin.utils.post');

Expand Down Expand Up @@ -64,15 +98,25 @@ public function testSoftDelete() {
$this->assertEqual($data['Post']['deleted'], 1);
$this->assertEqual($data['Post']['updated'], $data['Post']['deleted_date']);
}


/**
* testUnDelete
*
* @return void
*/
public function testUnDelete() {
$data = $this->Post->read(null, 1);
$result = $this->Post->delete(1);
$result = $this->Post->undelete(1);
$data = $this->Post->read(null, 1);
$this->assertEqual($data['Post']['deleted'], 0);
}


/**
* testSoftDeletePurge
*
* @return void
*/
public function testSoftDeletePurge() {
$this->Post->Behaviors->disable('SoftDeleteTest');
$data = $this->Post->read(null, 3);
Expand Down Expand Up @@ -111,4 +155,3 @@ public function testSoftDeletePurge() {
// $this->assertEqual($result['SoftDeletedPost']['slug'], 'fourth_Post_part_2');

}
?>

0 comments on commit 8510fe4

Please sign in to comment.