@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | interface ViewInterface |
| 6 | 6 | { |
| 7 | - /** |
|
| 7 | +/** |
|
| 8 | 8 | * Add a namespace to the view renderer |
| 9 | 9 | * |
| 10 | 10 | * @param string $sNamespace The namespace name |
@@ -13,14 +13,14 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @return void |
| 15 | 15 | */ |
| 16 | - public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void; |
|
| 16 | +public function addNamespace(string $sNamespace, string $sDirectory, string $sExtension = ''): void; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 18 | +/** |
|
| 19 | 19 | * Render a view |
| 20 | 20 | * |
| 21 | 21 | * @param Store $store A store populated with the view data |
| 22 | 22 | * |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - public function render(Store $store): string; |
|
| 25 | +public function render(Store $store): string; |
|
| 26 | 26 | } |
@@ -23,33 +23,33 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | class EventAttr |
| 25 | 25 | { |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @var array |
| 28 | 28 | */ |
| 29 | - private array $aHandlers = []; |
|
| 29 | +private array $aHandlers = []; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * The constructor |
| 33 | 33 | * |
| 34 | 34 | * @param string $sSelector |
| 35 | 35 | */ |
| 36 | - public function __construct(private string $sSelector) |
|
| 37 | - {} |
|
| 36 | +public function __construct(private string $sSelector) |
|
| 37 | +{} |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * Set a selector for the next event handler |
| 41 | 41 | * |
| 42 | 42 | * @param string $sSelector |
| 43 | 43 | * |
| 44 | 44 | * @return self |
| 45 | 45 | */ |
| 46 | - public function select(string $sSelector): self |
|
| 47 | - { |
|
| 48 | - $this->sSelector = trim($sSelector); |
|
| 49 | - return $this; |
|
| 50 | - } |
|
| 46 | +public function select(string $sSelector): self |
|
| 47 | +{ |
|
| 48 | +$this->sSelector = trim($sSelector); |
|
| 49 | +return $this; |
|
| 50 | +} |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | +/** |
|
| 53 | 53 | * Set an event handler with the "on" keyword |
| 54 | 54 | * |
| 55 | 55 | * @param string $event |
@@ -57,43 +57,43 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return self |
| 59 | 59 | */ |
| 60 | - public function on(string $event, JsExpr $xJsExpr): self |
|
| 61 | - { |
|
| 62 | - if($this->sSelector === '') |
|
| 63 | - { |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 60 | +public function on(string $event, JsExpr $xJsExpr): self |
|
| 61 | +{ |
|
| 62 | +if($this->sSelector === '') |
|
| 63 | +{ |
|
| 64 | +return $this; |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - $this->aHandlers[] = [ |
|
| 68 | - 'select' => $this->sSelector, |
|
| 69 | - 'event' => trim($event), |
|
| 70 | - 'handler' => $xJsExpr, |
|
| 71 | - ]; |
|
| 72 | - $this->sSelector = ''; |
|
| 73 | - return $this; |
|
| 74 | - } |
|
| 67 | +$this->aHandlers[] = [ |
|
| 68 | +'select' => $this->sSelector, |
|
| 69 | +'event' => trim($event), |
|
| 70 | +'handler' => $xJsExpr, |
|
| 71 | +]; |
|
| 72 | +$this->sSelector = ''; |
|
| 73 | +return $this; |
|
| 74 | +} |
|
| 75 | 75 | |
| 76 | - /** |
|
| 76 | +/** |
|
| 77 | 77 | * Shortcut to set a click event handler |
| 78 | 78 | * |
| 79 | 79 | * @param JsExpr $xJsExpr |
| 80 | 80 | * |
| 81 | 81 | * @return self |
| 82 | 82 | */ |
| 83 | - public function click(JsExpr $xJsExpr): self |
|
| 84 | - { |
|
| 85 | - return $this->on('click', $xJsExpr); |
|
| 86 | - } |
|
| 83 | +public function click(JsExpr $xJsExpr): self |
|
| 84 | +{ |
|
| 85 | +return $this->on('click', $xJsExpr); |
|
| 86 | +} |
|
| 87 | 87 | |
| 88 | - /** |
|
| 88 | +/** |
|
| 89 | 89 | * Convert to string. |
| 90 | 90 | * |
| 91 | 91 | * @return string |
| 92 | 92 | */ |
| 93 | - public function __toString(): string |
|
| 94 | - { |
|
| 95 | - // No output if no handler is defined. |
|
| 96 | - return count($this->aHandlers) === 0 ? '' : 'jxn-event="' . |
|
| 97 | - htmlentities(json_encode($this->aHandlers)) . '"'; |
|
| 98 | - } |
|
| 93 | +public function __toString(): string |
|
| 94 | +{ |
|
| 95 | +// No output if no handler is defined. |
|
| 96 | +return count($this->aHandlers) === 0 ? '' : 'jxn-event="' . |
|
| 97 | +htmlentities(json_encode($this->aHandlers)) . '"'; |
|
| 98 | +} |
|
| 99 | 99 | } |
@@ -31,40 +31,40 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | class HtmlAttrHelper |
| 33 | 33 | { |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @var string|null |
| 36 | 36 | */ |
| 37 | - private string|null $sPaginationComponent = null; |
|
| 37 | +private string|null $sPaginationComponent = null; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 39 | +/** |
|
| 40 | 40 | * The constructor |
| 41 | 41 | * |
| 42 | 42 | * @param ComponentContainer $cdi |
| 43 | 43 | */ |
| 44 | - public function __construct(protected ComponentContainer $cdi) |
|
| 45 | - {} |
|
| 44 | +public function __construct(protected ComponentContainer $cdi) |
|
| 45 | +{} |
|
| 46 | 46 | |
| 47 | - /** |
|
| 47 | +/** |
|
| 48 | 48 | * Get the component HTML code |
| 49 | 49 | * |
| 50 | 50 | * @param JxnCall $xJsCall |
| 51 | 51 | * |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | - public function html(JxnCall $xJsCall): string |
|
| 55 | - { |
|
| 56 | - $sClassName = $xJsCall->_class(); |
|
| 57 | - if(!$sClassName) |
|
| 58 | - { |
|
| 59 | - return ''; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - $xComponent = $this->cdi->makeComponent($sClassName); |
|
| 63 | - return is_a($xComponent, NodeComponent::class) ? |
|
| 64 | - (string)$xComponent->html() : ''; |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 54 | +public function html(JxnCall $xJsCall): string |
|
| 55 | +{ |
|
| 56 | +$sClassName = $xJsCall->_class(); |
|
| 57 | +if(!$sClassName) |
|
| 58 | +{ |
|
| 59 | +return ''; |
|
| 60 | +} |
|
| 61 | + |
|
| 62 | +$xComponent = $this->cdi->makeComponent($sClassName); |
|
| 63 | +return is_a($xComponent, NodeComponent::class) ? |
|
| 64 | +(string)$xComponent->html() : ''; |
|
| 65 | +} |
|
| 66 | + |
|
| 67 | +/** |
|
| 68 | 68 | * Attach a component to a DOM node |
| 69 | 69 | * |
| 70 | 70 | * @param JxnCall $xJsCall |
@@ -72,41 +72,41 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return string |
| 74 | 74 | */ |
| 75 | - public function bind(JxnCall $xJsCall, string $item = ''): string |
|
| 76 | - { |
|
| 77 | - $item = trim($item); |
|
| 78 | - return 'jxn-bind="' . $xJsCall->_class() . (!$item ? '"' : '" jxn-item="' . $item . '"'); |
|
| 79 | - } |
|
| 75 | +public function bind(JxnCall $xJsCall, string $item = ''): string |
|
| 76 | +{ |
|
| 77 | +$item = trim($item); |
|
| 78 | +return 'jxn-bind="' . $xJsCall->_class() . (!$item ? '"' : '" jxn-item="' . $item . '"'); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - /** |
|
| 81 | +/** |
|
| 82 | 82 | * Attach the pagination component to a DOM node |
| 83 | 83 | * |
| 84 | 84 | * @param JxnCall $xJsCall |
| 85 | 85 | * |
| 86 | 86 | * @return string |
| 87 | 87 | */ |
| 88 | - public function pagination(JxnCall $xJsCall): string |
|
| 89 | - { |
|
| 90 | - // The pagination is always rendered with the same Pagination component. |
|
| 91 | - $sComponent = $this->sPaginationComponent ?: |
|
| 92 | - ($this->sPaginationComponent = rq(Pagination::class)->_class()); |
|
| 93 | - $sItem = $xJsCall->_class(); |
|
| 94 | - return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\""; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 88 | +public function pagination(JxnCall $xJsCall): string |
|
| 89 | +{ |
|
| 90 | +// The pagination is always rendered with the same Pagination component. |
|
| 91 | +$sComponent = $this->sPaginationComponent ?: |
|
| 92 | +($this->sPaginationComponent = rq(Pagination::class)->_class()); |
|
| 93 | +$sItem = $xJsCall->_class(); |
|
| 94 | +return "jxn-bind=\"$sComponent\" jxn-item=\"$sItem\""; |
|
| 95 | +} |
|
| 96 | + |
|
| 97 | +/** |
|
| 98 | 98 | * Set a selector for the next event handler |
| 99 | 99 | * |
| 100 | 100 | * @param string $sSelector |
| 101 | 101 | * |
| 102 | 102 | * @return EventAttr |
| 103 | 103 | */ |
| 104 | - public function select(string $sSelector): EventAttr |
|
| 105 | - { |
|
| 106 | - return new EventAttr($sSelector); |
|
| 107 | - } |
|
| 104 | +public function select(string $sSelector): EventAttr |
|
| 105 | +{ |
|
| 106 | +return new EventAttr($sSelector); |
|
| 107 | +} |
|
| 108 | 108 | |
| 109 | - /** |
|
| 109 | +/** |
|
| 110 | 110 | * Set an event handler |
| 111 | 111 | * |
| 112 | 112 | * @param string $event |
@@ -114,83 +114,83 @@ discard block |
||
| 114 | 114 | * |
| 115 | 115 | * @return string |
| 116 | 116 | */ |
| 117 | - public function on(string $event, JsExpr $xJsExpr): string |
|
| 118 | - { |
|
| 119 | - $event = trim($event); |
|
| 120 | - $sCall = htmlentities(json_encode($xJsExpr->jsonSerialize())); |
|
| 121 | - return "jxn-on=\"$event\" jxn-call=\"$sCall\""; |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - /** |
|
| 117 | +public function on(string $event, JsExpr $xJsExpr): string |
|
| 118 | +{ |
|
| 119 | +$event = trim($event); |
|
| 120 | +$sCall = htmlentities(json_encode($xJsExpr->jsonSerialize())); |
|
| 121 | +return "jxn-on=\"$event\" jxn-call=\"$sCall\""; |
|
| 122 | +} |
|
| 123 | + |
|
| 124 | +/** |
|
| 125 | 125 | * Shortcut to set a click event handler |
| 126 | 126 | * |
| 127 | 127 | * @param JsExpr $xJsExpr |
| 128 | 128 | * |
| 129 | 129 | * @return string |
| 130 | 130 | */ |
| 131 | - public function click(JsExpr $xJsExpr): string |
|
| 132 | - { |
|
| 133 | - return $this->on('click', $xJsExpr); |
|
| 134 | - } |
|
| 131 | +public function click(JsExpr $xJsExpr): string |
|
| 132 | +{ |
|
| 133 | +return $this->on('click', $xJsExpr); |
|
| 134 | +} |
|
| 135 | 135 | |
| 136 | - /** |
|
| 136 | +/** |
|
| 137 | 137 | * @param array $aHandler |
| 138 | 138 | * |
| 139 | 139 | * @return bool |
| 140 | 140 | */ |
| 141 | - private function eventIsValid(array $aHandler): bool |
|
| 142 | - { |
|
| 143 | - return count($aHandler) === 3 && |
|
| 144 | - isset($aHandler[0]) && isset($aHandler[1]) && isset($aHandler[2]) && |
|
| 145 | - is_string($aHandler[0]) && is_string($aHandler[1]) && |
|
| 146 | - is_a($aHandler[2], JsExpr::class); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 141 | +private function eventIsValid(array $aHandler): bool |
|
| 142 | +{ |
|
| 143 | +return count($aHandler) === 3 && |
|
| 144 | +isset($aHandler[0]) && isset($aHandler[1]) && isset($aHandler[2]) && |
|
| 145 | +is_string($aHandler[0]) && is_string($aHandler[1]) && |
|
| 146 | +is_a($aHandler[2], JsExpr::class); |
|
| 147 | +} |
|
| 148 | + |
|
| 149 | +/** |
|
| 150 | 150 | * @param array $aHandler |
| 151 | 151 | * @param EventAttr|null $xAttr |
| 152 | 152 | * |
| 153 | 153 | * @return EventAttr|null |
| 154 | 154 | */ |
| 155 | - private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null |
|
| 156 | - { |
|
| 157 | - if(!$this->eventIsValid($aHandler)) |
|
| 158 | - { |
|
| 159 | - return $xAttr; |
|
| 160 | - } |
|
| 161 | - // The array content is valid. |
|
| 162 | - [$sSelector, $sEvent, $xJsExpr] = $aHandler; |
|
| 163 | - return !$xAttr ? |
|
| 164 | - $this->select($sSelector)->on($sEvent, $xJsExpr) : |
|
| 165 | - $xAttr->select($sSelector)->on($sEvent, $xJsExpr); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 155 | +private function setEventHandler(array $aHandler, ?EventAttr $xAttr = null): EventAttr|null |
|
| 156 | +{ |
|
| 157 | +if(!$this->eventIsValid($aHandler)) |
|
| 158 | +{ |
|
| 159 | +return $xAttr; |
|
| 160 | +} |
|
| 161 | +// The array content is valid. |
|
| 162 | +[$sSelector, $sEvent, $xJsExpr] = $aHandler; |
|
| 163 | +return !$xAttr ? |
|
| 164 | +$this->select($sSelector)->on($sEvent, $xJsExpr) : |
|
| 165 | +$xAttr->select($sSelector)->on($sEvent, $xJsExpr); |
|
| 166 | +} |
|
| 167 | + |
|
| 168 | +/** |
|
| 169 | 169 | * Set an event handler |
| 170 | 170 | * |
| 171 | 171 | * @param array $aHandler |
| 172 | 172 | * |
| 173 | 173 | * @return string |
| 174 | 174 | */ |
| 175 | - public function event(array $aHandler): string |
|
| 176 | - { |
|
| 177 | - return $this->setEventHandler($aHandler)?->__toString() ?? ''; |
|
| 178 | - } |
|
| 175 | +public function event(array $aHandler): string |
|
| 176 | +{ |
|
| 177 | +return $this->setEventHandler($aHandler)?->__toString() ?? ''; |
|
| 178 | +} |
|
| 179 | 179 | |
| 180 | - /** |
|
| 180 | +/** |
|
| 181 | 181 | * Set event handlers |
| 182 | 182 | * |
| 183 | 183 | * @param array $aHandlers |
| 184 | 184 | * |
| 185 | 185 | * @return string |
| 186 | 186 | */ |
| 187 | - public function events(array $aHandlers): string |
|
| 188 | - { |
|
| 189 | - return array_reduce($aHandlers, fn(EventAttr|null $xAttr, array $aHandler) |
|
| 190 | - => $this->setEventHandler($aHandler, $xAttr), null)?->__toString() ?? ''; |
|
| 191 | - } |
|
| 187 | +public function events(array $aHandlers): string |
|
| 188 | +{ |
|
| 189 | +return array_reduce($aHandlers, fn(EventAttr|null $xAttr, array $aHandler) |
|
| 190 | +=> $this->setEventHandler($aHandler, $xAttr), null)?->__toString() ?? ''; |
|
| 191 | +} |
|
| 192 | 192 | |
| 193 | - /** |
|
| 193 | +/** |
|
| 194 | 194 | * Get the HTML or Javascript ready code for a package |
| 195 | 195 | * |
| 196 | 196 | * @param string $sClass |
@@ -198,17 +198,17 @@ discard block |
||
| 198 | 198 | * |
| 199 | 199 | * @return string |
| 200 | 200 | */ |
| 201 | - public function package(string $sClass, string $sType = 'html'): string |
|
| 202 | - { |
|
| 203 | - $sCode = match($sType) { |
|
| 204 | - 'html' => jaxon()->package($sClass)?->getHtml() ?? '', |
|
| 205 | - 'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '', |
|
| 206 | - default => '' |
|
| 207 | - }; |
|
| 208 | - $sCode = trim($sCode); |
|
| 209 | - |
|
| 210 | - return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | - // Call the ready code with the jaxon.dom.ready function. |
|
| 212 | - "jaxon.dom.ready(() => $sCode)"; |
|
| 213 | - } |
|
| 201 | +public function package(string $sClass, string $sType = 'html'): string |
|
| 202 | +{ |
|
| 203 | +$sCode = match($sType) { |
|
| 204 | +'html' => jaxon()->package($sClass)?->getHtml() ?? '', |
|
| 205 | +'ready' => jaxon()->package($sClass)?->getReadyScript() ?? '', |
|
| 206 | +default => '' |
|
| 207 | +}; |
|
| 208 | +$sCode = trim($sCode); |
|
| 209 | + |
|
| 210 | +return $sType !== 'ready' || $sCode === '' ? $sCode : |
|
| 211 | +// Call the ready code with the jaxon.dom.ready function. |
|
| 212 | +"jaxon.dom.ready(() => $sCode)"; |
|
| 213 | +} |
|
| 214 | 214 | } |
@@ -26,41 +26,41 @@ |
||
| 26 | 26 | */ |
| 27 | 27 | class ExportAnnotation extends AbstractAnnotation |
| 28 | 28 | { |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @var array |
| 31 | 31 | */ |
| 32 | - private $aMethods = []; |
|
| 32 | +private $aMethods = []; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * @inheritDoc |
| 36 | 36 | */ |
| 37 | - public static function parseAnnotation($value) |
|
| 38 | - { |
|
| 39 | - $aParams = json_decode($value, true); |
|
| 40 | - return is_array($aParams) ? $aParams : []; |
|
| 41 | - } |
|
| 37 | +public static function parseAnnotation($value) |
|
| 38 | +{ |
|
| 39 | +$aParams = json_decode($value, true); |
|
| 40 | +return is_array($aParams) ? $aParams : []; |
|
| 41 | +} |
|
| 42 | 42 | |
| 43 | - /** |
|
| 43 | +/** |
|
| 44 | 44 | * @inheritDoc |
| 45 | 45 | * @throws AnnotationException |
| 46 | 46 | */ |
| 47 | - public function initAnnotation(array $properties) |
|
| 48 | - { |
|
| 49 | - foreach(['base', 'only', 'except'] as $key) |
|
| 50 | - { |
|
| 51 | - if(isset($properties[$key]) && is_array($properties[$key]) && |
|
| 52 | - count($properties[$key]) > 0) |
|
| 53 | - { |
|
| 54 | - $this->aMethods[$key] = $properties[$key]; |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - } |
|
| 47 | +public function initAnnotation(array $properties) |
|
| 48 | +{ |
|
| 49 | +foreach(['base', 'only', 'except'] as $key) |
|
| 50 | +{ |
|
| 51 | +if(isset($properties[$key]) && is_array($properties[$key]) && |
|
| 52 | + count($properties[$key]) > 0) |
|
| 53 | +{ |
|
| 54 | + $this->aMethods[$key] = $properties[$key]; |
|
| 55 | +} |
|
| 56 | +} |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * @inheritDoc |
| 61 | 61 | */ |
| 62 | - public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 63 | - { |
|
| 64 | - $xMetadata->export($sMethod)->setMethods($this->aMethods); |
|
| 65 | - } |
|
| 62 | +public function saveValue(Metadata $xMetadata, string $sMethod = '*'): void |
|
| 63 | +{ |
|
| 64 | +$xMetadata->export($sMethod)->setMethods($this->aMethods); |
|
| 65 | +} |
|
| 66 | 66 | } |
@@ -22,53 +22,53 @@ |
||
| 22 | 22 | |
| 23 | 23 | class ExportData extends AbstractData |
| 24 | 24 | { |
| 25 | - /** |
|
| 25 | +/** |
|
| 26 | 26 | * @var array<string, array<string>> |
| 27 | 27 | */ |
| 28 | - private array $aMethods = []; |
|
| 28 | +private array $aMethods = []; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * @return string |
| 32 | 32 | */ |
| 33 | - public function getName(): string |
|
| 34 | - { |
|
| 35 | - return 'export'; |
|
| 36 | - } |
|
| 33 | +public function getName(): string |
|
| 34 | +{ |
|
| 35 | +return 'export'; |
|
| 36 | +} |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @return mixed |
| 40 | 40 | */ |
| 41 | - public function getValue(): mixed |
|
| 42 | - { |
|
| 43 | - return $this->aMethods; |
|
| 44 | - } |
|
| 41 | +public function getValue(): mixed |
|
| 42 | +{ |
|
| 43 | +return $this->aMethods; |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * @param array $aMethods |
| 48 | 48 | * |
| 49 | 49 | * @return void |
| 50 | 50 | */ |
| 51 | - public function setMethods(array $aMethods): void |
|
| 51 | +public function setMethods(array $aMethods): void |
|
| 52 | +{ |
|
| 53 | +foreach(['base', 'only', 'except'] as $sKey) |
|
| 54 | +{ |
|
| 55 | +foreach($aMethods[$sKey] ?? [] as $sMethod) |
|
| 56 | +{ |
|
| 57 | + if(!is_string($sMethod) || !$this->validateMethod($sMethod)) |
|
| 52 | 58 | { |
| 53 | - foreach(['base', 'only', 'except'] as $sKey) |
|
| 54 | - { |
|
| 55 | - foreach($aMethods[$sKey] ?? [] as $sMethod) |
|
| 56 | - { |
|
| 57 | - if(!is_string($sMethod) || !$this->validateMethod($sMethod)) |
|
| 58 | - { |
|
| 59 | - throw new SetupException("'$sMethod' is not a valid method name."); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - $this->aMethods = $aMethods; |
|
| 59 | + throw new SetupException("'$sMethod' is not a valid method name."); |
|
| 64 | 60 | } |
| 61 | +} |
|
| 62 | +} |
|
| 63 | +$this->aMethods = $aMethods; |
|
| 64 | +} |
|
| 65 | 65 | |
| 66 | - /** |
|
| 66 | +/** |
|
| 67 | 67 | * @inheritDoc |
| 68 | 68 | */ |
| 69 | - public function encode(string $sVarName): array |
|
| 70 | - { |
|
| 71 | - $sMethods = addslashes(json_encode($this->aMethods)); |
|
| 72 | - return ["{$sVarName}->setMethods(json_decode(\"$sMethods\", true));"]; |
|
| 73 | - } |
|
| 69 | +public function encode(string $sVarName): array |
|
| 70 | +{ |
|
| 71 | +$sMethods = addslashes(json_encode($this->aMethods)); |
|
| 72 | +return ["{$sVarName}->setMethods(json_decode(\"$sMethods\", true));"]; |
|
| 73 | +} |
|
| 74 | 74 | } |
@@ -12,89 +12,89 @@ |
||
| 12 | 12 | |
| 13 | 13 | class TraitAnnotationTest extends TestCase |
| 14 | 14 | { |
| 15 | - use AnnotationTrait; |
|
| 15 | +use AnnotationTrait; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * @var string |
| 19 | 19 | */ |
| 20 | - protected $sCacheDir; |
|
| 20 | +protected $sCacheDir; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @throws SetupException |
| 24 | 24 | */ |
| 25 | - public function setUp(): void |
|
| 26 | - { |
|
| 27 | - $this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 28 | - @mkdir($this->sCacheDir); |
|
| 25 | +public function setUp(): void |
|
| 26 | +{ |
|
| 27 | +$this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 28 | +@mkdir($this->sCacheDir); |
|
| 29 | 29 | |
| 30 | - jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 31 | - _register(); |
|
| 30 | +jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 31 | +_register(); |
|
| 32 | 32 | |
| 33 | - jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 34 | - } |
|
| 33 | +jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * @throws SetupException |
| 38 | 38 | */ |
| 39 | - public function tearDown(): void |
|
| 40 | - { |
|
| 41 | - jaxon()->reset(); |
|
| 42 | - parent::tearDown(); |
|
| 43 | - |
|
| 44 | - // Delete the temp dir and all its content |
|
| 45 | - $aFiles = scandir($this->sCacheDir); |
|
| 46 | - foreach ($aFiles as $sFile) |
|
| 47 | - { |
|
| 48 | - if($sFile !== '.' && $sFile !== '..') |
|
| 49 | - { |
|
| 50 | - @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - @rmdir($this->sCacheDir); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 39 | +public function tearDown(): void |
|
| 40 | +{ |
|
| 41 | +jaxon()->reset(); |
|
| 42 | +parent::tearDown(); |
|
| 43 | + |
|
| 44 | +// Delete the temp dir and all its content |
|
| 45 | +$aFiles = scandir($this->sCacheDir); |
|
| 46 | +foreach ($aFiles as $sFile) |
|
| 47 | +{ |
|
| 48 | +if($sFile !== '.' && $sFile !== '..') |
|
| 49 | +{ |
|
| 50 | + @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 51 | +} |
|
| 52 | +} |
|
| 53 | +@rmdir($this->sCacheDir); |
|
| 54 | +} |
|
| 55 | + |
|
| 56 | +/** |
|
| 57 | 57 | * @throws SetupException |
| 58 | 58 | */ |
| 59 | - public function testTraitAnnotation() |
|
| 60 | - { |
|
| 61 | - $xMetadata = $this->getAttributes(TraitAnnotated::class, []); |
|
| 62 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 63 | - $aProperties = $xMetadata->getProperties(); |
|
| 64 | - |
|
| 65 | - $this->assertFalse($bExcluded); |
|
| 66 | - |
|
| 67 | - $this->assertCount(1, $aProperties); |
|
| 68 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 69 | - $this->assertCount(4, $aProperties['*']); |
|
| 70 | - $this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 71 | - $this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 72 | - $this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 73 | - |
|
| 74 | - $this->assertCount(2, $aProperties['*']['bags']); |
|
| 75 | - $this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 76 | - $this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 77 | - |
|
| 78 | - $this->assertCount(2, $aProperties['*']['__before']); |
|
| 79 | - $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 80 | - $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 81 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 82 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 83 | - |
|
| 84 | - $this->assertCount(3, $aProperties['*']['__after']); |
|
| 85 | - $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 86 | - $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 87 | - $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 88 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 89 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 90 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 91 | - |
|
| 92 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 93 | - $this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 94 | - $this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 95 | - $this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 96 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 97 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 98 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 99 | - } |
|
| 59 | +public function testTraitAnnotation() |
|
| 60 | +{ |
|
| 61 | +$xMetadata = $this->getAttributes(TraitAnnotated::class, []); |
|
| 62 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 63 | +$aProperties = $xMetadata->getProperties(); |
|
| 64 | + |
|
| 65 | +$this->assertFalse($bExcluded); |
|
| 66 | + |
|
| 67 | +$this->assertCount(1, $aProperties); |
|
| 68 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 69 | +$this->assertCount(4, $aProperties['*']); |
|
| 70 | +$this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 71 | +$this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 72 | +$this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 73 | + |
|
| 74 | +$this->assertCount(2, $aProperties['*']['bags']); |
|
| 75 | +$this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 76 | +$this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 77 | + |
|
| 78 | +$this->assertCount(2, $aProperties['*']['__before']); |
|
| 79 | +$this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 80 | +$this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 81 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 82 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 83 | + |
|
| 84 | +$this->assertCount(3, $aProperties['*']['__after']); |
|
| 85 | +$this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 86 | +$this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 87 | +$this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 88 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 89 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 90 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 91 | + |
|
| 92 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 93 | +$this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 94 | +$this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 95 | +$this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 96 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 97 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 98 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 99 | +} |
|
| 100 | 100 | } |
@@ -14,346 +14,346 @@ |
||
| 14 | 14 | |
| 15 | 15 | class ExtendAnnotationTest extends TestCase |
| 16 | 16 | { |
| 17 | - use AnnotationTrait; |
|
| 17 | +use AnnotationTrait; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 19 | +/** |
|
| 20 | 20 | * @var string |
| 21 | 21 | */ |
| 22 | - protected $sCacheDir; |
|
| 22 | +protected $sCacheDir; |
|
| 23 | 23 | |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @throws SetupException |
| 26 | 26 | */ |
| 27 | - public function setUp(): void |
|
| 28 | - { |
|
| 29 | - $this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 30 | - @mkdir($this->sCacheDir); |
|
| 27 | +public function setUp(): void |
|
| 28 | +{ |
|
| 29 | +$this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 30 | +@mkdir($this->sCacheDir); |
|
| 31 | 31 | |
| 32 | - jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 33 | - _register(); |
|
| 32 | +jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 33 | +_register(); |
|
| 34 | 34 | |
| 35 | - jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 36 | - } |
|
| 35 | +jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 36 | +} |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * @throws SetupException |
| 40 | 40 | */ |
| 41 | - public function tearDown(): void |
|
| 42 | - { |
|
| 43 | - jaxon()->reset(); |
|
| 44 | - parent::tearDown(); |
|
| 45 | - |
|
| 46 | - // Delete the temp dir and all its content |
|
| 47 | - $aFiles = scandir($this->sCacheDir); |
|
| 48 | - foreach ($aFiles as $sFile) |
|
| 49 | - { |
|
| 50 | - if($sFile !== '.' && $sFile !== '..') |
|
| 51 | - { |
|
| 52 | - @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - @rmdir($this->sCacheDir); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - /** |
|
| 41 | +public function tearDown(): void |
|
| 42 | +{ |
|
| 43 | +jaxon()->reset(); |
|
| 44 | +parent::tearDown(); |
|
| 45 | + |
|
| 46 | +// Delete the temp dir and all its content |
|
| 47 | +$aFiles = scandir($this->sCacheDir); |
|
| 48 | +foreach ($aFiles as $sFile) |
|
| 49 | +{ |
|
| 50 | +if($sFile !== '.' && $sFile !== '..') |
|
| 51 | +{ |
|
| 52 | + @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 53 | +} |
|
| 54 | +} |
|
| 55 | +@rmdir($this->sCacheDir); |
|
| 56 | +} |
|
| 57 | + |
|
| 58 | +/** |
|
| 59 | 59 | * @throws SetupException |
| 60 | 60 | */ |
| 61 | - public function testUploadAndExcludeAnnotation() |
|
| 62 | - { |
|
| 63 | - $xMetadata = $this->getAttributes(ExtendAnnotated::class, ['saveFiles', 'doNot']); |
|
| 64 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 65 | - $aProperties = $xMetadata->getProperties(); |
|
| 66 | - $aExcluded = $xMetadata->getExceptMethods(); |
|
| 61 | +public function testUploadAndExcludeAnnotation() |
|
| 62 | +{ |
|
| 63 | +$xMetadata = $this->getAttributes(ExtendAnnotated::class, ['saveFiles', 'doNot']); |
|
| 64 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 65 | +$aProperties = $xMetadata->getProperties(); |
|
| 66 | +$aExcluded = $xMetadata->getExceptMethods(); |
|
| 67 | 67 | |
| 68 | - $this->assertFalse($bExcluded); |
|
| 68 | +$this->assertFalse($bExcluded); |
|
| 69 | 69 | |
| 70 | - $this->assertCount(1, $aProperties); |
|
| 71 | - $this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 72 | - $this->assertCount(1, $aProperties['saveFiles']); |
|
| 73 | - $this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 70 | +$this->assertCount(1, $aProperties); |
|
| 71 | +$this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 72 | +$this->assertCount(1, $aProperties['saveFiles']); |
|
| 73 | +$this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 74 | 74 | |
| 75 | - $this->assertCount(1, $aExcluded); |
|
| 76 | - $this->assertEquals('doNot', $aExcluded[0]); |
|
| 77 | - } |
|
| 75 | +$this->assertCount(1, $aExcluded); |
|
| 76 | +$this->assertEquals('doNot', $aExcluded[0]); |
|
| 77 | +} |
|
| 78 | 78 | |
| 79 | - /** |
|
| 79 | +/** |
|
| 80 | 80 | * @throws SetupException |
| 81 | 81 | */ |
| 82 | - public function testDatabagAnnotation() |
|
| 83 | - { |
|
| 84 | - $xMetadata = $this->getAttributes(ExtendAnnotated::class, ['withBags']); |
|
| 85 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 86 | - $aProperties = $xMetadata->getProperties(); |
|
| 87 | - |
|
| 88 | - $this->assertFalse($bExcluded); |
|
| 89 | - |
|
| 90 | - $this->assertCount(1, $aProperties); |
|
| 91 | - $this->assertArrayHasKey('withBags', $aProperties); |
|
| 92 | - $this->assertCount(1, $aProperties['withBags']); |
|
| 93 | - $this->assertCount(2, $aProperties['withBags']['bags']); |
|
| 94 | - $this->assertEquals('user.name', $aProperties['withBags']['bags'][0]); |
|
| 95 | - $this->assertEquals('page.number', $aProperties['withBags']['bags'][1]); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 82 | +public function testDatabagAnnotation() |
|
| 83 | +{ |
|
| 84 | +$xMetadata = $this->getAttributes(ExtendAnnotated::class, ['withBags']); |
|
| 85 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 86 | +$aProperties = $xMetadata->getProperties(); |
|
| 87 | + |
|
| 88 | +$this->assertFalse($bExcluded); |
|
| 89 | + |
|
| 90 | +$this->assertCount(1, $aProperties); |
|
| 91 | +$this->assertArrayHasKey('withBags', $aProperties); |
|
| 92 | +$this->assertCount(1, $aProperties['withBags']); |
|
| 93 | +$this->assertCount(2, $aProperties['withBags']['bags']); |
|
| 94 | +$this->assertEquals('user.name', $aProperties['withBags']['bags'][0]); |
|
| 95 | +$this->assertEquals('page.number', $aProperties['withBags']['bags'][1]); |
|
| 96 | +} |
|
| 97 | + |
|
| 98 | +/** |
|
| 99 | 99 | * @throws SetupException |
| 100 | 100 | */ |
| 101 | - public function testServerCallbacksAnnotation() |
|
| 102 | - { |
|
| 103 | - $xMetadata = $this->getAttributes(ExtendAnnotated::class, |
|
| 104 | - ['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 105 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 106 | - $aProperties = $xMetadata->getProperties(); |
|
| 107 | - |
|
| 108 | - $this->assertFalse($bExcluded); |
|
| 109 | - |
|
| 110 | - $this->assertCount(3, $aProperties); |
|
| 111 | - $this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 112 | - $this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 113 | - $this->assertArrayHasKey('cbParams', $aProperties); |
|
| 114 | - |
|
| 115 | - $this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 116 | - $this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 117 | - $this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 118 | - $this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 119 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 120 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 121 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 122 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 123 | - $this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 124 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 125 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 126 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 127 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 128 | - |
|
| 129 | - $this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 130 | - $this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 131 | - $this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 132 | - $this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 133 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 134 | - $this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 135 | - $this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 136 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 137 | - $this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 138 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 139 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 140 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 141 | - $this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - /** |
|
| 101 | +public function testServerCallbacksAnnotation() |
|
| 102 | +{ |
|
| 103 | +$xMetadata = $this->getAttributes(ExtendAnnotated::class, |
|
| 104 | +['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 105 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 106 | +$aProperties = $xMetadata->getProperties(); |
|
| 107 | + |
|
| 108 | +$this->assertFalse($bExcluded); |
|
| 109 | + |
|
| 110 | +$this->assertCount(3, $aProperties); |
|
| 111 | +$this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 112 | +$this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 113 | +$this->assertArrayHasKey('cbParams', $aProperties); |
|
| 114 | + |
|
| 115 | +$this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 116 | +$this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 117 | +$this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 118 | +$this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 119 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 120 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 121 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 122 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 123 | +$this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 124 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 125 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 126 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 127 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 128 | + |
|
| 129 | +$this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 130 | +$this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 131 | +$this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 132 | +$this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 133 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 134 | +$this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 135 | +$this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 136 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 137 | +$this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 138 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 139 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 140 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 141 | +$this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 142 | +} |
|
| 143 | + |
|
| 144 | +/** |
|
| 145 | 145 | * @throws SetupException |
| 146 | 146 | */ |
| 147 | - public function testContainerAnnotation() |
|
| 148 | - { |
|
| 149 | - $xMetadata = $this->getAttributes(ExtendAnnotated::class, ['di1', 'di2']); |
|
| 150 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 151 | - $aProperties = $xMetadata->getProperties(); |
|
| 152 | - |
|
| 153 | - $this->assertFalse($bExcluded); |
|
| 154 | - |
|
| 155 | - $this->assertCount(2, $aProperties); |
|
| 156 | - $this->assertArrayHasKey('di1', $aProperties); |
|
| 157 | - $this->assertArrayHasKey('di2', $aProperties); |
|
| 158 | - $this->assertCount(2, $aProperties['di1']['__di']); |
|
| 159 | - $this->assertCount(2, $aProperties['di2']['__di']); |
|
| 160 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 161 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 162 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 163 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /** |
|
| 147 | +public function testContainerAnnotation() |
|
| 148 | +{ |
|
| 149 | +$xMetadata = $this->getAttributes(ExtendAnnotated::class, ['di1', 'di2']); |
|
| 150 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 151 | +$aProperties = $xMetadata->getProperties(); |
|
| 152 | + |
|
| 153 | +$this->assertFalse($bExcluded); |
|
| 154 | + |
|
| 155 | +$this->assertCount(2, $aProperties); |
|
| 156 | +$this->assertArrayHasKey('di1', $aProperties); |
|
| 157 | +$this->assertArrayHasKey('di2', $aProperties); |
|
| 158 | +$this->assertCount(2, $aProperties['di1']['__di']); |
|
| 159 | +$this->assertCount(2, $aProperties['di2']['__di']); |
|
| 160 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 161 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 162 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 163 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 164 | +} |
|
| 165 | + |
|
| 166 | +/** |
|
| 167 | 167 | * @throws SetupException |
| 168 | 168 | */ |
| 169 | - public function testClassAnnotation() |
|
| 170 | - { |
|
| 171 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 172 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 173 | - $aProperties = $xMetadata->getProperties(); |
|
| 174 | - |
|
| 175 | - $this->assertFalse($bExcluded); |
|
| 176 | - |
|
| 177 | - $this->assertCount(1, $aProperties); |
|
| 178 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 179 | - $this->assertCount(5, $aProperties['*']); |
|
| 180 | - $this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 181 | - $this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 182 | - $this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 183 | - $this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 169 | +public function testClassAnnotation() |
|
| 170 | +{ |
|
| 171 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 172 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 173 | +$aProperties = $xMetadata->getProperties(); |
|
| 174 | + |
|
| 175 | +$this->assertFalse($bExcluded); |
|
| 176 | + |
|
| 177 | +$this->assertCount(1, $aProperties); |
|
| 178 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 179 | +$this->assertCount(5, $aProperties['*']); |
|
| 180 | +$this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 181 | +$this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 182 | +$this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 183 | +$this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 184 | +} |
|
| 185 | + |
|
| 186 | +/** |
|
| 187 | 187 | * @throws SetupException |
| 188 | 188 | */ |
| 189 | - public function testClassBagsAnnotation() |
|
| 190 | - { |
|
| 191 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 192 | - $aProperties = $xMetadata->getProperties(); |
|
| 189 | +public function testClassBagsAnnotation() |
|
| 190 | +{ |
|
| 191 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 192 | +$aProperties = $xMetadata->getProperties(); |
|
| 193 | 193 | |
| 194 | - $this->assertCount(2, $aProperties['*']['bags']); |
|
| 195 | - $this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 196 | - $this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 197 | - } |
|
| 194 | +$this->assertCount(2, $aProperties['*']['bags']); |
|
| 195 | +$this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 196 | +$this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 197 | +} |
|
| 198 | 198 | |
| 199 | - /** |
|
| 199 | +/** |
|
| 200 | 200 | * @throws SetupException |
| 201 | 201 | */ |
| 202 | - public function testClassCallbackAnnotation() |
|
| 203 | - { |
|
| 204 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 205 | - $aProperties = $xMetadata->getProperties(); |
|
| 202 | +public function testClassCallbackAnnotation() |
|
| 203 | +{ |
|
| 204 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 205 | +$aProperties = $xMetadata->getProperties(); |
|
| 206 | 206 | |
| 207 | - $this->assertIsArray($aProperties['*']['callback']); |
|
| 208 | - $this->assertEquals('jaxon.callback.global', $aProperties['*']['callback'][0]); |
|
| 209 | - } |
|
| 207 | +$this->assertIsArray($aProperties['*']['callback']); |
|
| 208 | +$this->assertEquals('jaxon.callback.global', $aProperties['*']['callback'][0]); |
|
| 209 | +} |
|
| 210 | 210 | |
| 211 | - /** |
|
| 211 | +/** |
|
| 212 | 212 | * @throws SetupException |
| 213 | 213 | */ |
| 214 | - public function testClassBeforeAnnotation() |
|
| 215 | - { |
|
| 216 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 217 | - $aProperties = $xMetadata->getProperties(); |
|
| 218 | - |
|
| 219 | - $this->assertCount(2, $aProperties['*']['__before']); |
|
| 220 | - $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 221 | - $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 222 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 223 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - /** |
|
| 214 | +public function testClassBeforeAnnotation() |
|
| 215 | +{ |
|
| 216 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 217 | +$aProperties = $xMetadata->getProperties(); |
|
| 218 | + |
|
| 219 | +$this->assertCount(2, $aProperties['*']['__before']); |
|
| 220 | +$this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 221 | +$this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 222 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 223 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 224 | +} |
|
| 225 | + |
|
| 226 | +/** |
|
| 227 | 227 | * @throws SetupException |
| 228 | 228 | */ |
| 229 | - public function testClassAfterAnnotation() |
|
| 230 | - { |
|
| 231 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 232 | - $aProperties = $xMetadata->getProperties(); |
|
| 233 | - |
|
| 234 | - $this->assertCount(3, $aProperties['*']['__after']); |
|
| 235 | - $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 236 | - $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 237 | - $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 238 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 239 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 240 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 229 | +public function testClassAfterAnnotation() |
|
| 230 | +{ |
|
| 231 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 232 | +$aProperties = $xMetadata->getProperties(); |
|
| 233 | + |
|
| 234 | +$this->assertCount(3, $aProperties['*']['__after']); |
|
| 235 | +$this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 236 | +$this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 237 | +$this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 238 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 239 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 240 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 241 | +} |
|
| 242 | + |
|
| 243 | +/** |
|
| 244 | 244 | * @throws SetupException |
| 245 | 245 | */ |
| 246 | - public function testClassDiAnnotation() |
|
| 247 | - { |
|
| 248 | - $xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 249 | - $aProperties = $xMetadata->getProperties(); |
|
| 250 | - |
|
| 251 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 252 | - $this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 253 | - $this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 254 | - $this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 255 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 256 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 257 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - /** |
|
| 246 | +public function testClassDiAnnotation() |
|
| 247 | +{ |
|
| 248 | +$xMetadata = $this->getAttributes(ExtendClassAnnotated::class, []); |
|
| 249 | +$aProperties = $xMetadata->getProperties(); |
|
| 250 | + |
|
| 251 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 252 | +$this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 253 | +$this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 254 | +$this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 255 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 256 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 257 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 258 | +} |
|
| 259 | + |
|
| 260 | +/** |
|
| 261 | 261 | * @throws SetupException |
| 262 | 262 | */ |
| 263 | - public function testClassExcludeAnnotation() |
|
| 264 | - { |
|
| 265 | - $xMetadata = $this->getAttributes(ClassExcluded::class, |
|
| 266 | - ['doNot', 'withBags', 'cbSingle']); |
|
| 267 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 268 | - $aProperties = $xMetadata->getProperties(); |
|
| 269 | - $aExcluded = $xMetadata->getExceptMethods(); |
|
| 270 | - |
|
| 271 | - $this->assertTrue($bExcluded); |
|
| 272 | - $this->assertEmpty($aProperties); |
|
| 273 | - $this->assertEmpty($aExcluded); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - public function testExcludeAnnotationError() |
|
| 277 | - { |
|
| 278 | - $this->expectException(SetupException::class); |
|
| 279 | - $this->getAttributes(ExtendAnnotated::class, ['doNotError']); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - public function testDatabagAnnotationError() |
|
| 283 | - { |
|
| 284 | - $this->expectException(SetupException::class); |
|
| 285 | - $this->getAttributes(ExtendAnnotated::class, ['withBagsError']); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - public function testUploadAnnotationWrongName() |
|
| 289 | - { |
|
| 290 | - $this->expectException(SetupException::class); |
|
| 291 | - $this->getAttributes(ExtendAnnotated::class, ['saveFilesWrongName']); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - public function testUploadAnnotationMultiple() |
|
| 295 | - { |
|
| 296 | - $this->expectException(SetupException::class); |
|
| 297 | - $this->getAttributes(ExtendAnnotated::class, ['saveFilesMultiple']); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - public function testCallbacksBeforeAnnotationNoCall() |
|
| 301 | - { |
|
| 302 | - $this->expectException(SetupException::class); |
|
| 303 | - $this->getAttributes(ExtendAnnotated::class, ['cbBeforeNoCall']); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - public function testCallbacksBeforeAnnotationUnknownAttr() |
|
| 307 | - { |
|
| 308 | - $this->expectException(SetupException::class); |
|
| 309 | - $this->getAttributes(ExtendAnnotated::class, ['cbBeforeUnknownAttr']); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - public function testCallbacksBeforeAnnotationWrongAttrType() |
|
| 313 | - { |
|
| 314 | - $this->expectException(SetupException::class); |
|
| 315 | - $this->getAttributes(ExtendAnnotated::class, ['cbBeforeWrongAttrType']); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - public function testCallbacksAfterAnnotationNoCall() |
|
| 319 | - { |
|
| 320 | - $this->expectException(SetupException::class); |
|
| 321 | - $this->getAttributes(ExtendAnnotated::class, ['cbAfterNoCall']); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - public function testCallbacksAfterAnnotationUnknownAttr() |
|
| 325 | - { |
|
| 326 | - $this->expectException(SetupException::class); |
|
| 327 | - $this->getAttributes(ExtendAnnotated::class, ['cbAfterUnknownAttr']); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - public function testCallbacksAfterAnnotationWrongAttrType() |
|
| 331 | - { |
|
| 332 | - $this->expectException(SetupException::class); |
|
| 333 | - $this->getAttributes(ExtendAnnotated::class, ['cbAfterWrongAttrType']); |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - public function testContainerAnnotationUnknownAttr() |
|
| 337 | - { |
|
| 338 | - $this->expectException(SetupException::class); |
|
| 339 | - $this->getAttributes(ExtendAnnotated::class, ['diUnknownAttr']); |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - public function testContainerAnnotationWrongAttrType() |
|
| 343 | - { |
|
| 344 | - $this->expectException(SetupException::class); |
|
| 345 | - $this->getAttributes(ExtendAnnotated::class, ['diWrongAttrType']); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - public function testContainerAnnotationWrongClassType() |
|
| 349 | - { |
|
| 350 | - $this->expectException(SetupException::class); |
|
| 351 | - $this->getAttributes(ExtendAnnotated::class, ['diWrongClassType']); |
|
| 352 | - } |
|
| 353 | - |
|
| 354 | - public function testContainerAnnotationWrongVarCount() |
|
| 355 | - { |
|
| 356 | - $this->expectException(SetupException::class); |
|
| 357 | - $this->getAttributes(ExtendAnnotated::class, ['diWrongVarCount']); |
|
| 358 | - } |
|
| 263 | +public function testClassExcludeAnnotation() |
|
| 264 | +{ |
|
| 265 | +$xMetadata = $this->getAttributes(ClassExcluded::class, |
|
| 266 | +['doNot', 'withBags', 'cbSingle']); |
|
| 267 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 268 | +$aProperties = $xMetadata->getProperties(); |
|
| 269 | +$aExcluded = $xMetadata->getExceptMethods(); |
|
| 270 | + |
|
| 271 | +$this->assertTrue($bExcluded); |
|
| 272 | +$this->assertEmpty($aProperties); |
|
| 273 | +$this->assertEmpty($aExcluded); |
|
| 274 | +} |
|
| 275 | + |
|
| 276 | +public function testExcludeAnnotationError() |
|
| 277 | +{ |
|
| 278 | +$this->expectException(SetupException::class); |
|
| 279 | +$this->getAttributes(ExtendAnnotated::class, ['doNotError']); |
|
| 280 | +} |
|
| 281 | + |
|
| 282 | +public function testDatabagAnnotationError() |
|
| 283 | +{ |
|
| 284 | +$this->expectException(SetupException::class); |
|
| 285 | +$this->getAttributes(ExtendAnnotated::class, ['withBagsError']); |
|
| 286 | +} |
|
| 287 | + |
|
| 288 | +public function testUploadAnnotationWrongName() |
|
| 289 | +{ |
|
| 290 | +$this->expectException(SetupException::class); |
|
| 291 | +$this->getAttributes(ExtendAnnotated::class, ['saveFilesWrongName']); |
|
| 292 | +} |
|
| 293 | + |
|
| 294 | +public function testUploadAnnotationMultiple() |
|
| 295 | +{ |
|
| 296 | +$this->expectException(SetupException::class); |
|
| 297 | +$this->getAttributes(ExtendAnnotated::class, ['saveFilesMultiple']); |
|
| 298 | +} |
|
| 299 | + |
|
| 300 | +public function testCallbacksBeforeAnnotationNoCall() |
|
| 301 | +{ |
|
| 302 | +$this->expectException(SetupException::class); |
|
| 303 | +$this->getAttributes(ExtendAnnotated::class, ['cbBeforeNoCall']); |
|
| 304 | +} |
|
| 305 | + |
|
| 306 | +public function testCallbacksBeforeAnnotationUnknownAttr() |
|
| 307 | +{ |
|
| 308 | +$this->expectException(SetupException::class); |
|
| 309 | +$this->getAttributes(ExtendAnnotated::class, ['cbBeforeUnknownAttr']); |
|
| 310 | +} |
|
| 311 | + |
|
| 312 | +public function testCallbacksBeforeAnnotationWrongAttrType() |
|
| 313 | +{ |
|
| 314 | +$this->expectException(SetupException::class); |
|
| 315 | +$this->getAttributes(ExtendAnnotated::class, ['cbBeforeWrongAttrType']); |
|
| 316 | +} |
|
| 317 | + |
|
| 318 | +public function testCallbacksAfterAnnotationNoCall() |
|
| 319 | +{ |
|
| 320 | +$this->expectException(SetupException::class); |
|
| 321 | +$this->getAttributes(ExtendAnnotated::class, ['cbAfterNoCall']); |
|
| 322 | +} |
|
| 323 | + |
|
| 324 | +public function testCallbacksAfterAnnotationUnknownAttr() |
|
| 325 | +{ |
|
| 326 | +$this->expectException(SetupException::class); |
|
| 327 | +$this->getAttributes(ExtendAnnotated::class, ['cbAfterUnknownAttr']); |
|
| 328 | +} |
|
| 329 | + |
|
| 330 | +public function testCallbacksAfterAnnotationWrongAttrType() |
|
| 331 | +{ |
|
| 332 | +$this->expectException(SetupException::class); |
|
| 333 | +$this->getAttributes(ExtendAnnotated::class, ['cbAfterWrongAttrType']); |
|
| 334 | +} |
|
| 335 | + |
|
| 336 | +public function testContainerAnnotationUnknownAttr() |
|
| 337 | +{ |
|
| 338 | +$this->expectException(SetupException::class); |
|
| 339 | +$this->getAttributes(ExtendAnnotated::class, ['diUnknownAttr']); |
|
| 340 | +} |
|
| 341 | + |
|
| 342 | +public function testContainerAnnotationWrongAttrType() |
|
| 343 | +{ |
|
| 344 | +$this->expectException(SetupException::class); |
|
| 345 | +$this->getAttributes(ExtendAnnotated::class, ['diWrongAttrType']); |
|
| 346 | +} |
|
| 347 | + |
|
| 348 | +public function testContainerAnnotationWrongClassType() |
|
| 349 | +{ |
|
| 350 | +$this->expectException(SetupException::class); |
|
| 351 | +$this->getAttributes(ExtendAnnotated::class, ['diWrongClassType']); |
|
| 352 | +} |
|
| 353 | + |
|
| 354 | +public function testContainerAnnotationWrongVarCount() |
|
| 355 | +{ |
|
| 356 | +$this->expectException(SetupException::class); |
|
| 357 | +$this->getAttributes(ExtendAnnotated::class, ['diWrongVarCount']); |
|
| 358 | +} |
|
| 359 | 359 | } |
@@ -12,186 +12,186 @@ |
||
| 12 | 12 | |
| 13 | 13 | class AttrAnnotationTest extends TestCase |
| 14 | 14 | { |
| 15 | - use AnnotationTrait; |
|
| 15 | +use AnnotationTrait; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | +/** |
|
| 18 | 18 | * @var string |
| 19 | 19 | */ |
| 20 | - protected $sCacheDir; |
|
| 20 | +protected $sCacheDir; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * @throws SetupException |
| 24 | 24 | */ |
| 25 | - public function setUp(): void |
|
| 26 | - { |
|
| 27 | - $this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 28 | - @mkdir($this->sCacheDir); |
|
| 25 | +public function setUp(): void |
|
| 26 | +{ |
|
| 27 | +$this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 28 | +@mkdir($this->sCacheDir); |
|
| 29 | 29 | |
| 30 | - jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 31 | - _register(); |
|
| 30 | +jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 31 | +_register(); |
|
| 32 | 32 | |
| 33 | - jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 34 | - } |
|
| 33 | +jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * @throws SetupException |
| 38 | 38 | */ |
| 39 | - public function tearDown(): void |
|
| 40 | - { |
|
| 41 | - jaxon()->reset(); |
|
| 42 | - parent::tearDown(); |
|
| 43 | - |
|
| 44 | - // Delete the temp dir and all its content |
|
| 45 | - $aFiles = scandir($this->sCacheDir); |
|
| 46 | - foreach ($aFiles as $sFile) |
|
| 47 | - { |
|
| 48 | - if($sFile !== '.' && $sFile !== '..') |
|
| 49 | - { |
|
| 50 | - @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - @rmdir($this->sCacheDir); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 39 | +public function tearDown(): void |
|
| 40 | +{ |
|
| 41 | +jaxon()->reset(); |
|
| 42 | +parent::tearDown(); |
|
| 43 | + |
|
| 44 | +// Delete the temp dir and all its content |
|
| 45 | +$aFiles = scandir($this->sCacheDir); |
|
| 46 | +foreach ($aFiles as $sFile) |
|
| 47 | +{ |
|
| 48 | +if($sFile !== '.' && $sFile !== '..') |
|
| 49 | +{ |
|
| 50 | + @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 51 | +} |
|
| 52 | +} |
|
| 53 | +@rmdir($this->sCacheDir); |
|
| 54 | +} |
|
| 55 | + |
|
| 56 | +/** |
|
| 57 | 57 | * @throws SetupException |
| 58 | 58 | */ |
| 59 | - public function testContainerAnnotation() |
|
| 60 | - { |
|
| 61 | - $xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 62 | - ['attrVar'], ['colorService', 'fontService', 'textService']); |
|
| 63 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 64 | - $aProperties = $xMetadata->getProperties(); |
|
| 65 | - |
|
| 66 | - $this->assertFalse($bExcluded); |
|
| 67 | - |
|
| 68 | - $this->assertCount(1, $aProperties); |
|
| 69 | - $this->assertArrayHasKey('attrVar', $aProperties); |
|
| 70 | - $this->assertCount(3, $aProperties['attrVar']['__di']); |
|
| 71 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['attrVar']['__di']['colorService']); |
|
| 72 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['attrVar']['__di']['fontService']); |
|
| 73 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['attrVar']['__di']['textService']); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 59 | +public function testContainerAnnotation() |
|
| 60 | +{ |
|
| 61 | +$xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 62 | +['attrVar'], ['colorService', 'fontService', 'textService']); |
|
| 63 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 64 | +$aProperties = $xMetadata->getProperties(); |
|
| 65 | + |
|
| 66 | +$this->assertFalse($bExcluded); |
|
| 67 | + |
|
| 68 | +$this->assertCount(1, $aProperties); |
|
| 69 | +$this->assertArrayHasKey('attrVar', $aProperties); |
|
| 70 | +$this->assertCount(3, $aProperties['attrVar']['__di']); |
|
| 71 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['attrVar']['__di']['colorService']); |
|
| 72 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['attrVar']['__di']['fontService']); |
|
| 73 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['attrVar']['__di']['textService']); |
|
| 74 | +} |
|
| 75 | + |
|
| 76 | +/** |
|
| 77 | 77 | * @throws SetupException |
| 78 | 78 | */ |
| 79 | - public function testContainerDocBlockAnnotation() |
|
| 80 | - { |
|
| 81 | - $xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 82 | - ['attrDbVar'], ['colorService', 'fontService', 'textService']); |
|
| 83 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 84 | - $aProperties = $xMetadata->getProperties(); |
|
| 85 | - |
|
| 86 | - $this->assertFalse($bExcluded); |
|
| 87 | - |
|
| 88 | - $this->assertCount(1, $aProperties); |
|
| 89 | - $this->assertArrayHasKey('attrDbVar', $aProperties); |
|
| 90 | - $this->assertCount(3, $aProperties['attrDbVar']['__di']); |
|
| 91 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['attrDbVar']['__di']['colorService']); |
|
| 92 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['attrDbVar']['__di']['fontService']); |
|
| 93 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['attrDbVar']['__di']['textService']); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - /** |
|
| 79 | +public function testContainerDocBlockAnnotation() |
|
| 80 | +{ |
|
| 81 | +$xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 82 | +['attrDbVar'], ['colorService', 'fontService', 'textService']); |
|
| 83 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 84 | +$aProperties = $xMetadata->getProperties(); |
|
| 85 | + |
|
| 86 | +$this->assertFalse($bExcluded); |
|
| 87 | + |
|
| 88 | +$this->assertCount(1, $aProperties); |
|
| 89 | +$this->assertArrayHasKey('attrDbVar', $aProperties); |
|
| 90 | +$this->assertCount(3, $aProperties['attrDbVar']['__di']); |
|
| 91 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['attrDbVar']['__di']['colorService']); |
|
| 92 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['attrDbVar']['__di']['fontService']); |
|
| 93 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['attrDbVar']['__di']['textService']); |
|
| 94 | +} |
|
| 95 | + |
|
| 96 | +/** |
|
| 97 | 97 | * @throws SetupException |
| 98 | 98 | */ |
| 99 | - public function testContainerDiAnnotation() |
|
| 100 | - { |
|
| 101 | - $xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 102 | - ['attrDi'], ['colorService1', 'fontService1', 'textService1']); |
|
| 103 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 104 | - $aProperties = $xMetadata->getProperties(); |
|
| 105 | - |
|
| 106 | - $this->assertFalse($bExcluded); |
|
| 107 | - |
|
| 108 | - $this->assertCount(1, $aProperties); |
|
| 109 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 110 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 111 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService1']); |
|
| 112 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService1']); |
|
| 113 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService1']); |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - /** |
|
| 99 | +public function testContainerDiAnnotation() |
|
| 100 | +{ |
|
| 101 | +$xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 102 | +['attrDi'], ['colorService1', 'fontService1', 'textService1']); |
|
| 103 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 104 | +$aProperties = $xMetadata->getProperties(); |
|
| 105 | + |
|
| 106 | +$this->assertFalse($bExcluded); |
|
| 107 | + |
|
| 108 | +$this->assertCount(1, $aProperties); |
|
| 109 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 110 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 111 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService1']); |
|
| 112 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService1']); |
|
| 113 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService1']); |
|
| 114 | +} |
|
| 115 | + |
|
| 116 | +/** |
|
| 117 | 117 | * @throws SetupException |
| 118 | 118 | */ |
| 119 | - public function testContainerDiAndVarAnnotation() |
|
| 120 | - { |
|
| 121 | - $xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 122 | - ['attrDi'], ['colorService2', 'fontService2', 'textService2']); |
|
| 123 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 124 | - $aProperties = $xMetadata->getProperties(); |
|
| 125 | - |
|
| 126 | - $this->assertFalse($bExcluded); |
|
| 127 | - |
|
| 128 | - $this->assertCount(1, $aProperties); |
|
| 129 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 130 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 131 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService2']); |
|
| 132 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService2']); |
|
| 133 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService2']); |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - /** |
|
| 119 | +public function testContainerDiAndVarAnnotation() |
|
| 120 | +{ |
|
| 121 | +$xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 122 | +['attrDi'], ['colorService2', 'fontService2', 'textService2']); |
|
| 123 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 124 | +$aProperties = $xMetadata->getProperties(); |
|
| 125 | + |
|
| 126 | +$this->assertFalse($bExcluded); |
|
| 127 | + |
|
| 128 | +$this->assertCount(1, $aProperties); |
|
| 129 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 130 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 131 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService2']); |
|
| 132 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService2']); |
|
| 133 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService2']); |
|
| 134 | +} |
|
| 135 | + |
|
| 136 | +/** |
|
| 137 | 137 | * @throws SetupException |
| 138 | 138 | */ |
| 139 | - public function testContainerPropAnnotation() |
|
| 140 | - { |
|
| 141 | - $xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 142 | - ['attrDi'], ['colorService3', 'fontService3', 'textService3']); |
|
| 143 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 144 | - $aProperties = $xMetadata->getProperties(); |
|
| 145 | - |
|
| 146 | - $this->assertFalse($bExcluded); |
|
| 147 | - |
|
| 148 | - $this->assertCount(1, $aProperties); |
|
| 149 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 150 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 151 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService3']); |
|
| 152 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService3']); |
|
| 153 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService3']); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - public function testContainerAnnotationErrorTwoParams() |
|
| 157 | - { |
|
| 158 | - $this->expectException(SetupException::class); |
|
| 159 | - $this->getAttributes(AttrAnnotated::class, [], ['errorTwoParams']); |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - public function testContainerAnnotationErrorDiAttr() |
|
| 163 | - { |
|
| 164 | - $this->expectException(SetupException::class); |
|
| 165 | - $this->getAttributes(AttrAnnotated::class, [], ['errorDiAttr']); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - public function testContainerAnnotationErrorDiDbAttr() |
|
| 169 | - { |
|
| 170 | - $this->expectException(SetupException::class); |
|
| 171 | - $this->getAttributes(AttrAnnotated::class, [], ['errorDiDbAttr']); |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - public function testContainerAnnotationErrorTwoDi() |
|
| 175 | - { |
|
| 176 | - $this->expectException(SetupException::class); |
|
| 177 | - $this->getAttributes(AttrAnnotated::class, [], ['errorTwoDi']); |
|
| 178 | - } |
|
| 179 | - |
|
| 180 | - public function testContainerAnnotationErrorDiClass() |
|
| 181 | - { |
|
| 182 | - $this->expectException(SetupException::class); |
|
| 183 | - $this->getAttributes(AttrAnnotated::class, ['errorDiClass']); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - public function testContainerAnnotationErrorNoVar() |
|
| 187 | - { |
|
| 188 | - $this->expectException(SetupException::class); |
|
| 189 | - $this->getAttributes(AttrAnnotated::class, ['errorDiNoVar']); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - public function testContainerAnnotationErrorTwoVars() |
|
| 193 | - { |
|
| 194 | - $this->expectException(SetupException::class); |
|
| 195 | - $this->getAttributes(AttrAnnotated::class, ['errorDiTwoVars']); |
|
| 196 | - } |
|
| 139 | +public function testContainerPropAnnotation() |
|
| 140 | +{ |
|
| 141 | +$xMetadata = $this->getAttributes(AttrAnnotated::class, |
|
| 142 | +['attrDi'], ['colorService3', 'fontService3', 'textService3']); |
|
| 143 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 144 | +$aProperties = $xMetadata->getProperties(); |
|
| 145 | + |
|
| 146 | +$this->assertFalse($bExcluded); |
|
| 147 | + |
|
| 148 | +$this->assertCount(1, $aProperties); |
|
| 149 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 150 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 151 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService3']); |
|
| 152 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService3']); |
|
| 153 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService3']); |
|
| 154 | +} |
|
| 155 | + |
|
| 156 | +public function testContainerAnnotationErrorTwoParams() |
|
| 157 | +{ |
|
| 158 | +$this->expectException(SetupException::class); |
|
| 159 | +$this->getAttributes(AttrAnnotated::class, [], ['errorTwoParams']); |
|
| 160 | +} |
|
| 161 | + |
|
| 162 | +public function testContainerAnnotationErrorDiAttr() |
|
| 163 | +{ |
|
| 164 | +$this->expectException(SetupException::class); |
|
| 165 | +$this->getAttributes(AttrAnnotated::class, [], ['errorDiAttr']); |
|
| 166 | +} |
|
| 167 | + |
|
| 168 | +public function testContainerAnnotationErrorDiDbAttr() |
|
| 169 | +{ |
|
| 170 | +$this->expectException(SetupException::class); |
|
| 171 | +$this->getAttributes(AttrAnnotated::class, [], ['errorDiDbAttr']); |
|
| 172 | +} |
|
| 173 | + |
|
| 174 | +public function testContainerAnnotationErrorTwoDi() |
|
| 175 | +{ |
|
| 176 | +$this->expectException(SetupException::class); |
|
| 177 | +$this->getAttributes(AttrAnnotated::class, [], ['errorTwoDi']); |
|
| 178 | +} |
|
| 179 | + |
|
| 180 | +public function testContainerAnnotationErrorDiClass() |
|
| 181 | +{ |
|
| 182 | +$this->expectException(SetupException::class); |
|
| 183 | +$this->getAttributes(AttrAnnotated::class, ['errorDiClass']); |
|
| 184 | +} |
|
| 185 | + |
|
| 186 | +public function testContainerAnnotationErrorNoVar() |
|
| 187 | +{ |
|
| 188 | +$this->expectException(SetupException::class); |
|
| 189 | +$this->getAttributes(AttrAnnotated::class, ['errorDiNoVar']); |
|
| 190 | +} |
|
| 191 | + |
|
| 192 | +public function testContainerAnnotationErrorTwoVars() |
|
| 193 | +{ |
|
| 194 | +$this->expectException(SetupException::class); |
|
| 195 | +$this->getAttributes(AttrAnnotated::class, ['errorDiTwoVars']); |
|
| 196 | +} |
|
| 197 | 197 | } |
@@ -16,320 +16,320 @@ |
||
| 16 | 16 | |
| 17 | 17 | class DocBlockAnnotationTest extends TestCase |
| 18 | 18 | { |
| 19 | - use AnnotationTrait; |
|
| 19 | +use AnnotationTrait; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var string |
| 23 | 23 | */ |
| 24 | - protected $sCacheDir; |
|
| 24 | +protected $sCacheDir; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * @throws SetupException |
| 28 | 28 | */ |
| 29 | - public function setUp(): void |
|
| 30 | - { |
|
| 31 | - $this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 32 | - @mkdir($this->sCacheDir); |
|
| 29 | +public function setUp(): void |
|
| 30 | +{ |
|
| 31 | +$this->sCacheDir = __DIR__ . '/../tmp'; |
|
| 32 | +@mkdir($this->sCacheDir); |
|
| 33 | 33 | |
| 34 | - jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 35 | - _register(); |
|
| 34 | +jaxon()->di()->getPluginManager()->registerPlugins(); |
|
| 35 | +_register(); |
|
| 36 | 36 | |
| 37 | - jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 38 | - } |
|
| 37 | +jaxon()->di()->val('jaxon_annotations_cache_dir', $this->sCacheDir); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * @throws SetupException |
| 42 | 42 | */ |
| 43 | - public function tearDown(): void |
|
| 44 | - { |
|
| 45 | - jaxon()->reset(); |
|
| 46 | - parent::tearDown(); |
|
| 47 | - |
|
| 48 | - // Delete the temp dir and all its content |
|
| 49 | - $aFiles = scandir($this->sCacheDir); |
|
| 50 | - foreach ($aFiles as $sFile) |
|
| 51 | - { |
|
| 52 | - if($sFile !== '.' && $sFile !== '..') |
|
| 53 | - { |
|
| 54 | - @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 55 | - } |
|
| 56 | - } |
|
| 57 | - @rmdir($this->sCacheDir); |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** |
|
| 43 | +public function tearDown(): void |
|
| 44 | +{ |
|
| 45 | +jaxon()->reset(); |
|
| 46 | +parent::tearDown(); |
|
| 47 | + |
|
| 48 | +// Delete the temp dir and all its content |
|
| 49 | +$aFiles = scandir($this->sCacheDir); |
|
| 50 | +foreach ($aFiles as $sFile) |
|
| 51 | +{ |
|
| 52 | +if($sFile !== '.' && $sFile !== '..') |
|
| 53 | +{ |
|
| 54 | + @unlink($this->sCacheDir . DIRECTORY_SEPARATOR . $sFile); |
|
| 55 | +} |
|
| 56 | +} |
|
| 57 | +@rmdir($this->sCacheDir); |
|
| 58 | +} |
|
| 59 | + |
|
| 60 | +/** |
|
| 61 | 61 | * @throws SetupException |
| 62 | 62 | */ |
| 63 | - public function testUploadAndExcludeAnnotation() |
|
| 64 | - { |
|
| 65 | - $xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['saveFiles', 'doNot']); |
|
| 66 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 67 | - $aProperties = $xMetadata->getProperties(); |
|
| 68 | - $aExcluded = $xMetadata->getExceptMethods(); |
|
| 63 | +public function testUploadAndExcludeAnnotation() |
|
| 64 | +{ |
|
| 65 | +$xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['saveFiles', 'doNot']); |
|
| 66 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 67 | +$aProperties = $xMetadata->getProperties(); |
|
| 68 | +$aExcluded = $xMetadata->getExceptMethods(); |
|
| 69 | 69 | |
| 70 | - $this->assertFalse($bExcluded); |
|
| 70 | +$this->assertFalse($bExcluded); |
|
| 71 | 71 | |
| 72 | - $this->assertCount(1, $aExcluded); |
|
| 73 | - $this->assertEquals('doNot', $aExcluded[0]); |
|
| 72 | +$this->assertCount(1, $aExcluded); |
|
| 73 | +$this->assertEquals('doNot', $aExcluded[0]); |
|
| 74 | 74 | |
| 75 | - $this->assertCount(1, $aProperties); |
|
| 76 | - $this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 77 | - $this->assertCount(1, $aProperties['saveFiles']); |
|
| 78 | - $this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 79 | - } |
|
| 75 | +$this->assertCount(1, $aProperties); |
|
| 76 | +$this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 77 | +$this->assertCount(1, $aProperties['saveFiles']); |
|
| 78 | +$this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - /** |
|
| 81 | +/** |
|
| 82 | 82 | * @throws SetupException |
| 83 | 83 | */ |
| 84 | - public function testDatabagAnnotation() |
|
| 85 | - { |
|
| 86 | - $xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['withBags']); |
|
| 87 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 88 | - $aProperties = $xMetadata->getProperties(); |
|
| 89 | - |
|
| 90 | - $this->assertFalse($bExcluded); |
|
| 91 | - |
|
| 92 | - $this->assertCount(1, $aProperties); |
|
| 93 | - $this->assertArrayHasKey('withBags', $aProperties); |
|
| 94 | - $this->assertCount(1, $aProperties['withBags']); |
|
| 95 | - $this->assertCount(2, $aProperties['withBags']['bags']); |
|
| 96 | - $this->assertEquals('user.name', $aProperties['withBags']['bags'][0]); |
|
| 97 | - $this->assertEquals('page.number', $aProperties['withBags']['bags'][1]); |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - /** |
|
| 84 | +public function testDatabagAnnotation() |
|
| 85 | +{ |
|
| 86 | +$xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['withBags']); |
|
| 87 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 88 | +$aProperties = $xMetadata->getProperties(); |
|
| 89 | + |
|
| 90 | +$this->assertFalse($bExcluded); |
|
| 91 | + |
|
| 92 | +$this->assertCount(1, $aProperties); |
|
| 93 | +$this->assertArrayHasKey('withBags', $aProperties); |
|
| 94 | +$this->assertCount(1, $aProperties['withBags']); |
|
| 95 | +$this->assertCount(2, $aProperties['withBags']['bags']); |
|
| 96 | +$this->assertEquals('user.name', $aProperties['withBags']['bags'][0]); |
|
| 97 | +$this->assertEquals('page.number', $aProperties['withBags']['bags'][1]); |
|
| 98 | +} |
|
| 99 | + |
|
| 100 | +/** |
|
| 101 | 101 | * @throws SetupException |
| 102 | 102 | */ |
| 103 | - public function testCallbackAnnotation() |
|
| 104 | - { |
|
| 105 | - $xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['withCallback']); |
|
| 106 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 107 | - $aProperties = $xMetadata->getProperties(); |
|
| 108 | - |
|
| 109 | - $this->assertFalse($bExcluded); |
|
| 110 | - |
|
| 111 | - $this->assertCount(1, $aProperties); |
|
| 112 | - $this->assertArrayHasKey('withCallback', $aProperties); |
|
| 113 | - $this->assertCount(1, $aProperties['withCallback']); |
|
| 114 | - $this->assertIsArray($aProperties['withCallback']['callback']); |
|
| 115 | - $this->assertEquals('jaxon.ajax.callback.test', $aProperties['withCallback']['callback'][0]); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 103 | +public function testCallbackAnnotation() |
|
| 104 | +{ |
|
| 105 | +$xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['withCallback']); |
|
| 106 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 107 | +$aProperties = $xMetadata->getProperties(); |
|
| 108 | + |
|
| 109 | +$this->assertFalse($bExcluded); |
|
| 110 | + |
|
| 111 | +$this->assertCount(1, $aProperties); |
|
| 112 | +$this->assertArrayHasKey('withCallback', $aProperties); |
|
| 113 | +$this->assertCount(1, $aProperties['withCallback']); |
|
| 114 | +$this->assertIsArray($aProperties['withCallback']['callback']); |
|
| 115 | +$this->assertEquals('jaxon.ajax.callback.test', $aProperties['withCallback']['callback'][0]); |
|
| 116 | +} |
|
| 117 | + |
|
| 118 | +/** |
|
| 119 | 119 | * @throws SetupException |
| 120 | 120 | */ |
| 121 | - public function testHooksAnnotation() |
|
| 122 | - { |
|
| 123 | - $xMetadata = $this->getAttributes(DocBlockAnnotated::class, |
|
| 124 | - ['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 125 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 126 | - $aProperties = $xMetadata->getProperties(); |
|
| 127 | - |
|
| 128 | - $this->assertFalse($bExcluded); |
|
| 129 | - |
|
| 130 | - $this->assertCount(3, $aProperties); |
|
| 131 | - $this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 132 | - $this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 133 | - $this->assertArrayHasKey('cbParams', $aProperties); |
|
| 134 | - |
|
| 135 | - $this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 136 | - $this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 137 | - $this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 138 | - $this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 139 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 140 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 141 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 142 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 143 | - $this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 144 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 145 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 146 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 147 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 148 | - |
|
| 149 | - $this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 150 | - $this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 151 | - $this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 152 | - $this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 153 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 154 | - $this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 155 | - $this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 156 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 157 | - $this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 158 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 159 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 160 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 161 | - $this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 121 | +public function testHooksAnnotation() |
|
| 122 | +{ |
|
| 123 | +$xMetadata = $this->getAttributes(DocBlockAnnotated::class, |
|
| 124 | +['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 125 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 126 | +$aProperties = $xMetadata->getProperties(); |
|
| 127 | + |
|
| 128 | +$this->assertFalse($bExcluded); |
|
| 129 | + |
|
| 130 | +$this->assertCount(3, $aProperties); |
|
| 131 | +$this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 132 | +$this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 133 | +$this->assertArrayHasKey('cbParams', $aProperties); |
|
| 134 | + |
|
| 135 | +$this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 136 | +$this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 137 | +$this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 138 | +$this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 139 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 140 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 141 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 142 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 143 | +$this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 144 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 145 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 146 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 147 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 148 | + |
|
| 149 | +$this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 150 | +$this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 151 | +$this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 152 | +$this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 153 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 154 | +$this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 155 | +$this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 156 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 157 | +$this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 158 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 159 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 160 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 161 | +$this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 162 | +} |
|
| 163 | + |
|
| 164 | +/** |
|
| 165 | 165 | * @throws SetupException |
| 166 | 166 | */ |
| 167 | - public function testContainerAnnotation() |
|
| 168 | - { |
|
| 169 | - $xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['di1', 'di2']); |
|
| 170 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 171 | - $aProperties = $xMetadata->getProperties(); |
|
| 172 | - |
|
| 173 | - $this->assertFalse($bExcluded); |
|
| 174 | - |
|
| 175 | - $this->assertCount(2, $aProperties); |
|
| 176 | - $this->assertArrayHasKey('di1', $aProperties); |
|
| 177 | - $this->assertArrayHasKey('di2', $aProperties); |
|
| 178 | - $this->assertCount(2, $aProperties['di1']['__di']); |
|
| 179 | - $this->assertCount(2, $aProperties['di2']['__di']); |
|
| 180 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 181 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 182 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 183 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 167 | +public function testContainerAnnotation() |
|
| 168 | +{ |
|
| 169 | +$xMetadata = $this->getAttributes(DocBlockAnnotated::class, ['di1', 'di2']); |
|
| 170 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 171 | +$aProperties = $xMetadata->getProperties(); |
|
| 172 | + |
|
| 173 | +$this->assertFalse($bExcluded); |
|
| 174 | + |
|
| 175 | +$this->assertCount(2, $aProperties); |
|
| 176 | +$this->assertArrayHasKey('di1', $aProperties); |
|
| 177 | +$this->assertArrayHasKey('di2', $aProperties); |
|
| 178 | +$this->assertCount(2, $aProperties['di1']['__di']); |
|
| 179 | +$this->assertCount(2, $aProperties['di2']['__di']); |
|
| 180 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 181 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 182 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 183 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 184 | +} |
|
| 185 | + |
|
| 186 | +/** |
|
| 187 | 187 | * @throws SetupException |
| 188 | 188 | */ |
| 189 | - public function testClassAnnotation() |
|
| 190 | - { |
|
| 191 | - $xMetadata = $this->getAttributes(DocBlockClassAnnotated::class, []); |
|
| 192 | - // $this->assertEquals('', json_encode($aProperties)); |
|
| 193 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 194 | - $aProperties = $xMetadata->getProperties(); |
|
| 195 | - |
|
| 196 | - $this->assertFalse($bExcluded); |
|
| 197 | - |
|
| 198 | - $this->assertCount(1, $aProperties); |
|
| 199 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 200 | - $this->assertCount(5, $aProperties['*']); |
|
| 201 | - $this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 202 | - $this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 203 | - $this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 204 | - $this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 205 | - |
|
| 206 | - $this->assertCount(2, $aProperties['*']['bags']); |
|
| 207 | - $this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 208 | - $this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 209 | - |
|
| 210 | - $this->assertIsArray($aProperties['*']['callback']); |
|
| 211 | - $this->assertEquals('jaxon.ajax.callback.test', $aProperties['*']['callback'][0]); |
|
| 212 | - |
|
| 213 | - $this->assertCount(2, $aProperties['*']['__before']); |
|
| 214 | - $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 215 | - $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 216 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 217 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 218 | - |
|
| 219 | - $this->assertCount(3, $aProperties['*']['__after']); |
|
| 220 | - $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 221 | - $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 222 | - $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 223 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 224 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 225 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 226 | - |
|
| 227 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 228 | - $this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 229 | - $this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 230 | - $this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 231 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 232 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 233 | - $this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - /** |
|
| 189 | +public function testClassAnnotation() |
|
| 190 | +{ |
|
| 191 | +$xMetadata = $this->getAttributes(DocBlockClassAnnotated::class, []); |
|
| 192 | +// $this->assertEquals('', json_encode($aProperties)); |
|
| 193 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 194 | +$aProperties = $xMetadata->getProperties(); |
|
| 195 | + |
|
| 196 | +$this->assertFalse($bExcluded); |
|
| 197 | + |
|
| 198 | +$this->assertCount(1, $aProperties); |
|
| 199 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 200 | +$this->assertCount(5, $aProperties['*']); |
|
| 201 | +$this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 202 | +$this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 203 | +$this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 204 | +$this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 205 | + |
|
| 206 | +$this->assertCount(2, $aProperties['*']['bags']); |
|
| 207 | +$this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 208 | +$this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 209 | + |
|
| 210 | +$this->assertIsArray($aProperties['*']['callback']); |
|
| 211 | +$this->assertEquals('jaxon.ajax.callback.test', $aProperties['*']['callback'][0]); |
|
| 212 | + |
|
| 213 | +$this->assertCount(2, $aProperties['*']['__before']); |
|
| 214 | +$this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 215 | +$this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 216 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 217 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 218 | + |
|
| 219 | +$this->assertCount(3, $aProperties['*']['__after']); |
|
| 220 | +$this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 221 | +$this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 222 | +$this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 223 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 224 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 225 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 226 | + |
|
| 227 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 228 | +$this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 229 | +$this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 230 | +$this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 231 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 232 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 233 | +$this->assertEquals('Jaxon\Annotations\Tests\Attr\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 234 | +} |
|
| 235 | + |
|
| 236 | +/** |
|
| 237 | 237 | * @throws SetupException |
| 238 | 238 | */ |
| 239 | - public function testClassExcludeAnnotation() |
|
| 240 | - { |
|
| 241 | - $xMetadata = $this->getAttributes(DocBlockClassExcluded::class, |
|
| 242 | - ['doNot', 'withBags', 'cbSingle']); |
|
| 243 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 244 | - $aProperties = $xMetadata->getProperties(); |
|
| 245 | - $aExcluded = $xMetadata->getExceptMethods(); |
|
| 246 | - |
|
| 247 | - $this->assertTrue($bExcluded); |
|
| 248 | - $this->assertEmpty($aProperties); |
|
| 249 | - $this->assertEmpty($aExcluded); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - public function testUploadAnnotationErrorFieldName() |
|
| 253 | - { |
|
| 254 | - $this->expectException(SetupException::class); |
|
| 255 | - $this->getAttributes(DocBlockAnnotated::class, ['saveFileErrorFieldName']); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - public function testUploadAnnotationErrorFieldNumber() |
|
| 259 | - { |
|
| 260 | - $this->expectException(SetupException::class); |
|
| 261 | - $this->getAttributes(DocBlockAnnotated::class, ['saveFileErrorFieldNumber']); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - public function testDatabagAnnotationErrorName() |
|
| 265 | - { |
|
| 266 | - $this->expectException(SetupException::class); |
|
| 267 | - $this->getAttributes(DocBlockAnnotated::class, ['withBagsErrorName']); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - public function testDatabagAnnotationErrorNumber() |
|
| 271 | - { |
|
| 272 | - $this->expectException(SetupException::class); |
|
| 273 | - $this->getAttributes(DocBlockAnnotated::class, ['withBagsErrorNumber']); |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - public function testContainerAnnotationErrorAttr() |
|
| 277 | - { |
|
| 278 | - $this->expectException(SetupException::class); |
|
| 279 | - $this->getAttributes(DocBlockAnnotated::class, ['diErrorAttr']); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - public function testContainerAnnotationErrorClass() |
|
| 283 | - { |
|
| 284 | - $this->expectException(SetupException::class); |
|
| 285 | - $this->getAttributes(DocBlockAnnotated::class, ['diErrorClass']); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - public function testContainerAnnotationErrorOneParam() |
|
| 289 | - { |
|
| 290 | - $this->expectException(SetupException::class); |
|
| 291 | - $this->getAttributes(DocBlockAnnotated::class, ['diErrorOneParam']); |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - public function testContainerAnnotationErrorThreeParams() |
|
| 295 | - { |
|
| 296 | - $this->expectException(SetupException::class); |
|
| 297 | - $this->getAttributes(DocBlockAnnotated::class, ['diErrorThreeParams']); |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - public function testCbBeforeAnnotationErrorName() |
|
| 301 | - { |
|
| 302 | - $this->expectException(SetupException::class); |
|
| 303 | - $this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorName']); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - public function testCbBeforeAnnotationErrorParam() |
|
| 307 | - { |
|
| 308 | - $this->expectException(SetupException::class); |
|
| 309 | - $this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorParam']); |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - public function testCbBeforeAnnotationErrorNumber() |
|
| 313 | - { |
|
| 314 | - $this->expectException(SetupException::class); |
|
| 315 | - $this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorNumber']); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - public function testCbAfterAnnotationErrorName() |
|
| 319 | - { |
|
| 320 | - $this->expectException(SetupException::class); |
|
| 321 | - $this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorName']); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - public function testCbAfterAnnotationErrorParam() |
|
| 325 | - { |
|
| 326 | - $this->expectException(SetupException::class); |
|
| 327 | - $this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorParam']); |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - public function testCbAfterAnnotationErrorNumber() |
|
| 331 | - { |
|
| 332 | - $this->expectException(SetupException::class); |
|
| 333 | - $this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorNumber']); |
|
| 334 | - } |
|
| 239 | +public function testClassExcludeAnnotation() |
|
| 240 | +{ |
|
| 241 | +$xMetadata = $this->getAttributes(DocBlockClassExcluded::class, |
|
| 242 | +['doNot', 'withBags', 'cbSingle']); |
|
| 243 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 244 | +$aProperties = $xMetadata->getProperties(); |
|
| 245 | +$aExcluded = $xMetadata->getExceptMethods(); |
|
| 246 | + |
|
| 247 | +$this->assertTrue($bExcluded); |
|
| 248 | +$this->assertEmpty($aProperties); |
|
| 249 | +$this->assertEmpty($aExcluded); |
|
| 250 | +} |
|
| 251 | + |
|
| 252 | +public function testUploadAnnotationErrorFieldName() |
|
| 253 | +{ |
|
| 254 | +$this->expectException(SetupException::class); |
|
| 255 | +$this->getAttributes(DocBlockAnnotated::class, ['saveFileErrorFieldName']); |
|
| 256 | +} |
|
| 257 | + |
|
| 258 | +public function testUploadAnnotationErrorFieldNumber() |
|
| 259 | +{ |
|
| 260 | +$this->expectException(SetupException::class); |
|
| 261 | +$this->getAttributes(DocBlockAnnotated::class, ['saveFileErrorFieldNumber']); |
|
| 262 | +} |
|
| 263 | + |
|
| 264 | +public function testDatabagAnnotationErrorName() |
|
| 265 | +{ |
|
| 266 | +$this->expectException(SetupException::class); |
|
| 267 | +$this->getAttributes(DocBlockAnnotated::class, ['withBagsErrorName']); |
|
| 268 | +} |
|
| 269 | + |
|
| 270 | +public function testDatabagAnnotationErrorNumber() |
|
| 271 | +{ |
|
| 272 | +$this->expectException(SetupException::class); |
|
| 273 | +$this->getAttributes(DocBlockAnnotated::class, ['withBagsErrorNumber']); |
|
| 274 | +} |
|
| 275 | + |
|
| 276 | +public function testContainerAnnotationErrorAttr() |
|
| 277 | +{ |
|
| 278 | +$this->expectException(SetupException::class); |
|
| 279 | +$this->getAttributes(DocBlockAnnotated::class, ['diErrorAttr']); |
|
| 280 | +} |
|
| 281 | + |
|
| 282 | +public function testContainerAnnotationErrorClass() |
|
| 283 | +{ |
|
| 284 | +$this->expectException(SetupException::class); |
|
| 285 | +$this->getAttributes(DocBlockAnnotated::class, ['diErrorClass']); |
|
| 286 | +} |
|
| 287 | + |
|
| 288 | +public function testContainerAnnotationErrorOneParam() |
|
| 289 | +{ |
|
| 290 | +$this->expectException(SetupException::class); |
|
| 291 | +$this->getAttributes(DocBlockAnnotated::class, ['diErrorOneParam']); |
|
| 292 | +} |
|
| 293 | + |
|
| 294 | +public function testContainerAnnotationErrorThreeParams() |
|
| 295 | +{ |
|
| 296 | +$this->expectException(SetupException::class); |
|
| 297 | +$this->getAttributes(DocBlockAnnotated::class, ['diErrorThreeParams']); |
|
| 298 | +} |
|
| 299 | + |
|
| 300 | +public function testCbBeforeAnnotationErrorName() |
|
| 301 | +{ |
|
| 302 | +$this->expectException(SetupException::class); |
|
| 303 | +$this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorName']); |
|
| 304 | +} |
|
| 305 | + |
|
| 306 | +public function testCbBeforeAnnotationErrorParam() |
|
| 307 | +{ |
|
| 308 | +$this->expectException(SetupException::class); |
|
| 309 | +$this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorParam']); |
|
| 310 | +} |
|
| 311 | + |
|
| 312 | +public function testCbBeforeAnnotationErrorNumber() |
|
| 313 | +{ |
|
| 314 | +$this->expectException(SetupException::class); |
|
| 315 | +$this->getAttributes(DocBlockAnnotated::class, ['cbBeforeErrorNumber']); |
|
| 316 | +} |
|
| 317 | + |
|
| 318 | +public function testCbAfterAnnotationErrorName() |
|
| 319 | +{ |
|
| 320 | +$this->expectException(SetupException::class); |
|
| 321 | +$this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorName']); |
|
| 322 | +} |
|
| 323 | + |
|
| 324 | +public function testCbAfterAnnotationErrorParam() |
|
| 325 | +{ |
|
| 326 | +$this->expectException(SetupException::class); |
|
| 327 | +$this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorParam']); |
|
| 328 | +} |
|
| 329 | + |
|
| 330 | +public function testCbAfterAnnotationErrorNumber() |
|
| 331 | +{ |
|
| 332 | +$this->expectException(SetupException::class); |
|
| 333 | +$this->getAttributes(DocBlockAnnotated::class, ['cbAfterErrorNumber']); |
|
| 334 | +} |
|
| 335 | 335 | } |