Proyectos de Subversion Moodle

Rev

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

Rev 11 Rev 1441
Línea 27... Línea 27...
27
 *
27
 *
28
 * @package core_calendar
28
 * @package core_calendar
29
 * @copyright 2017 Ryan Wyllie <ryan@moodle.com>
29
 * @copyright 2017 Ryan Wyllie <ryan@moodle.com>
30
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
31
 */
32
class calendar_event_exporter_test extends \advanced_testcase {
32
final class calendar_event_exporter_test extends \advanced_testcase {
33
    /**
33
    /**
34
     * Data provider for the timestamp min limit test case to confirm
34
     * Data provider for the timestamp min limit test case to confirm
35
     * that the minimum time limit is set correctly on the boundary cases.
35
     * that the minimum time limit is set correctly on the boundary cases.
36
     */
36
     */
37
    public function get_timestamp_min_limit_test_cases() {
37
    public static function get_timestamp_min_limit_test_cases(): array {
38
        $now = time();
38
        $now = time();
39
        $todaymidnight = usergetmidnight($now);
39
        $todaymidnight = usergetmidnight($now);
40
        $tomorrowmidnight = $todaymidnight + DAYSECS;
40
        $tomorrowmidnight = $todaymidnight + DAYSECS;
41
        $eightam = $todaymidnight + (60 * 60 * 8);
41
        $eightam = $todaymidnight + (60 * 60 * 8);
42
        $starttime = (new \DateTime())->setTimestamp($eightam);
42
        $starttime = (new \DateTime())->setTimestamp($eightam);
Línea 68... Línea 68...
68
            ]
68
            ]
69
        ];
69
        ];
70
    }
70
    }
Línea 71... Línea 71...
71
 
71
 
72
    /**
72
    /**
73
     * @dataProvider get_timestamp_min_limit_test_cases()
73
     * @dataProvider get_timestamp_min_limit_test_cases
74
     */
74
     */
75
    public function test_get_timestamp_min_limit($starttime, $min, $expected): void {
75
    public function test_get_timestamp_min_limit($starttime, $min, $expected): void {
76
        $class = calendar_event_exporter::class;
76
        $class = calendar_event_exporter::class;
77
        $mock = $this->getMockBuilder($class)
77
        $mock = $this->getMockBuilder($class)
Línea 88... Línea 88...
88
 
88
 
89
    /**
89
    /**
90
     * Data provider for the timestamp max limit test case to confirm
90
     * Data provider for the timestamp max limit test case to confirm
91
     * that the maximum time limit is set correctly on the boundary cases.
91
     * that the maximum time limit is set correctly on the boundary cases.
92
     */
92
     */
93
    public function get_timestamp_max_limit_test_cases() {
93
    public static function get_timestamp_max_limit_test_cases(): array {
94
        $now = time();
94
        $now = time();
95
        $todaymidnight = usergetmidnight($now);
95
        $todaymidnight = usergetmidnight($now);
96
        $yesterdaymidnight = $todaymidnight - DAYSECS;
96
        $yesterdaymidnight = $todaymidnight - DAYSECS;
97
        $eightam = $todaymidnight + (60 * 60 * 8);
97
        $eightam = $todaymidnight + (60 * 60 * 8);
Línea 124... Línea 124...
124
            ]
124
            ]
125
        ];
125
        ];
126
    }
126
    }
Línea 127... Línea 127...
127
 
127
 
128
    /**
128
    /**
129
     * @dataProvider get_timestamp_max_limit_test_cases()
129
     * @dataProvider get_timestamp_max_limit_test_cases
130
     */
130
     */
131
    public function test_get_timestamp_max_limit($starttime, $max, $expected): void {
131
    public function test_get_timestamp_max_limit($starttime, $max, $expected): void {
132
        $class = calendar_event_exporter::class;
132
        $class = calendar_event_exporter::class;
133
        $mock = $this->getMockBuilder($class)
133
        $mock = $this->getMockBuilder($class)