Liaison.php
<?php
namespace Lia\Test\Disabled;
class Liaison extends \Tlf\Tester {
public function testRootCallMethods(){
$this->disable();
$ns = 'methods-test';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$addon = new \Lia\Addon($package);
$lia->addMethod('xyz', function(){return 'xyz';});
$lia->addMethod($ns.'.def', function(){return 'def';});
$lia->addMethod($ns.'.addon.abc', function(){return 'abc';});
$this->compare('xyz', $addon->_api('xyz'));
$this->compare('def', $addon->_api($ns.'.def'));
$this->compare('abc', $addon->_api($ns.'.addon.abc'));
$this->compare('xyz', $package->_api('xyz'));
$this->compare('def', $package->_api($ns.'.def'));
$this->compare('abc', $package->_api($ns.'.addon.abc'));
$this->compare('xyz', $lia->_api('xyz'));
$this->compare('def', $lia->_api($ns.'.def'));
$this->compare('abc', $lia->_api($ns.'.addon.abc'));
$this->compare ('xyz', $package->_lia->xyz());
$this->compare('xyz', $package->lia->xyz());
$this->compare('xyz', $addon->lia->lia->xyz());
$this->compare('xyz', $addon->_lia->xyz());
$this->compare('def', $addon->lia->def());
}
public function testAddDotMethods(){
$this->disable();
$ns = 'methods-test';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$addon = new \Lia\Addon($package);
$lia->addMethod($ns.'.addon.abc', function(){return 'abc';});
$this->compare('abc', $addon->abc());
$this->compare('abc',$package->methods['addon']['abc']());
$this->compare('abc',$package->api('addon.abc'));
$this->compare('abc',$lia->methods[$ns]['addon']['abc']());
$this->compare('abc',$lia->api($ns.'.addon.abc'));
$lia->addMethod($ns.'.def', function(){return 'def';});
$this->compare('def',$package->def());
$this->compare('def', $lia->api($ns.'.def'));
}
public function testAddMethods(){
$this->disable();
$ns = 'methods-test';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$addon = new \Lia\Addon($package);
$addon->addMethod('abc', function(){return 'abc';});
$this->compare('abc', $addon->abc());
$this->compare('abc',$package->methods['addon']['abc']());
$this->compare('abc',$package->api('addon.abc'));
$this->compare('abc',$lia->methods[$ns]['addon']['abc']());
$this->compare('abc',$lia->api($ns.'.addon.abc'));
$package->addMethod('def', function(){return 'def';});
$this->compare('def',$package->def());
$this->compare('def', $lia->api($ns.'.def'));
}
/**
* Checks namespacing & structure of addons property with lia, a package, and an addon
*/
public function testAddAddonsPackageAddons(){
$this->disable();
$ns = 'test-ns';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$addon = new \Lia\Addon($package);
$this->compare_raw($package->addons, ['package'=>$package, 'addon'=>$addon]);
$this->compare_raw($package, $lia->addons[$ns]['package']);
$this->compare_raw($addon, $lia->addons[$ns]['addon']);
$this->compare_raw(
[
$ns=>[
'package'=>$package,
'addon'=>$addon
]
],
$lia->addons
);
}
/**
* Checks namespacing & structure of addons property with lia & a package
*/
public function testAddAddonsPackage(){
$this->disable();
$ns = 'namespace';
$lia = new \Lia();
$package = new \Lia\Package($lia, $ns);
$this->compare_raw(
[
$ns=>[
'package'=>$package
]
],
$lia->addons
);
}
public function testPackageConfig(){
//this feature was removed for v0.6
$this->disable();
return;
$lia = new \Lia();
$package = new \Lia\Package($lia, 'ns');
$addon = new \Lia\Addon($package, 'addon');
$package->set('something', 'value');
$this->compare(
[
'ns'=>[
'dir' => null,
'something'=>'value',
'addon'=>[]
]
],
$lia->props,
);
}
public function testDirectConfigsAccess(){
//this feature was removed for v0.6
$this->disable();
return;
$lia = new \Lia();
$package = new \Lia\Package($lia, 'ns');
$addon = new \Lia\Addon($package, 'addon');
$addon->set('something', 'value');
$lia->set('ns.addon.something', 'new_value');
$this->compare(
[
'ns'=>[
'dir' => null,
'addon'=>[
'something'=> 'new_value',
]
]
],
$lia->props,
);
$this->compare('new_value', $lia->props['ns']['addon']['something']);
$this->compare('new_value', $package->props['addon']['something']);
$this->compare('new_value', $addon->props['something']);
}
public function testNamespaceConfigs(){
//this feature was removed for v0.6
$this->disable();
return;
$lia = new \Lia();
$package = new \Lia\Package($lia, 'ns');
$addon = new \Lia\Addon($package, 'addon');
$addon->set('something', 'value');
$lia->set('ns.addon.something', 'new_value');
$this->compare(
[
'ns'=>[
'dir' => null,
'addon'=>[
'something'=> 'new_value',
]
]
],
$lia->props,
);
$this->compare('new_value', $lia->get('ns.addon.something'));
$this->compare('new_value', $package->get('addon.something'));
$this->compare('new_value', $addon->get('something'));
}
public function testPackageAddonConfig(){
//this feature was removed for v0.6
$this->disable();
return;
$lia = new \Lia();
$package = new \Lia\Package($lia, 'ns');
$addon = new \Lia\Addon($package, 'addon');
$addon->set('something', 'value');
$this->compare(
[
'ns'=>[
'dir' => null,
'addon'=>[
'something'=> 'value',
]
]
],
$lia->props,
);
}
}