Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 44... Línea 44...
44
 * @copyright   2015 David Monllao {@link http://www.davidmonllao.com}
44
 * @copyright   2015 David Monllao {@link http://www.davidmonllao.com}
45
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
46
 *
46
 *
47
 * @runTestsInSeparateProcesses
47
 * @runTestsInSeparateProcesses
48
 */
48
 */
49
class engine_test extends \advanced_testcase {
49
final class engine_test extends \advanced_testcase {
50
 
-
 
51
    /**
50
    /**
52
     * @var \core_search\manager
51
     * @var \core_search\manager
53
     */
52
     */
54
    protected $search = null;
53
    protected $search = null;
Línea 62... Línea 61...
62
     * @var Instace of testable_engine.
61
     * @var Instace of testable_engine.
63
     */
62
     */
64
    protected $engine = null;
63
    protected $engine = null;
Línea 65... Línea 64...
65
 
64
 
-
 
65
    public function setUp(): void {
66
    public function setUp(): void {
66
        parent::setUp();
67
        $this->resetAfterTest();
67
        $this->resetAfterTest();
68
        set_config('enableglobalsearch', true);
68
        set_config('enableglobalsearch', true);
Línea 69... Línea 69...
69
        set_config('searchengine', 'solr');
69
        set_config('searchengine', 'solr');
Línea 136... Línea 136...
136
        if ($this->generator) {
136
        if ($this->generator) {
137
            // Moodle DML freaks out if we don't teardown the temp table after each run.
137
            // Moodle DML freaks out if we don't teardown the temp table after each run.
138
            $this->generator->teardown();
138
            $this->generator->teardown();
139
            $this->generator = null;
139
            $this->generator = null;
140
        }
140
        }
-
 
141
        parent::tearDown();
141
    }
142
    }
Línea 142... Línea 143...
142
 
143
 
143
    /**
144
    /**
144
     * Simple data provider to allow tests to be run with file indexing on and off.
145
     * Simple data provider to allow tests to be run with file indexing on and off.
145
     */
146
     */
146
    public function file_indexing_provider() {
147
    public static function file_indexing_provider(): array {
147
        return array(
148
        return array(
148
            'file-indexing-on' => array(1),
149
            'file-indexing-on' => array(1),
149
            'file-indexing-off' => array(0)
150
            'file-indexing-off' => array(0)
150
        );
151
        );
Línea 1469... Línea 1470...
1469
        $results = $this->search->search($querydata);
1470
        $results = $this->search->search($querydata);
1470
        $this->assertCount(1, $results);
1471
        $this->assertCount(1, $results);
1471
    }
1472
    }
Línea 1472... Línea 1473...
1472
 
1473
 
-
 
1474
    /**
-
 
1475
     * Tests that the get_status function works OK on the real server (there are more detailed
-
 
1476
     * tests for this function in {@see mock_engine_test}).
-
 
1477
     *
-
 
1478
     * @covers \search_solr\check\connection
-
 
1479
     */
-
 
1480
    public function test_get_status(): void {
-
 
1481
        $status = $this->engine->get_status(5);
-
 
1482
        $this->assertTrue($status['connected']);
-
 
1483
        $this->assertTrue($status['foundcore']);
-
 
1484
        $this->assertGreaterThan(0, $status['indexsize']);
-
 
1485
    }
-
 
1486
 
1473
    /**
1487
    /**
1474
     * Carries out a raw Solr query using the Solr basic query syntax.
1488
     * Carries out a raw Solr query using the Solr basic query syntax.
1475
     *
1489
     *
1476
     * This is used to test data contained in the index without going through Moodle processing.
1490
     * This is used to test data contained in the index without going through Moodle processing.
1477
     *
1491
     *