1: <?php
2: /**
3: * A test helper replacing real factories.
4: *
5: * PHP version 5
6: *
7: * @category Horde
8: * @package Test
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL
11: * @link http://www.horde.org/components/Horde_Test
12: */
13:
14: /**
15: * A test helper replacing real factories.
16: *
17: * The Horde_Injector is often queried for factories that allow to generate more
18: * complex objects. The factories usually implement the create() method as
19: * primary variant for generating the instance. This test replacement is meant
20: * to be used as a prepared stub that can be provided to the injector and will
21: * return the instance required for testing.
22: *
23: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
24: *
25: * See the enclosed file COPYING for license information (LGPL). If you
26: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
27: *
28: * @since Horde_Test 1.2.0
29: *
30: * @category Horde
31: * @package Test
32: * @author Gunnar Wrobel <wrobel@pardus.de>
33: * @license http://www.horde.org/licenses/lgpl21 LGPL
34: * @link http://www.horde.org/components/Horde_Test
35: */
36: class Horde_Test_Stub_Factory
37: {
38: /**
39: * The instance to be returned.
40: *
41: * @var mixed
42: */
43: private $_instance;
44:
45: /**
46: * Constructor.
47: *
48: * @param mixed $instance The instance that the factory should return.
49: */
50: public function __construct($instance)
51: {
52: $this->_instance = $instance;
53: }
54:
55: /**
56: * Create an instance.
57: *
58: * @return mixed The predefined instance.
59: */
60: public function create()
61: {
62: return $this->_instance;
63: }
64: }