Skip to content

Commit a8125f9

Browse files
committed
Fix unit tests in lib (tsugi-php)
1 parent bfe0ba3 commit a8125f9

4 files changed

Lines changed: 71 additions & 3 deletions

File tree

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,69 @@ Edit `composer.json` and
5656

5757
composer update --prefer-dist tsugi/lib
5858

59+
Making Changes and Contributing Back
60+
-------------------------------------
61+
62+
This `tsugi/lib` directory is a git subtree that tracks the upstream repository
63+
at [tsugiproject/tsugi-php](https://github.com/tsugiproject/tsugi-php). When you
64+
make changes to files in this subtree, you can push those changes back to the
65+
original repository as a pull request.
66+
67+
### Workflow for Contributing Changes
68+
69+
1. **Make your changes** in the `tsugi/lib` directory as you normally would.
70+
71+
2. **Commit your changes** in the parent repository:
72+
73+
git add tsugi/lib
74+
git commit -m "Your commit message describing the changes"
75+
76+
3. **Push changes back to the upstream repository**:
77+
78+
First, ensure you have the upstream repository configured as a remote:
79+
80+
git remote add tsugi-php https://github.com/tsugiproject/tsugi-php.git
81+
82+
Then push the subtree changes to a branch in the upstream repository:
83+
84+
git subtree push --prefix=tsugi/lib tsugi-php your-branch-name
85+
86+
This will create a new branch `your-branch-name` in the upstream repository
87+
with your changes.
88+
89+
4. **Create a Pull Request**:
90+
91+
- Navigate to https://github.com/tsugiproject/tsugi-php
92+
- You should see a banner suggesting to create a PR from your new branch
93+
- Click "Compare & pull request" and fill out the PR description
94+
- Submit the PR for review
95+
96+
### Alternative: Using a Fork
97+
98+
If you prefer to work with a fork of the upstream repository:
99+
100+
1. **Fork the repository** at https://github.com/tsugiproject/tsugi-php
101+
102+
2. **Add your fork as a remote**:
103+
104+
git remote add tsugi-php-fork https://github.com/YOUR-USERNAME/tsugi-php.git
105+
106+
3. **Push to your fork**:
107+
108+
git subtree push --prefix=tsugi/lib tsugi-php-fork your-branch-name
109+
110+
4. **Create a PR** from your fork's branch to the upstream repository.
111+
112+
### Notes
113+
114+
- The `git subtree push` command extracts only the commits that affect files
115+
in the `tsugi/lib` directory and creates a clean history in the upstream
116+
repository.
117+
- Make sure your commit messages are clear and descriptive, as they will be
118+
preserved in the upstream repository.
119+
- If you encounter conflicts during the push, you may need to pull the latest
120+
changes from upstream first using `git subtree pull`.
121+
59122
Releasing
60123
---------
61124

include/setup.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ function print_stack_trace() {
4545

4646
if ( is_string($CFG->staticroot) ) $CFG->staticroot = \Tsugi\Util\U::remove_relative_path($CFG->staticroot);
4747

48-
require_once $CFG->dirroot."/lib/include/lms_lib.php";
48+
// Handle both cases: lib in parent directory structure vs standalone lib
49+
$lms_lib_path = $CFG->dirroot."/lib/include/lms_lib.php";
50+
if ( !file_exists($lms_lib_path) ) {
51+
$lms_lib_path = $CFG->dirroot."/include/lms_lib.php";
52+
}
53+
require_once $lms_lib_path;
4954

5055
// Check to see if pre_config was included
5156
// TODO: Make this a die() about a year after - Thu Nov 11 19:34:23 EST 2021

tests/Util/LTI13Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
require_once "src/Config/ConfigInfo.php";
2121
require_once "src/Blob/BlobUtil.php";
2222

23-
$dirroot = dirname(__FILE__).'/../';
23+
$dirroot = dirname(__FILE__).'/../../';
2424
$wwwroot = 'http://localhost:8888';
2525
$CFG = new \Tsugi\Config\ConfigInfo($dirroot, $wwwroot);
2626

tests/Util/LTITest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
require_once "src/Config/ConfigInfo.php";
2121
require_once "src/Blob/BlobUtil.php";
2222

23-
$dirroot = dirname(__FILE__).'/../';
23+
$dirroot = dirname(__FILE__).'/../../';
2424
$wwwroot = 'http://localhost:8888';
2525
$CFG = new \Tsugi\Config\ConfigInfo($dirroot, $wwwroot);
2626

0 commit comments

Comments
 (0)