Commit a5867544 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Réorganisation du répertoire des tests : séparation des tests unitaires et fonctionnels.

parent e9c6f22c
<?php
$settings = array(
);
/**
* You do not need to edit below this line
*/
return array(
'unicaen-ldap' => $settings,
);
<?php
$settings = array(
'host' => 'ldev.unicaen.fr',
'port' => 389,
'version' => 3,
'baseDn' => "dc=unicaen,dc=fr",
'bindRequiresDn' => true,
'username' => "uid=gestbg,ou=system,dc=unicaen,dc=fr",
'password' => "LgeDstAbgP2012",
'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))",
);
return array(
'unicaen-ldap' => $settings
);
\ No newline at end of file
<?php
namespace UnicaenLdapTest;
namespace UnicaenLdapFuncTest;
use Zend\Loader\AutoloaderFactory;
use Zend\Mvc\Service\ServiceManagerConfig;
......
<?php
namespace UnicaenLdapTest\Service;
namespace UnicaenLdapFuncTest\Service;
use PHPUnit_Framework_TestCase;
use Zend\ServiceManager\ServiceManager;
use UnicaenLdap\Ldap;
use UnicaenLdap\Filter\People as PeopleFilter;
use UnicaenLdapFuncTest\Bootstrap;
/**
* @group Service
......@@ -22,7 +20,7 @@ class ServiceTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$serviceManager = \UnicaenLdapTest\Bootstrap::getServiceManager();
$serviceManager = Bootstrap::getServiceManager();
$this->service = $serviceManager->get('ldapServicePeople');
}
......@@ -30,5 +28,13 @@ class ServiceTest extends PHPUnit_Framework_TestCase
{
$this->assertInstanceOf('UnicaenLdap\Service\Service', $this->service);
$this->assertEquals('dc=unicaen,dc=fr', $this->service->getLdap()->getBaseDn());
$this->assertTrue(true);
}
public function testCanSearch()
{
$filter = PeopleFilter::noIndividu("21237");
$result = $this->service->search($filter);
var_dump(get_class($result));
}
}
\ No newline at end of file
<?php
return array(
'unicaen-ldap' => array(
'host' => 'ldev.unicaen.fr',
'port' => 389,
'version' => 3,
'baseDn' => "dc=unicaen,dc=fr",
'bindRequiresDn' => true,
'username' => "uid=applidev,ou=system,dc=unicaen,dc=fr",
'password' => "Ifq1pdeS2of_7DC",
'accountFilterFormat' => "(&(objectClass=posixAccount)(supannAliasLogin=%s))",
)
);
\ No newline at end of file
......@@ -2,8 +2,8 @@
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="UnicaenLdap">
<directory>./UnicaenLdapTest</directory>
<testsuite name="UnicaenLdapFuncTest">
<directory>./UnicaenLdapFuncTest</directory>
</testsuite>
</testsuites>
......@@ -15,7 +15,7 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../src</directory>
<directory suffix=".php">../../src</directory>
</whitelist>
</filter>
......
<?php
namespace UnicaenLdapUnitTest;
use Zend\Loader\AutoloaderFactory;
use RuntimeException;
error_reporting(E_ALL | E_STRICT);
chdir(__DIR__);
/**
* Test bootstrap, for setting up autoloading
*/
class Bootstrap
{
public static function init()
{
$zf2ModulePaths = array(dirname(dirname(dirname(__DIR__))));
if (($path = static::findParentPath('vendor'))) {
$zf2ModulePaths[] = $path;
}
if (($path = static::findParentPath('module')) !== $zf2ModulePaths[0]) {
$zf2ModulePaths[] = $path;
}
$zf2ModulePaths[] = __DIR__;
static::initAutoloader();
}
protected static function initAutoloader()
{
$vendorPath = static::findParentPath('vendor');
if (is_readable($vendorPath . '/autoload.php')) {
include $vendorPath . '/autoload.php';
return;
}
$zf2Path = getenv('ZF2_PATH');
if (!$zf2Path) {
if (defined('ZF2_PATH')) {
$zf2Path = ZF2_PATH;
} elseif (is_dir($vendorPath . '/ZF2/library')) {
$zf2Path = $vendorPath . '/ZF2/library';
} elseif (is_dir($vendorPath . '/zendframework/zendframework/library')) {
$zf2Path = $vendorPath . '/zendframework/zendframework/library';
}
}
if (!$zf2Path) {
throw new RuntimeException('Unable to load ZF2. Run `php composer.phar install` or define a ZF2_PATH environment variable.');
}
include $zf2Path . '/Zend/Loader/AutoloaderFactory.php';
AutoloaderFactory::factory(array(
'Zend\Loader\StandardAutoloader' => array(
'autoregister_zf' => true,
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__,
),
),
));
}
protected static function findParentPath($path)
{
$dir = __DIR__;
$previousDir = '.';
while (!is_dir($dir . '/' . $path)) {
$dir = dirname($dir);
if ($previousDir === $dir) return false;
$previousDir = $dir;
}
return $dir . '/' . $path;
}
}
Bootstrap::init();
......@@ -12,11 +12,6 @@ use UnicaenLdap\Node;
*/
class NodeTest extends PHPUnit_Framework_TestCase
{
/**
* @var ServiceManager
*/
protected $serviceManager;
/**
*
* @var Ldap
......@@ -26,7 +21,6 @@ class NodeTest extends PHPUnit_Framework_TestCase
protected function setUp()
{
$this->serviceManager = Bootstrap::getServiceManager();
$this->ldap = $this->getMock('UnicaenLdap\Ldap', array('getBaseDn'));
$this->ldap->expects($this->any())
->method('getBaseDn')
......
<?php
namespace UnicaenLdapUnitTest\Service;
use PHPUnit_Framework_TestCase;
/**
* @group Service
*/
class ServiceTest extends PHPUnit_Framework_TestCase
{
/**
*
* @var \UnicaenLdap\Service\Service
*/
protected $service;
protected function setUp()
{
// $serviceManager = Bootstrap::getServiceManager();
// $this->service = $serviceManager->get('ldapServicePeople');
}
public function testConstructor()
{
// $this->assertInstanceOf('UnicaenLdap\Service\Service', $this->service);
// $this->assertEquals('dc=unicaen,dc=fr', $this->service->getLdap()->getBaseDn());
$this->assertTrue(true);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="UnicaenLdapUnitTest">
<directory>./UnicaenLdapUnitTest</directory>
</testsuite>
</testsuites>
<logging>
<!--<log type="junit" target="/tmp/phpunit/logs/junit.xml" />-->
<!--<log type="coverage-clover" target="/tmp/phpunit/logs/clover.xml" />-->
<!--<log type="coverage-html" target="/tmp/phpunit/coverage" />-->
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">../../src</directory>
</whitelist>
</filter>
<groups>
</groups>
</phpunit>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment