HunSpellProviderTest::testCheckWords()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\SpellCheck\Tests;
4
5
use SilverStripe\SpellCheck\Providers\HunSpellProvider;
6
use SilverStripe\Dev\SapphireTest;
7
8
/**
9
 * Tests the {@see HunSpellProvider} class
10
 */
11
class HunSpellProviderTest extends SapphireTest
12
{
13
14
    /**
15
     * Assert that all needles are in the haystack
16
     *
17
     * @param array $needles
18
     * @param array $haystack
19
     */
20
    protected function assertArrayContains($needles, $haystack)
21
    {
22
        $overlap = array_intersect($needles, $haystack);
23
        $this->assertEquals($overlap, $needles, "Assert that array contains all values specified");
24
    }
25
26 View Code Duplication
    public function testCheckWords()
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...
27
    {
28
        $provider = new HunSpellProvider();
29
        $result = $provider->checkWords('en_US', array('collor', 'one', 'twoo', 'three'));
30
        $this->assertArrayContains(
31
            array('collor', 'twoo'),
32
            $result
33
        );
34
        $result = $provider->checkWords('en_US', array('basketball'));
35
        $this->assertEmpty($result);
36
    }
37
38 View Code Duplication
    public function testGetSuggestions()
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...
39
    {
40
        $provider = new HunSpellProvider();
41
        $result = $provider->getSuggestions('en_US', 'collor');
42
        $this->assertArrayContains(
43
            array('color', 'collar', 'coll or', 'coll-or', 'collator'),
44
            $result
45
        );
46
        $result = $provider->getSuggestions('en_US', 'basketball');
47
        $this->assertEmpty($result);
48
    }
49
}
50