Skip to content

Commit 5eef959

Browse files
committed
adding test for repository factory. TODO: test bootstrap should really be refactored
1 parent 89392fd commit 5eef959

File tree

2 files changed

+40
-5
lines changed

2 files changed

+40
-5
lines changed

bootstrap.dist.php

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Sample bootstrap file (as used for jr_cr)
55
*
66
* This file does some basic stuff that's project specific.
7-
* Please copy the file for your project and make sure phpunit.xml includes
7+
* Please copy the file for your project and make sure phpunit.xml includes
88
* this file.
9-
*
9+
*
1010
* function getRepository(config) which returns the repository
1111
* function getJCRSession(config) which returns the session
1212
*
@@ -24,7 +24,7 @@
2424
}
2525
}
2626

27-
/**
27+
/**
2828
* autoloader: jackalope-api-tests relies on this autoloader.
2929
*/
3030
function jackalopeApiTestsAutoload($class) {
@@ -37,11 +37,27 @@ function jackalopeApiTestsAutoload($class) {
3737
}
3838
spl_autoload_register('jackalopeApiTestsAutoload');
3939

40+
/**
41+
* @return string classname of the repository factory
42+
*/
43+
function getRepositoryFactoryClass()
44+
{
45+
return 'Jackalope\RepositoryFactoryJackrabbit';
46+
}
47+
48+
/**
49+
* @return hashmap to be used with the repository factory
50+
*/
51+
function getRepositoryFactoryParameters($config)
52+
{
53+
return array('jackalope.jackrabbit_uri' => $config['url']);
54+
}
55+
4056
/**
4157
* Repository lookup is implementation specific.
4258
* @param config The configuration where to find the repository
4359
* @return the repository instance
44-
*/
60+
*/
4561
function getRepository($config) {
4662
if (empty($config['url']) || empty($config['transport'])) {
4763
return false;
@@ -58,7 +74,7 @@ function getSimpleCredentials($user, $password) {
5874
return new jr_cr_simplecredentials($user, $password);
5975
}
6076

61-
/**
77+
/**
6278
* Get a session for this implementation.
6379
* @param config The configuration that is passed to getRepository
6480
* @param credentials The credentials to log into the repository. If omitted, $config['user'] and $config['pass'] is used with getSimpleCredentials
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
require_once(dirname(__FILE__) . '/../../inc/baseCase.php');
3+
4+
class Connecting_4_RepositoryFactoryTest extends phpcr_suite_baseCase
5+
{
6+
//don't care about fixtures
7+
8+
// 4.1 Repository
9+
public function testRepositoryFactory()
10+
{
11+
$class = getRepositoryFactoryClass();
12+
$factory = new $class;
13+
$this->assertInstanceOf('PHPCR\RepositoryFactoryInterface', $factory);
14+
15+
$repo = $factory->getRepository(getRepositoryFactoryParameters($this->config));
16+
$this->assertInstanceOf('PHPCR\RepositoryInterface', $repo);
17+
}
18+
19+
}

0 commit comments

Comments
 (0)