Passed
Push — master ( ed4c81...3098af )
by DeGracia
01:51
created

Test::example()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
use DeGraciaMathieu\Riddler\Password;
4
use DeGraciaMathieu\Riddler\Criterias;
5
use DeGraciaMathieu\Riddler\Formats;
6
use DeGraciaMathieu\Riddler\Occurences;
7
8
class Test extends \PHPUnit\Framework\TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    /** @test */
11 1
    public function emptyPassword()
12
    {
13 1
        $pw = new Password();
14
15 1
        $str = $pw->generate();
16
17 1
        $this->assertEmpty($str);
18 1
    }
19
20
    /** @test */
21 1 View Code Duplication
    public function letterPasswordOnly()
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...
22
    {
23 1
        $pw = new Password();
24
25 1
        $pw->addCriteria(new Criterias\Letter(), new Occurences\Strict(10));
26
27 1
        $str = $pw->generate();
28
29 1
        $this->assertNotEmpty($str);
30
31 1
        $this->assertRegExp('/[a-z]/', $str);
32 1
    }
33
34
    /** @test */
35 1
    public function FormatOnly()
36
    {
37 1
        $pw = new Password();
38
39 1
        $pw->addFormat(new Formats\LongDigit());
40
41 1
        $str = $pw->generate();
42
43 1
        $this->assertNotEmpty($str);
44
45 1
        $this->assertRegExp('/\d{30}/', $str);
46 1
    }
47
48
    /** @test */
49 1 View Code Duplication
    public function digitPasswordOnly()
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...
50
    {
51 1
        $pw = new Password();
52
53 1
        $pw->addCriteria(new Criterias\Digit(), new Occurences\Strict(10));
54
55 1
        $str = $pw->generate();
56
57 1
        $this->assertNotEmpty($str);
58
59 1
        $this->assertRegExp('/\d{10}/', $str);
60 1
    }    
61
62
    /** @test */
63 1 View Code Duplication
    public function strictOccurences()
0 ignored issues
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...
64
    {
65 1
        $dictionary = ['a', 'b', 'c', 'd'];
66
67 1
        $strict = new Occurences\Strict(5);
68 1
        $result = $strict->parse($dictionary);
69
70 1
        $this->assertTrue(is_array($result));
71 1
        $this->assertEquals(5, count($result));
72 1
        $this->assertContains($result[0], $dictionary);
73 1
        $this->assertContains($result[1], $dictionary);
74 1
        $this->assertContains($result[2], $dictionary);
75 1
        $this->assertContains($result[3], $dictionary);
76 1
    }
77
78
    /** @test */
79 1 View Code Duplication
    public function betweenOccurences()
0 ignored issues
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...
80
    {
81 1
        $dictionary = ['a', 'b', 'c', 'd'];
82
83 1
        $strict = new Occurences\Between(3, 5);
84 1
        $result = $strict->parse($dictionary);
85
86 1
        $this->assertTrue(is_array($result));
87 1
        $this->assertTrue(count($result) >= 3);
88 1
        $this->assertTrue(count($result) <= 5);
89 1
        $this->assertContains($result[0], $dictionary);
90 1
        $this->assertContains($result[1], $dictionary);
91 1
        $this->assertContains($result[2], $dictionary);
92 1
    }
93
}
94