Differences Between: [Versions 310 and 403] [Versions 39 and 403]
1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace core_backup; 18 19 use mock_base_attribute; 20 21 defined('MOODLE_INTERNAL') || die(); 22 23 // Include all the needed stuff 24 require_once (__DIR__.'/fixtures/structure_fixtures.php'); 25 26 27 /** 28 * Unit test case the base_attribute class. 29 * 30 * Note: No really much to test here as attribute is 100% 31 * atom extension without new functionality (name/value) 32 * 33 * @package core_backup 34 * @category test 35 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class baseattribute_test extends \basic_testcase { 39 40 /** 41 * Correct base_attribute tests 42 */ 43 function test_base_attribute() { 44 $name_with_all_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'; 45 $value_to_test = 'Some <value> to test'; 46 47 // Create instance with correct names 48 $instance = new mock_base_attribute($name_with_all_chars); 49 $this->assertInstanceOf('base_attribute', $instance); 50 $this->assertEquals($instance->get_name(), $name_with_all_chars); 51 $this->assertNull($instance->get_value()); 52 53 // Set value 54 $instance->set_value($value_to_test); 55 $this->assertEquals($instance->get_value(), $value_to_test); 56 57 // Get to_string() results (with values) 58 $instance = new mock_base_attribute($name_with_all_chars); 59 $instance->set_value($value_to_test); 60 $tostring = $instance->to_string(true); 61 $this->assertTrue(strpos($tostring, '@' . $name_with_all_chars) !== false); 62 $this->assertTrue(strpos($tostring, ' => ') !== false); 63 $this->assertTrue(strpos($tostring, $value_to_test) !== false); 64 } 65 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body