forked from extern/egroupware
Tests for customfields read options from file
This commit is contained in:
parent
f6ae17c0d3
commit
74dafc653a
@ -172,6 +172,75 @@ class CustomfieldsTest extends LoggedInTest
|
||||
Customfields::save(self::APP, $fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getting options from a file
|
||||
*
|
||||
* @dataProvider fileOptionProvider
|
||||
*/
|
||||
public function testGetOptionsFromGoodFile($expected, $file)
|
||||
{
|
||||
// Load
|
||||
$options = Customfields::get_options_from_file('api/tests/fixtures/Storage/'.$file);
|
||||
|
||||
// Check
|
||||
$this->assertInternalType('array', $options);
|
||||
$this->assertEquals($expected, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide some options (duplicated in the files) to check loading
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fileOptionProvider()
|
||||
{
|
||||
// Expected options, file
|
||||
return array(
|
||||
array(array(
|
||||
'' => 'Select',
|
||||
'Α'=> 'α Alpha',
|
||||
'Β'=> 'β Beta',
|
||||
'Γ'=> 'γ Gamma',
|
||||
'Δ'=> 'δ Delta',
|
||||
'Ε'=> 'ε Epsilon',
|
||||
'Ζ'=> 'ζ Zeta',
|
||||
'Η'=> 'η Eta',
|
||||
'Θ'=> 'θ Theta',
|
||||
'Ι'=> 'ι Iota',
|
||||
'Κ'=> 'κ Kappa',
|
||||
'Λ'=> 'λ Lambda',
|
||||
'Μ'=> 'μ Mu',
|
||||
'Ν'=> 'ν Nu',
|
||||
'Ξ'=> 'ξ Xi',
|
||||
'Ο'=> 'ο Omicron',
|
||||
'Π'=> 'π Pi',
|
||||
'Ρ'=> 'ρ Rho',
|
||||
'Σ'=> 'σ Sigma',
|
||||
'Τ'=> 'τ Tau',
|
||||
'Υ'=> 'υ Upsilon',
|
||||
'Φ'=> 'φ Phi',
|
||||
'Χ'=> 'χ Chi',
|
||||
'Ψ'=> 'ψ Psi',
|
||||
'Ω'=> 'ω Omega'
|
||||
), 'greek_options.php'),
|
||||
array(array(
|
||||
'View Subs' => "egw_open('','infolog','list',{action:'sp',action_id:widget.getRoot().getArrayMgr('content').getEntry('info_id')},'infolog','infolog');"
|
||||
), 'infolog_subs_option.php')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A file that is not found or cannot be read should return an array
|
||||
* with an error message, and not error. It's impossible to deal with an
|
||||
* actual invalid file though, they just cause Fatal Errors.
|
||||
*/
|
||||
public function testGetOptionsFromMissingFile()
|
||||
{
|
||||
$options = Customfields::get_options_from_file('totally invalid');
|
||||
$this->assertInternalType('array', $options);
|
||||
$this->assertCount(1, $options);
|
||||
}
|
||||
|
||||
protected function create_private_field()
|
||||
{
|
||||
// Create field
|
||||
|
29
api/tests/fixtures/Storage/greek_options.php
vendored
Normal file
29
api/tests/fixtures/Storage/greek_options.php
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// Options for testing selectboxes
|
||||
$options = array(
|
||||
'' => 'Select',
|
||||
'Α'=> 'α Alpha',
|
||||
'Β'=> 'β Beta',
|
||||
'Γ'=> 'γ Gamma',
|
||||
'Δ'=> 'δ Delta',
|
||||
'Ε'=> 'ε Epsilon',
|
||||
'Ζ'=> 'ζ Zeta',
|
||||
'Η'=> 'η Eta',
|
||||
'Θ'=> 'θ Theta',
|
||||
'Ι'=> 'ι Iota',
|
||||
'Κ'=> 'κ Kappa',
|
||||
'Λ'=> 'λ Lambda',
|
||||
'Μ'=> 'μ Mu',
|
||||
'Ν'=> 'ν Nu',
|
||||
'Ξ'=> 'ξ Xi',
|
||||
'Ο'=> 'ο Omicron',
|
||||
'Π'=> 'π Pi',
|
||||
'Ρ'=> 'ρ Rho',
|
||||
'Σ'=> 'σ Sigma',
|
||||
'Τ'=> 'τ Tau',
|
||||
'Υ'=> 'υ Upsilon',
|
||||
'Φ'=> 'φ Phi',
|
||||
'Χ'=> 'χ Chi',
|
||||
'Ψ'=> 'ψ Psi',
|
||||
'Ω'=> 'ω Omega'
|
||||
);
|
5
api/tests/fixtures/Storage/infolog_subs_option.php
vendored
Normal file
5
api/tests/fixtures/Storage/infolog_subs_option.php
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
// Options file that, when used for a button, will open the list of infolog sub-entries
|
||||
$options = array(
|
||||
'View Subs' => "egw_open('','infolog','list',{action:'sp',action_id:widget.getRoot().getArrayMgr('content').getEntry('info_id')},'infolog','infolog');"
|
||||
);
|
Loading…
Reference in New Issue
Block a user