Skip to content
Snippets Groups Projects
Commit 3c52bd68 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Add unit tests

parent 7b47e553
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,34 @@ class AttributeAlterTest extends TestCase
}
/**
* Test the most basic functionality with merging strategy.
*/
public function testMergeWithTarget(): void
{
$config = [
'subject' => 'test',
'target' => 'test2',
'pattern' => '/wrong/',
'replacement' => 'right',
'%merge'
];
$request = [
'Attributes' => [
'test' => ['wrong'],
'test2' => ['somethingelse'],
],
];
$result = self::processFilter($config, $request);
$attributes = $result['Attributes'];
$this->assertArrayHasKey('test2', $attributes);
$this->assertEquals($attributes['test'], ['wrong']);
$this->assertEquals($attributes['test2'], ['right', 'somethingelse']);
}
/**
* Module is a no op if subject attribute is not present.
*/
......@@ -155,6 +183,31 @@ class AttributeAlterTest extends TestCase
}
/**
* Test replacing attribute value with merging strategy.
*/
public function testReplaceMergeMatchWithTarget(): void
{
$config = [
'subject' => 'source',
'pattern' => '/wrong/',
'replacement' => 'right',
'target' => 'test',
'%replace',
'%merge',
];
$request = [
'Attributes' => [
'source' => ['wrong'],
'test' => ['wrong', 'somethingelse'],
],
];
$result = self::processFilter($config, $request);
$attributes = $result['Attributes'];
$this->assertEquals($attributes['test'], ['somethingelse', 'right']);
}
/**
* Test replacing attribute values.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment