Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 22... Línea 22...
22
 * @package    mod_glossary
22
 * @package    mod_glossary
23
 * @category   test
23
 * @category   test
24
 * @copyright  2014 Petr Skoda
24
 * @copyright  2014 Petr Skoda
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26
 */
26
 */
27
class concept_cache_test extends \advanced_testcase {
27
final class concept_cache_test extends \advanced_testcase {
28
    /**
28
    /**
29
     * Test convect fetching.
29
     * Test convect fetching.
30
     */
30
     */
31
    public function test_concept_fetching(): void {
31
    public function test_concept_fetching(): void {
32
        global $CFG, $DB;
32
        global $CFG, $DB;
Línea 66... Línea 66...
66
 
66
 
Línea 67... Línea 67...
67
        \mod_glossary\local\concept_cache::reset_caches();
67
        \mod_glossary\local\concept_cache::reset_caches();
68
 
68
 
69
        $concepts1 = \mod_glossary\local\concept_cache::get_concepts($course1->id);
69
        $concepts1 = \mod_glossary\local\concept_cache::get_concepts($course1->id);
70
        $this->assertCount(3, $concepts1[0]);
70
        $this->assertCount(3, $concepts1[0]);
71
        $this->arrayHasKey($concepts1[0], $glossary1a->id);
71
        $this->assertArrayHasKey($glossary1a->id, $concepts1[0]);
72
        $this->arrayHasKey($concepts1[0], $glossary1b->id);
72
        $this->assertArrayHasKey($glossary1b->id, $concepts1[0]);
73
        $this->arrayHasKey($concepts1[0], $glossary3->id);
73
        $this->assertArrayHasKey($glossary3->id, $concepts1[0]);
74
        $this->assertCount(3, $concepts1[1]);
74
        $this->assertCount(3, $concepts1[1]);
75
        $this->arrayHasKey($concepts1[1], $glossary1a->id);
75
        $this->assertArrayHasKey($glossary1a->id, $concepts1[1]);
76
        $this->arrayHasKey($concepts1[1], $glossary1b->id);
76
        $this->assertArrayHasKey($glossary1b->id, $concepts1[1]);
77
        $this->arrayHasKey($concepts1[0], $glossary3->id);
77
        $this->assertArrayHasKey($glossary3->id, $concepts1[1]);
78
        $this->assertCount(5, $concepts1[1][$glossary1a->id]);
78
        $this->assertCount(5, $concepts1[1][$glossary1a->id]);
79
        foreach($concepts1[1][$glossary1a->id] as $concept) {
79
        foreach($concepts1[1][$glossary1a->id] as $concept) {
80
            $this->assertSame(array('id', 'glossaryid', 'concept', 'casesensitive', 'category', 'fullmatch'), array_keys((array)$concept));
80
            $this->assertSame(array('id', 'glossaryid', 'concept', 'casesensitive', 'category', 'fullmatch'), array_keys((array)$concept));
Línea 129... Línea 129...
129
            }
129
            }
130
        }
130
        }
Línea 131... Línea 131...
131
 
131
 
132
        $concepts3 = \mod_glossary\local\concept_cache::get_concepts($site->id);
132
        $concepts3 = \mod_glossary\local\concept_cache::get_concepts($site->id);
133
        $this->assertCount(1, $concepts3[0]);
133
        $this->assertCount(1, $concepts3[0]);
134
        $this->arrayHasKey($concepts3[0], $glossary3->id);
134
        $this->assertArrayHasKey($glossary3->id, $concepts3[0]);
135
        $this->assertCount(1, $concepts3[1]);
135
        $this->assertCount(1, $concepts3[1]);
136
        $this->arrayHasKey($concepts3[0], $glossary3->id);
136
        $this->assertArrayHasKey($glossary3->id, $concepts3[1]);
137
        foreach($concepts3[1][$glossary3->id] as $concept) {
137
        foreach($concepts3[1][$glossary3->id] as $concept) {
138
            $this->assertSame(array('id', 'glossaryid', 'concept', 'casesensitive', 'category', 'fullmatch'), array_keys((array)$concept));
138
            $this->assertSame(array('id', 'glossaryid', 'concept', 'casesensitive', 'category', 'fullmatch'), array_keys((array)$concept));
139
            if ($concept->concept === 'global') {
139
            if ($concept->concept === 'global') {
140
                $this->assertEquals($entry31->id, $concept->id);
140
                $this->assertEquals($entry31->id, $concept->id);