Passed
Branch master (b37043)
by Timo
11:18
created

SolrConfigurationStatusTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 72.73 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 48
loc 66
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace ApacheSolrForTypo3\Solr\Tests\Integration\Report;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2010-2015 Timo Schmidt <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 2 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
use ApacheSolrForTypo3\Solr\Tests\Integration\IntegrationTest;
27
use TYPO3\CMS\Core\Utility\GeneralUtility;
28
29
/**
30
 * Integration testcase to test the results plugin.
31
 *
32
 * @author Timo Schmidt
33
 * @package TYPO3
34
 * @subpackage solr
35
 */
36
class SolrConfigurationStatusTest extends IntegrationTest
37
{
38
    /**
39
     * @test
40
     */
41
    public function canGetGreenReportAgainstTestServer()
42
    {
43
        $this->importDataSetFromFixture('can_get_green_solr_configuration_status_report.xml');
44
45
            /** @var $solrConfigurationStatus  \ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus */
46
        $solrConfigurationStatus = GeneralUtility::makeInstance('ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus');
47
        $violations = $solrConfigurationStatus->getStatus();
48
        $this->assertEmpty($violations, 'We did not get an empty response from the solr configuration status report! Something is wrong');
49
    }
50
51
    /**
52
     * @test
53
     */
54
    public function canDetectMissingDomainRecord()
55
    {
56
        $this->importDataSetFromFixture('can_detect_missing_domain_record.xml');
57
58
        /** @var $solrConfigurationStatus  \ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus */
59
        $solrConfigurationStatus = GeneralUtility::makeInstance('ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus');
60
        $violations = $solrConfigurationStatus->getStatus();
61
62
        $this->assertCount(1, $violations, 'Asserting to contain only one violation.');
63
64
        $firstViolation = array_pop($violations);
65
        $this->assertContains('Domain records missing', $firstViolation->getValue(), 'Did not get a domain record violation');
66
    }
67
68
    /**
69
     * @test
70
     */
71
    public function canDetectMissingRootPage()
72
    {
73
        $this->importDataSetFromFixture('can_detect_missing_rootpage.xml');
74
75
        /** @var $solrConfigurationStatus  \ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus */
76
        $solrConfigurationStatus = GeneralUtility::makeInstance('ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus');
77
        $violations = $solrConfigurationStatus->getStatus();
78
79
        $this->assertCount(1, $violations, 'Asserting to contain only one violation.');
80
81
        $firstViolation = array_pop($violations);
82
        $this->assertContains('No sites', $firstViolation->getValue(), 'Did not get a no sites found violation');
83
    }
84
85
    /**
86
     * @test
87
     */
88
    public function canDetectIndexingDisabled()
89
    {
90
        $this->importDataSetFromFixture('can_detect_indexing_disabled.xml');
91
92
        /** @var $solrConfigurationStatus  \ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus */
93
        $solrConfigurationStatus = GeneralUtility::makeInstance('ApacheSolrForTypo3\Solr\Report\SolrConfigurationStatus');
94
        $violations = $solrConfigurationStatus->getStatus();
95
96
        $this->assertCount(1, $violations, 'Asserting to contain only one violation.');
97
98
        $firstViolation = array_pop($violations);
99
        $this->assertContains('Indexing is disabled', $firstViolation->getValue(), 'Did not get a no sites found violation');
100
    }
101
}
102