Completed
Push — master ( 2cdcf8...724561 )
by Christopher
06:47
created

MetadataManagerTest::testEntitysAndProperties()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Doc
5
 * Date: 5/11/2017
6
 * Time: 11:01 PM
7
 */
8
9
namespace AlgoWeb\ODataMetadata\Tests;
10
11
use AlgoWeb\ODataMetadata\MetadataManager;
12
13
class MetadataManagerTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testIsOKAtDefault()
16
    {
17
        $ds = DIRECTORY_SEPARATOR;
0 ignored issues
show
Unused Code introduced by
$ds is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
18
        $metadataManager = new MetadataManager();
19
        $msg = null;
20
        $edmx = $metadataManager->getEdmx();
21
        $this->assertTrue($edmx->isOK($msg), $msg);
22
        $this->assertNull($msg);
23
24
        $d = $metadataManager->getEdmxXML();
25
        $this->v3MetadataAgainstXSD($d);
26
    }
27
28 View Code Duplication
    public function v3MetadataAgainstXSD($data)
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $ds = DIRECTORY_SEPARATOR;
31
        $xml = new \DOMDocument();
32
        $xml->loadXML($data);
33
        $xml->schemaValidate(dirname(__DIR__) . $ds . "xsd" . $ds . "/Microsoft.Data.Entity.Design.Edmx_3.xsd");
34
    }
35
36
    public function testEntitysAndProperties()
37
    {
38
        $metadataManager = new MetadataManager();
39
40
        $eType = $metadataManager->addEntityType("Category");
41
        $this->assertNotFalse($eType, "Etype is false not type " . $metadataManager->getLastError());
42
        $metadataManager->addPropertyToEntityType($eType, "CategoryID", "Int32", null, false, true, "Identity");
43
        $metadataManager->addPropertyToEntityType($eType, "CategoryName", "String");
44
        $metadataManager->addPropertyToEntityType($eType, "Description", "String");
45
        $metadataManager->addPropertyToEntityType($eType, "Picture", "Binary");
46
47
        $eType = $metadataManager->addEntityType("CustomerDemographic");
48
        $metadataManager->addPropertyToEntityType($eType, "CustomerTypeID", "String", null, false, true);
49
        $metadataManager->addPropertyToEntityType($eType, "CustomerDesc", "String");
50
51
52
        $msg = null;
53
        $edmx = $metadataManager->getEdmx();
54
        $this->assertTrue($edmx->isOK($msg), $msg);
55
        $this->assertNull($msg);
56
57
        $d = $metadataManager->getEdmxXML();
58
        die($d);
59
        $this->v3MetadataAgainstXSD($d);
0 ignored issues
show
Unused Code introduced by
$this->v3MetadataAgainstXSD($d); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
60
    }
61
62
63
}
64