1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* MageSpec |
4
|
|
|
* |
5
|
|
|
* NOTICE OF LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the MIT License, that is bundled with this |
8
|
|
|
* package in the file LICENSE. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* |
11
|
|
|
* http://opensource.org/licenses/MIT |
12
|
|
|
* |
13
|
|
|
* If you did not receive a copy of the license and are unable to obtain it |
14
|
|
|
* through the world-wide-web, please send an email |
15
|
|
|
* to <[email protected]> so we can send you a copy immediately. |
16
|
|
|
* |
17
|
|
|
* @category MageTest |
18
|
|
|
* @package PhpSpec_MagentoExtension |
19
|
|
|
* |
20
|
|
|
* @copyright Copyright (c) 2012-2013 MageTest team and contributors. |
21
|
|
|
*/ |
22
|
|
|
namespace MageTest\PhpSpec\MagentoExtension\Locator\Magento; |
23
|
|
|
|
24
|
|
|
use PhpSpec\Locator\Resource as ResourceInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* ModelResource |
28
|
|
|
* |
29
|
|
|
* @category MageTest |
30
|
|
|
* @package PhpSpec_MagentoExtension |
31
|
|
|
* |
32
|
|
|
* @author MageTest team (https://github.com/MageTest/MageSpec/contributors) |
33
|
|
|
*/ |
34
|
|
|
class ControllerResource implements ResourceInterface |
35
|
|
|
{ |
36
|
|
|
private $parts; |
37
|
|
|
private $pathParts; |
38
|
|
|
private $locator; |
39
|
|
|
|
40
|
|
|
public function __construct(array $parts, ControllerLocator $locator) |
41
|
|
|
{ |
42
|
|
|
$this->parts = $parts; |
43
|
|
|
$this->pathParts = $parts; |
44
|
|
|
array_splice($this->pathParts, 2, 0, array('controllers')); |
45
|
|
|
$this->locator = $locator; |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function getName() |
49
|
|
|
{ |
50
|
|
|
return implode('_', $this->parts); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getSpecName() |
54
|
|
|
{ |
55
|
|
|
return $this->getName() . 'Spec'; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function getSrcFilename() |
59
|
|
|
{ |
60
|
|
|
return $this->locator->getFullSrcPath() . implode(DIRECTORY_SEPARATOR, $this->pathParts) . '.php'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function getSrcNamespace() |
64
|
|
|
{ |
65
|
|
|
return ''; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function getSrcClassname() |
69
|
|
|
{ |
70
|
|
|
return implode('_', $this->parts); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public function getSpecFilename() |
74
|
|
|
{ |
75
|
|
|
return $this->locator->getFullSpecPath() . implode(DIRECTORY_SEPARATOR, $this->pathParts) . 'Spec.php'; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
public function getSpecNamespace() |
79
|
|
|
{ |
80
|
|
|
return rtrim($this->locator->getSpecNamespace(), '/\\'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function getSpecClassname() |
84
|
|
|
{ |
85
|
|
|
return $this->locator->getSpecNamespace() . implode('_', $this->parts).'Spec'; |
86
|
|
|
} |
87
|
|
|
} |