0009810: Plugins architecture
[tine20] / tests / tine20 / Tinebase / Pluggable / ConcreteTest.php
1 <?php
2 /**
3  * Tine 2.0 - http://www.tine20.org
4  * 
5  * @package     Tinebase
6  * @subpackage  Pluggable
7  * @license     http://www.gnu.org/licenses/agpl.html
8  * @copyright   Copyright (c) 2007-2014 Metaways Infosystems GmbH (http://www.metaways.de)
9  * @copyright   Copyright (c) 2014 Serpro (http://www.serpro.gov.br)
10  * @author      Fl├ívio Gomes da Silva Lisboa <flavio.lisboa@serpro.gov.br>
11  * 
12  */
13
14 /**
15  * Test helper
16  */
17 require_once dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
18
19 /**
20  * Test class for Tinebase_Pluggable
21  */
22 class Tinebase_Pluggable_ConcreteTest extends PHPUnit_Framework_TestCase
23 {
24     protected $frontend = NULL;
25     protected $controller = NULL;
26     protected $backend = NULL;        
27     
28     /**
29      * Sets up the fixture, for example
30      * This method is called before a test is executed.
31      *
32      * @access protected
33      */
34     protected function setUp()
35     {
36         // creates layer instances
37         $this->frontend = new Tinebase_Pluggable_DummyFrontend();
38         $this->controller = new Tinebase_Pluggable_DummyController();
39         $this->backend = new Tinebase_Pluggable_DummyBackend();
40         
41         // injects plugin into layers
42         Tinebase_Frontend_Abstract::attachPlugin('dummyPluginMethod', 'Tinebase_Pluggable_Plugin_DummyPlugin');
43         Tinebase_Controller_Abstract::attachPlugin('dummyPluginMethod', 'Tinebase_Pluggable_Plugin_DummyPlugin');
44         Tinebase_Backend_Abstract::attachPlugin('dummyPluginMethod', 'Tinebase_Pluggable_Plugin_DummyPlugin');
45     }
46     
47     /**
48      * Verifies if plugin is callable from layers
49      */
50     protected function testCallPluginMethod()
51     {
52         $expected = 'dummyPluginReturn';
53         
54         $frontendReturn = $this->frontend->dummyPluginMethod();
55         $controllerReturn = $this->controller->dummyPluginMethod();
56         $backendReturn = $this->backend->dummyPluginMethod();
57         
58         $this->assertEquals($expected, $frontendReturn);
59         $this->assertEquals($expected, $controllerReturn);
60         $this->assertEquals($expected, $backendReturn);        
61     }
62
63     /**
64      * Tears down the fixture
65      * This method is called after a test is executed.
66      *
67      * @access protected
68      */
69     protected function tearDown()
70     {
71     
72     }
73 }