4 * Class CRM_Utils_AutoCleanTest
7 class CRM_Utils_AutoCleanTest
extends CiviUnitTestCase
{
11 protected function setUp() {
12 $this->useTransaction();
16 public function testAutoclean() {
18 $this->assertEquals('orig', $this->foo
);
19 $this->nestedWithArrayCb();
20 $this->assertEquals('orig', $this->foo
);
21 $this->nestedWithFuncCb();
22 $this->assertEquals('orig', $this->foo
);
24 $this->assertEquals('orig', $this->foo
);
27 public function nestedWithArrayCb() {
28 $this->foo
= 'arraycb';
29 $ac = CRM_Utils_AutoClean
::with(array($this, 'setFoo'), 'orig');
30 $this->assertEquals('arraycb', $this->foo
);
33 public function nestedWithFuncCb() {
34 $this->foo
= 'funccb';
36 $self = $this; /* php 5.3 */
37 $ac = CRM_Utils_AutoClean
::with(function () use ($self /* php 5.3 */) {
41 $this->assertEquals('funccb', $this->foo
);
44 public function nestedSwap() {
45 $ac = CRM_Utils_AutoClean
::swap(array($this, 'getFoo'), array($this, 'setFoo'), 'tmp');
46 $this->assertEquals('tmp', $this->foo
);
49 public function getFoo() {
53 public function setFoo($value) {