1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8/**
9 * @group unit
10 *
11 */
12
13class DeclFilter_StaticKeyFilterTest extends TikiTestCase
14{
15	function testMatch()
16	{
17		$rule = new DeclFilter_StaticKeyFilterRule(
18			[
19				'hello' => 'digits',
20				'world' => 'alpha',
21			]
22		);
23
24		$this->assertTrue($rule->match('hello'));
25		$this->assertTrue($rule->match('world'));
26		$this->assertFalse($rule->match('baz'));
27	}
28
29	function testApply()
30	{
31		$rule = new DeclFilter_StaticKeyFilterRule(
32			[
33				'hello' => 'digits',
34				'world' => 'alpha',
35			]
36		);
37
38		$data = [
39			'hello' => '123abc',
40			'world' => '123abc',
41			'foo' => '123abc',
42		];
43
44		$rule->apply($data, 'hello');
45		$rule->apply($data, 'world');
46
47		$this->assertEquals($data['hello'], '123');
48		$this->assertEquals($data['world'], 'abc');
49		$this->assertEquals($data['foo'], '123abc');
50	}
51}
52