Abstract   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _testGetValues() 0 20 3
A _updateValues() 0 14 2
A _loadEntityByCollection() 0 7 1
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
abstract class IntegerNet_Anonymizer_Test_Model_Bridge_Entity_Abstract extends EcomDev_PHPUnit_Test_Case
11
{
12
    /**
13
     * @param $bridge
14
     * @param $expected
15
     */
16
    protected function _testGetValues(IntegerNet_Anonymizer_Model_Bridge_Entity_Abstract $bridge,
17
                                      Mage_Core_Model_Abstract $model, Varien_Object $expected)
18
    {
19
        $bridge->setRawData($model->getData());
20
        $this->assertEquals($expected['identifier'], $bridge->getIdentifier(), 'Identifier');
21
        $actualValues = $bridge->getValues();
22
        reset($actualValues);
23
        foreach ($expected['values'] as $expectedValue) {
24
            $this->assertInstanceOf(IntegerNet\Anonymizer\AnonymizableValue::__CLASS,
25
                current($actualValues), 'Value instance');
26
            $this->assertEquals($expectedValue['formatter'],
27
                current($actualValues)->getFakerFormatter(), 'Value formatter');
28
            $this->assertEquals($expectedValue['value'],
29
                current($actualValues)->getValue(), 'Value');
30
            if (!empty($expectedValue['unique'])) {
31
                $this->assertTrue(current($actualValues)->isUnique(), 'Unique');
32
            }
33
            next($actualValues);
34
        }
35
    }
36
37
    /**
38
     * @param $bridge
39
     */
40
    protected function _updateValues($bridge)
41
    {
42
        $bridge->updateValues();
43
44
        $this->assertNotEquals('', $bridge->getIdentifier());
45
        $bridge->clearInstance();
46
        $this->assertEquals('', $bridge->getIdentifier());
47
        foreach ($bridge->getValues() as $value) {
48
            $this->logicalOr(
49
                $this->isEmpty($value->getValue()),
0 ignored issues
show
Unused Code introduced by
The call to IntegerNet_Anonymizer_Te...ity_Abstract::isEmpty() has too many arguments starting with $value->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
50
                $this->equalTo(array(''))
51
            );
52
        }
53
    }
54
55
    /**
56
     * @param $id
57
     * @param $bridge
58
     * @return mixed
59
     */
60
    protected function _loadEntityByCollection($idField, $id, $bridge)
61
    {
62
        $entity = $bridge->getCollectionIterator()->getCollection()
63
            ->addFieldToFilter($idField, $id)
64
            ->getFirstItem();
65
        return $entity;
66
    }
67
}