Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve readme #842

Merged
merged 2 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ phpunit.xml
jackrabbit/
vendor/
composer.lock
/tests/jackrabbit-standalone-*.jar
69 changes: 49 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

## Requirements

* PHP 7.1
* libxml version >= 2.7.0 (due to a bug in libxml [http://bugs.php.net/bug.php?id=36501](http://bugs.php.net/bug.php?id=36501))
* [composer](http://getcomposer.org/)
* See also the `require` section of [composer.json](composer.json)
Expand All @@ -29,22 +28,52 @@ Thanks to

## Running the tests

This examples shows how to run the tests for jackrabbit. You can run the tests
for the other backends. Just replace jackrabbit with the name of the backend
you want to run.

1. Make sure you have installed the dependencies that can't be installed with
Composer (e.g. when running `travis_doctrine_dbal.sh`, install MySQL). Do not
run `composer install`, it will not work because phpcr-odm requires virtual
packages that change depending on the backend you want to test.
2. Run this command to download jackrabbit and launch it (requires wget)

./tests/travis_jackrabbit.sh

Please note that this will also require implementations for virtual packages
that match the backend you want to test, resulting in a change in your
`composer.json`. Make sure you do not check in this change into version control.

3. Run the tests:

phpunit -c tests/phpunit_jackrabbit.xml.dist
There are separate test setups for the `doctrine-dbal` and the `jackrabbit` PHPCR implementations.
Before installing the composer dependencies, you will need to prepare the database for storage and
choose a `phpcr/phpcr-implementation`.
Doing so will change the `composer.json` file - please make sure you do not check in this change
into version control.

### Setting up to test with Jackrabbit

1. Make sure you have `java` and `wget` installed, then run this script to install and start jackrabbit:
```
tests/script_jackrabbit.sh
```
2. Require the PHPCR implementation:
```
composer require jackalope/jackalope-jackrabbit --no-update
```
3. Now you can install all dependencies with:
```
composer install
```
4. Now you can run the tests:
```
vendor/bin/phpunit -c tests/phpunit_jackrabbit.xml.dist
```
You can also copy the phpunit dist file to `./phpunit.xml` to have it selected by default, or
if you need to customize any configuration options.

### Setting up to test with Doctrine-DBAL

1. For `doctrine-dbal`, make sure that MySQL is installed. If the connection parameters in
`cli-config.doctrine_dbal.php.dist` are not correct, manually create `cli-config.php` and adjust
the options as needed. Then run the script to initialize the repository in the database:
```
tests/script_doctrine_dbal.sh
```
2. Require the PHPCR implementation
```
composer require jackalope/jackalope-doctrine-dbal --no-update
```
3. Now you can install all dependencies with:
```
composer install
```
4. Now you can run the tests:
```
vendor/bin/phpunit -c tests/phpunit_doctrine_dbal.xml.dist
```
You can also copy the phpunit dist file to `./phpunit.xml` to have it selected by default, or
if you need to customize any configuration options.
5 changes: 5 additions & 0 deletions tests/jackrabbit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ JAR=jackrabbit-standalone-$VERSION.jar
# download jackrabbit jar from archive, as the dist only contains the latest
# stable versions
if [ ! -f "$DIR/$JAR" ]; then
if ! [ -x "$(command -v wget)" ]; then
echo 'Error: wget is not installed.' >&2
exit 1
fi

wget http://archive.apache.org/dist/jackrabbit/$VERSION/$JAR
fi

Expand Down
7 changes: 5 additions & 2 deletions tests/script_doctrine_dbal.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

SCRIPT_DIR="${0%/*}"

Expand All @@ -12,6 +13,8 @@ elif test "${SCRIPT_DIR:0:1}" != "/" ; then
SCRIPT_DIR="$PWD/$SCRIPT_DIR"
fi

cp ${SCRIPT_DIR}/../cli-config.doctrine_dbal.php.dist ${SCRIPT_DIR}/../cli-config.php
if [ ! -f ${SCRIPT_DIR}/../cli-config.php ]; then
cp ${SCRIPT_DIR}/../cli-config.doctrine_dbal.php.dist ${SCRIPT_DIR}/../cli-config.php
fi
${SCRIPT_DIR}/../bin/phpcrodm jackalope:init:dbal --force
${SCRIPT_DIR}/../bin/phpcrodm doctrine:phpcr:register-system-node-types
${SCRIPT_DIR}/../bin/phpcrodm doctrine:phpcr:register-system-node-types
1 change: 1 addition & 0 deletions tests/script_jackrabbit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e

SCRIPT_DIR="${0%/*}"

Expand Down