new type API

This commit is contained in:
Roland Gruber 2017-04-26 19:25:12 +02:00
parent c51918907e
commit 50d472e96d
1 changed files with 11 additions and 3 deletions

View File

@ -3,7 +3,7 @@
$Id$ $Id$
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2016 Roland Gruber Copyright (C) 2016 - 2017 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -31,14 +31,22 @@ require_once 'lam/lib/types.inc';
*/ */
class ListAttributeTest extends PHPUnit_Framework_TestCase { class ListAttributeTest extends PHPUnit_Framework_TestCase {
private $type;
public function setUp() {
$this->type = $this->getMockBuilder('ConfiguredType')->setMethods(array('getBaseType'))->getMock();
$scope = new user($this->type);
$this->type->method('getBaseType')->willReturn($scope);
}
public function testPreTranslated() { public function testPreTranslated() {
$attr = new \LAM\TYPES\ListAttribute('#uid', 'user'); $attr = new \LAM\TYPES\ListAttribute('#uid', $this->type);
$this->assertEquals('User name', $attr->getAlias()); $this->assertEquals('User name', $attr->getAlias());
$this->assertEquals('uid', $attr->getAttributeName()); $this->assertEquals('uid', $attr->getAttributeName());
} }
public function testCustomAlias() { public function testCustomAlias() {
$attr = new \LAM\TYPES\ListAttribute('uid:My translation', 'user'); $attr = new \LAM\TYPES\ListAttribute('uid:My translation', $this->type);
$this->assertEquals('My translation', $attr->getAlias()); $this->assertEquals('My translation', $attr->getAlias());
$this->assertEquals('uid', $attr->getAttributeName()); $this->assertEquals('uid', $attr->getAttributeName());
} }