ProviderTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testDeterministicValues() 0 16 1
A testNullFormatter() 0 7 1
A testUniqueData() 0 11 2
1
<?php
2
/**
3
 * integer_net Magento Module
4
 *
5
 * @category   IntegerNet
6
 * @package    IntegerNet_Anonymizer
7
 * @copyright  Copyright (c) 2015 integer_net GmbH (http://www.integer-net.de/)
8
 * @author     Fabian Schmengler <[email protected]>
9
 */
10
11
namespace IntegerNet\Anonymizer;
12
13
14
class ProviderTest extends \PHPUnit_Framework_TestCase
15
{
16
    public function testDeterministicValues()
17
    {
18
        $provider = new Provider();
19
        $provider->initialize('de_DE');
20
        $aName = $provider->getFakerData('name', '[email protected]');
21
        $aRandomNumber = mt_rand();
22
        $aDifferentName = $provider->getFakerData('name', '[email protected]');
23
        $aSameName = $provider->getFakerData('name', '[email protected]');
24
        $this->assertNotEquals($aName, $aDifferentName, 'Name should be different for different identifier (email address)');
25
        $this->assertEquals($aName, $aSameName, 'Name should be equal for same identifier (email address)');
26
        $this->assertNotEquals($aRandomNumber, mt_rand(), 'The provider should not have side effects on mt_rand.');
27
28
        $provider->initialize('de_DE');
29
        $aNameAfterReinitialize = $provider->getFakerData('name', '[email protected]');
30
        $this->assertNotEquals($aName, $aNameAfterReinitialize, 'Names should be different each anonymization process.');
31
    }
32
    public function testNullFormatter()
33
    {
34
        $provider = new Provider();
35
        $provider->initialize('de_DE');
36
        $nulledData = $provider->getFakerData('null', '[email protected]');
37
        $this->assertEquals(null, $nulledData);
38
    }
39
    public function testUniqueData()
40
    {
41
        $provider = new Provider();
42
        $provider->initialize('de_DE');
43
        $randomDigits = array();
44
        for ($d = 0; $d < 10; ++$d) {
45
            $randomDigits[] = $provider->getFakerData('randomDigit', '[email protected]', true);
46
        }
47
        sort($randomDigits);
48
        $this->assertEquals(range(0,9), $randomDigits, '10 unique digits should be all from 0..9');
49
    }
50
}
51