Permalink
Browse files

updated READMEs & clean up config-generator

  • Loading branch information...
1 parent cdbb25e commit 20434005fee1a73a40bcfd3b3ce8b04faceb3d00 @cryptocompress cryptocompress committed Jul 19, 2012
Showing with 46 additions and 35 deletions.
  1. +3 −0 .gitignore
  2. +2 −2 .travis.yml
  3. +20 −17 README.md
  4. +5 −0 phpunit.xml.dist
  5. +6 −11 tests/README.md
  6. +10 −5 tests/{generate_travis_config.php → generate_phpunit_config.php}
View
@@ -12,6 +12,9 @@ doc/html
tests/fixtures/doctrine
phpunit.xml
+mysql.phpunit.xml
+pgsql.phpunit.xml
+sqlite.phpunit.xml
phpcr_tests.db
phpcr_tests.db-journal
View
@@ -17,9 +17,9 @@ before_script:
- if [[ "$DB" == "mysql" ]]; then mysql -e "create database phpcr_tests;"; fi
- if [[ "$DB" == "pgsql" ]]; then psql -c "create database phpcr_tests;" -U postgres; fi
- pyrus install phpunit/DBUnit
- - php tests/generate_travis_config.php
+ - php tests/generate_travis_config.php $DB
-script: phpunit
+script: phpunit -c $DB.phpunit.xml
notifications:
irc: "irc.freenode.org#jackalope"
View
@@ -3,7 +3,7 @@
A powerful implementation of the [PHPCR API](http://phpcr.github.com).
Jackalope binding for relational databases with the DoctrineDBAL. Works with any
-database supported by doctrine (mysql, postgres, ...) and has no dependency
+database supported by doctrine (mysql, postgres, sqlite, ...) and has no dependency
on java or jackrabbit. For the moment, it is less feature complete.
Discuss on jackalope-dev@googlegroups.com
@@ -23,21 +23,20 @@ Please see the file LICENSE in this folder.
# Installation
-If you do not yet have composer, install it like this
-
- curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin
-
-To install jackalope itselves, run the following in the parent directory of where you want jackalope
+To install jackalope, run the following in the parent directory of where you want jackalope
+ # get source
git clone git://github.com/jackalope/jackalope-doctrine-dbal.git
cd jackalope-doctrine-dbal
- php /usr/local/bin/composer.phar install --dev
-Note that the --dev parameter is only needed if you want to be
-able to run the test suite. If you already installed jackalope without the test
-suite, you need to remove composer.lock before running composer again with the
---dev parameter.
+ # install dependencies
+ curl -s http://getcomposer.org/installer | php
+ php composer.phar install
+ # install tests dependencies
+ php composer.phar install --dev
+
+Note that the --dev parameter is only needed if you want to be able to run the test suite.
## Create a repository
@@ -51,6 +50,9 @@ Set up a new database supported by Doctrine DBAL. You can use your favorite GUI
psql -c "CREATE ROLE jackalope WITH ENCRYPTED PASSWORD '1234test' NOINHERIT LOGIN;" -U postgres
psql -c "CREATE DATABASE jackalope WITH OWNER = jackalope;" -U postgres
+### SQLite
+ Database is created automagically if you specify driver and path ("pdo_sqlite", "jackalope.db").
+
## phpunit Tests
If you want to run the tests , please see the [README file in the tests folder](https://github.com/jackalope/jackalope-doctrine-dbal/blob/master/tests/README.md)
@@ -108,12 +110,12 @@ is set up (see above "Enable the commands"). Now you can run:
Once these steps are done, you can bootstrap the library. A minimalist
sample code to get a PHPCR session with the doctrine-dbal backend:
- $driver = 'pdo_mysql'; // pdo_pgsql
- $host = 'localhost';
- $user = 'jackalope';
- $password = '';
- $database = 'jackalope';
- $workspace = 'default';
+ $driver = 'pdo_mysql'; // pdo_pgsql | pdo_sqlite
+ $host = 'localhost';
+ $user = 'jackalope';
+ $password = '';
+ $database = 'jackalope'; // $path = 'jackalope.db'; // for SQLite
+ $workspace = 'default';
// Bootstrap Doctrine
$dbConn = \Doctrine\DBAL\DriverManager::getConnection(array(
@@ -122,6 +124,7 @@ sample code to get a PHPCR session with the doctrine-dbal backend:
'user' => $user,
'password' => $pass,
'dbname' => $database,
+ // 'path' => $path, // for SQLite
));
$repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository(
View
@@ -16,6 +16,11 @@
<!-- Doctrine DBAL database configuration -->
<var name="phpcr.doctrine.dbal.driver" value="pdo_sqlite" />
<var name="phpcr.doctrine.dbal.path" value="phpcr_tests.db" />
+ <!-- for mysql and postgresql use this -->
+ <var name="phpcr.doctrine.dbal.host" value="localhost"/>
+ <var name="phpcr.doctrine.dbal.username" value="jackalope"/>
+ <var name="phpcr.doctrine.dbal.password" value=""/>
+ <var name="phpcr.doctrine.dbal.dbname" value="phpcr_tests"/>
</php>
<testsuites>
View
@@ -14,7 +14,7 @@ its tests folder.
## API test suite
-The mysql.phpunit.xml.dist and pgsql.phpunit.xml.dist are configured to run all tests. You can limit the tests
+The phpunit.xml.dist is configured to run all tests. You can limit the tests
to run by specifying the path to those tests to phpunit.
Note that the phpcr-api tests are skipped for features not implemented in
@@ -40,22 +40,17 @@ You can use your favorite GUI frontend or just do something like this:
psql -c "CREATE ROLE jackalope WITH ENCRYPTED PASSWORD '1234test' NOINHERIT LOGIN;" -U postgres
psql -c "CREATE DATABASE phpcr_tests WITH OWNER = jackalope;" -U postgres
-Test fixtures for functional tests are written in the JCR System XML format. Use
-the converter script ``tests/generate_fixtures.php`` to prepare the fixtures
-for the tests.
-The converted fixtures are written into tests/fixtures/doctrine. The
-converted fixtures are not tracked in the repository, you should regenerate
-them whenever you update the vendors through composer.
+Test fixtures for functional tests are written in the JCR System XML format.
+The converted fixtures are not tracked in the repository, and gets regenerate
+on each testrun.
To run the tests:
- cd /path/to/jackalope-doctrine-dbal/tests
- cp mysql.phpunit.xml.dist phpunit.xml
+ cd /path/to/jackalope-doctrine-dbal
+ # cp phpunit.xml.dist phpunit.xml
# adjust phpunit.xml as necessary
- ./generate_fixtures.php
phpunit
-
## Note on JCR
It would be nice if we were able to run the relevant parts of the JSR-283
@@ -1,7 +1,8 @@
<?php
/**
- * create database specific phpunit.xml for travis
+ * create database specific phpunit.xml config file for travis.
+ * e.g. sqlite.phpunit.xml
*
* @author cryptocompress <cryptocompress@googlemail.com>
*/
@@ -28,8 +29,9 @@
),
);
-if (!in_array(@$_SERVER['DB'], array_keys($config))) {
- die('Error: Database "' . @$_SERVER['DB'] . '" not supported!' . "\n" . 'Try: export DB=mysql' . "\n");
+if (!in_array(@$argv[1], array_keys($config))) {
+ die('Error:' . "\n\t" . 'Database "' . @$argv[1] . '" not supported.' . PHP_EOL .
+ 'Usage:' . "\n\t" . 'php tests/' . basename(__FILE__) . ' [' . implode('|', array_keys($config)) . ']' . "\n");
}
$dom = new \DOMDocument('1.0', 'UTF-8');
@@ -47,11 +49,14 @@
$parent->removeChild($node);
}
-foreach ($config[$_SERVER['DB']] as $key => $value) {
+foreach ($config[$argv[1]] as $key => $value) {
$node = $dom->createElement('var');
$node->setAttribute('name', $key);
$node->setAttribute('value', $value);
$parent->appendChild($node);
}
-$dom->save(str_replace('phpunit.xml.dist', 'phpunit.xml', $source));
+$destination = str_replace('phpunit.xml.dist', $argv[1] . '.phpunit.xml', $source);
+$dom->save($destination);
+
+echo 'Created:' . "\n\t" . realpath($destination). "\n";

0 comments on commit 2043400

Please sign in to comment.