Skip to content

Commit 5fbffae

Browse files
authored
Merge pull request #168 from iMattPro/update-tests
Maintenance
2 parents 60762db + 9fde561 commit 5fbffae

2 files changed

Lines changed: 73 additions & 17 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Sync develop branch
2+
3+
on:
4+
push:
5+
branches:
6+
# Keep this in sync with SYNC_SOURCE_BRANCH below.
7+
# GitHub Actions does not allow env values in trigger branch filters.
8+
- master
9+
10+
env:
11+
SYNC_SOURCE_BRANCH: master
12+
SYNC_TARGET_BRANCH: dev/4.0
13+
14+
permissions:
15+
contents: write
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: false
20+
21+
jobs:
22+
sync-dev-branch:
23+
name: Merge master into dev/4.0 branch
24+
# Keep this named after the GitHub repository.
25+
# GitHub Actions does not allow workflow env values in jobs.<job_id>.if.
26+
if: github.repository == 'phpbb/ideas' && github.event.repository.fork == false
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Check out repository
31+
uses: actions/checkout@v6
32+
with:
33+
fetch-depth: 0
34+
35+
- name: Configure Git author
36+
run: |
37+
git config user.name "github-actions[bot]"
38+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
39+
40+
- name: Merge source branch into target branch when clean
41+
run: |
42+
if ! git ls-remote --exit-code --heads origin "${SYNC_TARGET_BRANCH}" > /dev/null 2>&1; then
43+
echo "origin/${SYNC_TARGET_BRANCH} does not exist; skipping."
44+
exit 0
45+
fi
46+
47+
git fetch --no-tags --prune origin "${SYNC_TARGET_BRANCH}"
48+
git checkout -B "${SYNC_TARGET_BRANCH}" "origin/${SYNC_TARGET_BRANCH}"
49+
50+
if git merge --no-edit "$GITHUB_SHA"; then
51+
if [ "$(git rev-list --count "origin/${SYNC_TARGET_BRANCH}..HEAD")" -eq 0 ]; then
52+
echo "${SYNC_TARGET_BRANCH} is already up to date."
53+
exit 0
54+
fi
55+
56+
git push origin "HEAD:${SYNC_TARGET_BRANCH}"
57+
else
58+
echo "${SYNC_SOURCE_BRANCH} could not be merged cleanly into ${SYNC_TARGET_BRANCH}; skipping."
59+
if git rev-parse -q --verify MERGE_HEAD > /dev/null; then
60+
git merge --abort
61+
fi
62+
exit 1
63+
fi

tests/functional/viewonline_test.php

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,24 @@
1616
class viewonline_test extends ideas_functional_base
1717
{
1818
/**
19-
* Visit Ideas as user "admin"
19+
* Test viewonline page for admin
2020
*/
21-
public function test_viewonline_visit_ideas()
21+
public function test_viewonline_check_viewonline()
2222
{
23+
// Visit Ideas as user "admin"
2324
$this->login();
2425
$crawler = self::request('GET', "app.php/ideas?sid=$this->sid");
2526
$this->assertContainsLang('IDEAS_TITLE', $crawler->filter('h2')->text());
26-
}
2727

28-
/**
29-
* Test viewonline page for admin
30-
*
31-
* We use a second function here, so we get a new session and can log in
32-
* without having to log out "admin" first.
33-
*
34-
* @depends test_viewonline_visit_ideas
35-
*/
36-
public function test_viewonline_check_viewonline()
37-
{
38-
// Create user1 and send them to the Viewonline
39-
$this->create_user('user1');
40-
$this->login('user1');
28+
// Create a second user and check who is online from a separate session.
29+
self::$client->restart();
30+
$this->create_user('ideas-viewonline-user1');
31+
$this->login('ideas-viewonline-user1');
32+
// PHP goes faster than DBMS, make sure session data got written to the database.
33+
sleep(1);
4134
$crawler = self::request('GET', "viewonline.php?sid=$this->sid");
4235

43-
// Is admin still viewing Ideas page
36+
// Is admin still viewing Ideas page?
4437
self::assertStringContainsString('admin', $crawler->filter('#page-body table.table1')->text());
4538

4639
$session_entries = $crawler->filter('#page-body table.table1 tr')->count();

0 commit comments

Comments
 (0)