forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-74327 calendar: format event location property if it's a URL.
- Loading branch information
1 parent
5500d14
commit 432fbbc
Showing
7 changed files
with
81 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,19 +14,8 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Contains the class containing unit tests for the calendar lib. | ||
* | ||
* @package core_calendar | ||
* @copyright 2017 Mark Nelson <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace core_calendar; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
require_once(__DIR__ . '/helpers.php'); | ||
|
||
/** | ||
* Class contaning unit tests for the calendar lib. | ||
* | ||
|
@@ -36,6 +25,15 @@ | |
*/ | ||
class lib_test extends \advanced_testcase { | ||
|
||
/** | ||
* Load required test libraries | ||
*/ | ||
public static function setUpBeforeClass(): void { | ||
global $CFG; | ||
|
||
require_once("{$CFG->dirroot}/calendar/tests/helpers.php"); | ||
} | ||
|
||
/** | ||
* Tests set up | ||
*/ | ||
|
@@ -1046,4 +1044,35 @@ public function test_calendar_can_manage_user_event() { | |
$result = calendar_can_manage_user_event($adminevent); | ||
$this->assertEquals(false, $result); | ||
} | ||
|
||
/** | ||
* Data provider for {@see test_calendar_format_event_location} | ||
* | ||
* @return array[] | ||
*/ | ||
public function calendar_format_event_location_provider(): array { | ||
return [ | ||
'Empty' => ['', ''], | ||
'Text' => ['Barcelona', 'Barcelona'], | ||
'Link (http)' => ['http://example.com', '<a title=".*" href="http://example.com">http://example.com</a>'], | ||
'Link (https)' => ['https://example.com', '<a title=".*" href="https://example.com">https://example.com</a>'], | ||
]; | ||
} | ||
|
||
/** | ||
* Test formatting event location | ||
* | ||
* @param string $location | ||
* @param string $expectedpattern | ||
* | ||
* @covers ::calendar_format_event_location | ||
* @dataProvider calendar_format_event_location_provider | ||
*/ | ||
public function test_calendar_format_event_location(string $location, string $expectedpattern): void { | ||
$this->resetAfterTest(); | ||
$this->setAdminUser(); | ||
|
||
$event = create_event(['location' => $location]); | ||
$this->assertMatchesRegularExpression("|^({$expectedpattern})$|", calendar_format_event_location($event)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters