Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
@tool @tool_behat
2
Feature: Frozen clock in Behat
3
  In order to write tests that depend on the current system time
4
  As a test writer
5
  I need to set the time using a Behat step
6
 
7
  Background:
8
    Given the following "courses" exist:
9
      | fullname | shortname |
10
      | Course 1 | C1        |
11
    And the following "activities" exist:
12
      | activity | course | name      | idnumber | externalurl                                                 |
13
      | url      | C1     | Fixture   | url1     | #wwwroot#/admin/tool/behat/tests/fixtures/core/showtime.php |
14
      | forum    | C1     | TestForum | forum1   |                                                             |
15
 
16
  Scenario: Time has been frozen
17
    # Set up 2 forum discussions at different times. This tests the clock in the Behat CLI process.
18
    Given the time is frozen at "2024-03-01 12:34:56"
19
    And the following "mod_forum > discussions" exist:
20
      | user  | forum  | name     | message  |
21
      | admin | forum1 | Subject1 | Message1 |
22
    And the time is frozen at "2024-08-01 12:34:56"
23
    And the following "mod_forum > discussions" exist:
24
      | user  | forum  | name     | message  |
25
      | admin | forum1 | Subject2 | Message2 |
26
    When I am on the "TestForum" "forum activity" page logged in as admin
27
    Then I should see "1 Mar 2024" in the "Subject1" "table_row"
28
    And I should see "1 Aug 2024" in the "Subject2" "table_row"
29
    # Also view time on the fixture page. This tests the clock for Behat web server requests.
30
    And I am on the "Fixture" "url activity" page
31
    And I should see "Behat time is not the same as real time"
32
    # This Unix time corresponds to 12:34:56 in Perth time zone.
33
    And I should see "Unix time 1722486896"
34
    And I should see "Date-time 2024-08-01 12:34:56"
35
 
36
  # This scenario is second, to verify that the clock automatically goes back to normal after test.
37
  Scenario: Time is normal
38
    Given the following "mod_forum > discussions" exist:
39
      | user  | forum  | name     | message  |
40
      | admin | forum1 | Subject1 | Message1 |
41
    When I am on the "TestForum" "forum activity" page logged in as admin
42
    # The time should be the real current time, not the frozen time.
43
    Then I should see "## today ##%d %b %Y##" in the "Subject1" "table_row"
44
    And I am on the "Fixture" "url activity" page
45
    And I should see "Behat time is the same as real time"
46
 
47
  Scenario: Time is frozen and then unfrozen
48
    Given the time is frozen at "2024-03-01 12:34:56"
49
    And the following "mod_forum > discussions" exist:
50
      | user  | forum  | name     | message  |
51
      | admin | forum1 | Subject1 | Message1 |
52
    And the time is no longer frozen
53
    And the following "mod_forum > discussions" exist:
54
      | user  | forum  | name     | message  |
55
      | admin | forum1 | Subject2 | Message2 |
56
    When I am on the "TestForum" "forum activity" page logged in as admin
57
    Then I should see "1 Mar 2024" in the "Subject1" "table_row"
58
    # The time should be the real current time, not the frozen time for this entry.
59
    And I should see "## today ##%d %b %Y##" in the "Subject2" "table_row"
60
    And I am on the "Fixture" "url activity" page
61
    And I should see "Behat time is the same as real time"