@@ -13,94 +13,94 @@ |
||
| 13 | 13 | |
| 14 | 14 | class DataBagPlugin extends AbstractResponsePlugin |
| 15 | 15 | { |
| 16 | - /** |
|
| 16 | +/** |
|
| 17 | 17 | * @const The plugin name |
| 18 | 18 | */ |
| 19 | - public const NAME = 'bags'; |
|
| 19 | +public const NAME = 'bags'; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @var DataBag |
| 23 | 23 | */ |
| 24 | - protected $xDataBag = null; |
|
| 24 | +protected $xDataBag = null; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 26 | +/** |
|
| 27 | 27 | * The constructor |
| 28 | 28 | */ |
| 29 | - public function __construct(protected Container $di) |
|
| 30 | - {} |
|
| 29 | +public function __construct(protected Container $di) |
|
| 30 | +{} |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | +/** |
|
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - private function initDataBag(): void |
|
| 36 | - { |
|
| 37 | - if($this->xDataBag !== null) |
|
| 38 | - { |
|
| 39 | - return; |
|
| 40 | - } |
|
| 35 | +private function initDataBag(): void |
|
| 36 | +{ |
|
| 37 | +if($this->xDataBag !== null) |
|
| 38 | +{ |
|
| 39 | +return; |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - // Get the databag contents from the HTTP request parameters. |
|
| 43 | - $xRequest = $this->di->getRequest(); |
|
| 44 | - $aBody = $xRequest->getParsedBody(); |
|
| 45 | - $aParams = $xRequest->getQueryParams(); |
|
| 46 | - $aData = is_array($aBody) ? |
|
| 47 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
| 48 | - $this->readData($aParams['jxnbags'] ?? []); |
|
| 49 | - $this->xDataBag = new DataBag($this, $aData); |
|
| 50 | - } |
|
| 42 | +// Get the databag contents from the HTTP request parameters. |
|
| 43 | +$xRequest = $this->di->getRequest(); |
|
| 44 | +$aBody = $xRequest->getParsedBody(); |
|
| 45 | +$aParams = $xRequest->getQueryParams(); |
|
| 46 | +$aData = is_array($aBody) ? |
|
| 47 | +$this->readData($aBody['jxnbags'] ?? []) : |
|
| 48 | +$this->readData($aParams['jxnbags'] ?? []); |
|
| 49 | +$this->xDataBag = new DataBag($this, $aData); |
|
| 50 | +} |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | +/** |
|
| 53 | 53 | * @inheritDoc |
| 54 | 54 | */ |
| 55 | - public function getName(): string |
|
| 56 | - { |
|
| 57 | - return self::NAME; |
|
| 58 | - } |
|
| 55 | +public function getName(): string |
|
| 56 | +{ |
|
| 57 | +return self::NAME; |
|
| 58 | +} |
|
| 59 | 59 | |
| 60 | - /** |
|
| 60 | +/** |
|
| 61 | 61 | * @param mixed $xData |
| 62 | 62 | * |
| 63 | 63 | * @return array |
| 64 | 64 | */ |
| 65 | - private function readData($xData): array |
|
| 66 | - { |
|
| 67 | - // Todo: clean input data. |
|
| 68 | - // Todo: verify the checksums. |
|
| 69 | - return is_string($xData) ? |
|
| 70 | - (json_decode($xData, true) ?: []) : |
|
| 71 | - (is_array($xData) ? $xData : []); |
|
| 72 | - } |
|
| 65 | +private function readData($xData): array |
|
| 66 | +{ |
|
| 67 | +// Todo: clean input data. |
|
| 68 | +// Todo: verify the checksums. |
|
| 69 | +return is_string($xData) ? |
|
| 70 | +(json_decode($xData, true) ?: []) : |
|
| 71 | +(is_array($xData) ? $xData : []); |
|
| 72 | +} |
|
| 73 | 73 | |
| 74 | - /** |
|
| 74 | +/** |
|
| 75 | 75 | * @inheritDoc |
| 76 | 76 | */ |
| 77 | - public function getHash(): string |
|
| 78 | - { |
|
| 79 | - // Use the version number as hash |
|
| 80 | - return '4.0.0'; |
|
| 81 | - } |
|
| 77 | +public function getHash(): string |
|
| 78 | +{ |
|
| 79 | +// Use the version number as hash |
|
| 80 | +return '4.0.0'; |
|
| 81 | +} |
|
| 82 | 82 | |
| 83 | - /** |
|
| 83 | +/** |
|
| 84 | 84 | * @return void |
| 85 | 85 | */ |
| 86 | - public function writeCommand(): void |
|
| 87 | - { |
|
| 88 | - $this->initDataBag(); |
|
| 89 | - if($this->xDataBag->touched()) |
|
| 90 | - { |
|
| 91 | - // Todo: calculate the checksums. |
|
| 92 | - $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
|
| 93 | - } |
|
| 94 | - } |
|
| 86 | +public function writeCommand(): void |
|
| 87 | +{ |
|
| 88 | +$this->initDataBag(); |
|
| 89 | +if($this->xDataBag->touched()) |
|
| 90 | +{ |
|
| 91 | +// Todo: calculate the checksums. |
|
| 92 | +$this->addCommand('databag.set', ['values' => $this->xDataBag]); |
|
| 93 | +} |
|
| 94 | +} |
|
| 95 | 95 | |
| 96 | - /** |
|
| 96 | +/** |
|
| 97 | 97 | * @param string $sName |
| 98 | 98 | * |
| 99 | 99 | * @return DataBagContext |
| 100 | 100 | */ |
| 101 | - public function bag(string $sName): DataBagContext |
|
| 102 | - { |
|
| 103 | - $this->initDataBag(); |
|
| 104 | - return new DataBagContext($this->xDataBag, $sName); |
|
| 105 | - } |
|
| 101 | +public function bag(string $sName): DataBagContext |
|
| 102 | +{ |
|
| 103 | +$this->initDataBag(); |
|
| 104 | +return new DataBagContext($this->xDataBag, $sName); |
|
| 105 | +} |
|
| 106 | 106 | } |
@@ -18,43 +18,43 @@ |
||
| 18 | 18 | |
| 19 | 19 | abstract class AbstractCodeGenerator implements CodeGeneratorInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 21 | +/** |
|
| 22 | 22 | * @inheritDoc |
| 23 | 23 | */ |
| 24 | - public function getHash(): string |
|
| 25 | - { |
|
| 26 | - return ''; |
|
| 27 | - } |
|
| 24 | +public function getHash(): string |
|
| 25 | +{ |
|
| 26 | +return ''; |
|
| 27 | +} |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * @inheritDoc |
| 31 | 31 | */ |
| 32 | - public function getCss(): string |
|
| 33 | - { |
|
| 34 | - return ''; |
|
| 35 | - } |
|
| 32 | +public function getCss(): string |
|
| 33 | +{ |
|
| 34 | +return ''; |
|
| 35 | +} |
|
| 36 | 36 | |
| 37 | - /** |
|
| 37 | +/** |
|
| 38 | 38 | * @inheritDoc |
| 39 | 39 | */ |
| 40 | - public function getJs(): string |
|
| 41 | - { |
|
| 42 | - return ''; |
|
| 43 | - } |
|
| 40 | +public function getJs(): string |
|
| 41 | +{ |
|
| 42 | +return ''; |
|
| 43 | +} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * @inheritDoc |
| 47 | 47 | */ |
| 48 | - public function getScript(): string |
|
| 49 | - { |
|
| 50 | - return ''; |
|
| 51 | - } |
|
| 48 | +public function getScript(): string |
|
| 49 | +{ |
|
| 50 | +return ''; |
|
| 51 | +} |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * @inheritDoc |
| 55 | 55 | */ |
| 56 | - public function getJsCode(): ?JsCode |
|
| 57 | - { |
|
| 58 | - return null; |
|
| 59 | - } |
|
| 56 | +public function getJsCode(): ?JsCode |
|
| 57 | +{ |
|
| 58 | +return null; |
|
| 59 | +} |
|
| 60 | 60 | } |
@@ -31,48 +31,48 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | trait ResponsePluginTrait |
| 33 | 33 | { |
| 34 | - /** |
|
| 34 | +/** |
|
| 35 | 35 | * The object used to build the response that will be sent to the client browser |
| 36 | 36 | * |
| 37 | 37 | * @var AbstractResponse |
| 38 | 38 | */ |
| 39 | - private $xResponse = null; |
|
| 39 | +private $xResponse = null; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 41 | +/** |
|
| 42 | 42 | * Get a unique name to identify the plugin. |
| 43 | 43 | * |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - abstract public function getName(): string; |
|
| 46 | +abstract public function getName(): string; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 48 | +/** |
|
| 49 | 49 | * Initialize the plugin |
| 50 | 50 | * |
| 51 | 51 | * @return void |
| 52 | 52 | */ |
| 53 | - abstract protected function init(); |
|
| 53 | +abstract protected function init(); |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * @param AbstractResponse $xResponse The response |
| 57 | 57 | * |
| 58 | 58 | * @return static |
| 59 | 59 | */ |
| 60 | - public function initPlugin(AbstractResponse $xResponse): static |
|
| 61 | - { |
|
| 62 | - $this->xResponse = $xResponse; |
|
| 63 | - $this->init(); |
|
| 64 | - return $this; |
|
| 65 | - } |
|
| 60 | +public function initPlugin(AbstractResponse $xResponse): static |
|
| 61 | +{ |
|
| 62 | +$this->xResponse = $xResponse; |
|
| 63 | +$this->init(); |
|
| 64 | +return $this; |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * @inheritDoc |
| 69 | 69 | */ |
| 70 | - public function response(): ?AbstractResponse |
|
| 71 | - { |
|
| 72 | - return $this->xResponse; |
|
| 73 | - } |
|
| 70 | +public function response(): ?AbstractResponse |
|
| 71 | +{ |
|
| 72 | +return $this->xResponse; |
|
| 73 | +} |
|
| 74 | 74 | |
| 75 | - /** |
|
| 75 | +/** |
|
| 76 | 76 | * Add a plugin command to the response |
| 77 | 77 | * |
| 78 | 78 | * @param string $sName The command name |
@@ -80,10 +80,10 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return Command |
| 82 | 82 | */ |
| 83 | - public function addCommand(string $sName, array|JsonSerializable $aOptions): Command |
|
| 84 | - { |
|
| 85 | - return $this->xResponse |
|
| 86 | - ->addCommand($sName, $aOptions) |
|
| 87 | - ->setOption('plugin', $this->getName()); |
|
| 88 | - } |
|
| 83 | +public function addCommand(string $sName, array|JsonSerializable $aOptions): Command |
|
| 84 | +{ |
|
| 85 | +return $this->xResponse |
|
| 86 | +->addCommand($sName, $aOptions) |
|
| 87 | +->setOption('plugin', $this->getName()); |
|
| 88 | +} |
|
| 89 | 89 | } |
@@ -17,46 +17,46 @@ |
||
| 17 | 17 | |
| 18 | 18 | interface CodeGeneratorInterface |
| 19 | 19 | { |
| 20 | - /** |
|
| 20 | +/** |
|
| 21 | 21 | * Get the value to be hashed |
| 22 | 22 | * |
| 23 | 23 | * @return string |
| 24 | 24 | */ |
| 25 | - public function getHash(): string; |
|
| 25 | +public function getHash(): string; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * Get the HTML tags to include CSS code and files into the page |
| 29 | 29 | * |
| 30 | 30 | * The code must be enclosed in the appropriate HTML tags. |
| 31 | 31 | * |
| 32 | 32 | * @return string |
| 33 | 33 | */ |
| 34 | - public function getCss(): string; |
|
| 34 | +public function getCss(): string; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 36 | +/** |
|
| 37 | 37 | * Get the HTML tags to include javascript code and files into the page |
| 38 | 38 | * |
| 39 | 39 | * The code must be enclosed in the appropriate HTML tags. |
| 40 | 40 | * |
| 41 | 41 | * @return string |
| 42 | 42 | */ |
| 43 | - public function getJs(): string; |
|
| 43 | +public function getJs(): string; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * Get the javascript code to include into the page |
| 47 | 47 | * |
| 48 | 48 | * The code must NOT be enclosed in HTML tags. |
| 49 | 49 | * |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function getScript(): string; |
|
| 52 | +public function getScript(): string; |
|
| 53 | 53 | |
| 54 | - /** |
|
| 54 | +/** |
|
| 55 | 55 | * Get the javascript codes to include into the page |
| 56 | 56 | * |
| 57 | 57 | * The code must NOT be enclosed in HTML tags. |
| 58 | 58 | * |
| 59 | 59 | * @return JsCode|null |
| 60 | 60 | */ |
| 61 | - public function getJsCode(): ?JsCode; |
|
| 61 | +public function getJsCode(): ?JsCode; |
|
| 62 | 62 | } |
@@ -42,21 +42,21 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | class CallableFunctionPlugin extends AbstractRequestPlugin |
| 44 | 44 | { |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * The registered functions names |
| 47 | 47 | * |
| 48 | 48 | * @var array |
| 49 | 49 | */ |
| 50 | - protected $aFunctions = []; |
|
| 50 | +protected $aFunctions = []; |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | +/** |
|
| 53 | 53 | * The registered functions options |
| 54 | 54 | * |
| 55 | 55 | * @var array |
| 56 | 56 | */ |
| 57 | - protected $aOptions = []; |
|
| 57 | +protected $aOptions = []; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * The constructor |
| 61 | 61 | * |
| 62 | 62 | * @param string $sPrefix |
@@ -66,41 +66,41 @@ discard block |
||
| 66 | 66 | * @param Translator $xTranslator |
| 67 | 67 | * @param Validator $xValidator |
| 68 | 68 | */ |
| 69 | - public function __construct(private string $sPrefix, private bool $bDebug, |
|
| 70 | - private Container $di, private TemplateEngine $xTemplateEngine, |
|
| 71 | - private Translator $xTranslator, private Validator $xValidator) |
|
| 72 | - {} |
|
| 69 | +public function __construct(private string $sPrefix, private bool $bDebug, |
|
| 70 | +private Container $di, private TemplateEngine $xTemplateEngine, |
|
| 71 | +private Translator $xTranslator, private Validator $xValidator) |
|
| 72 | +{} |
|
| 73 | 73 | |
| 74 | - /** |
|
| 74 | +/** |
|
| 75 | 75 | * @inheritDoc |
| 76 | 76 | */ |
| 77 | - public function getName(): string |
|
| 78 | - { |
|
| 79 | - return Jaxon::CALLABLE_FUNCTION; |
|
| 80 | - } |
|
| 77 | +public function getName(): string |
|
| 78 | +{ |
|
| 79 | +return Jaxon::CALLABLE_FUNCTION; |
|
| 80 | +} |
|
| 81 | 81 | |
| 82 | - /** |
|
| 82 | +/** |
|
| 83 | 83 | * @inheritDoc |
| 84 | 84 | * @throws SetupException |
| 85 | 85 | */ |
| 86 | - public function checkOptions(string $sCallable, $xOptions): array |
|
| 87 | - { |
|
| 88 | - if(!$this->xValidator->validateFunction(trim($sCallable))) |
|
| 89 | - { |
|
| 90 | - throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
|
| 91 | - } |
|
| 92 | - if(is_string($xOptions)) |
|
| 93 | - { |
|
| 94 | - $xOptions = ['include' => $xOptions]; |
|
| 95 | - } |
|
| 96 | - elseif(!is_array($xOptions)) |
|
| 97 | - { |
|
| 98 | - throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
|
| 99 | - } |
|
| 100 | - return $xOptions; |
|
| 101 | - } |
|
| 86 | +public function checkOptions(string $sCallable, $xOptions): array |
|
| 87 | +{ |
|
| 88 | +if(!$this->xValidator->validateFunction(trim($sCallable))) |
|
| 89 | +{ |
|
| 90 | +throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
|
| 91 | +} |
|
| 92 | +if(is_string($xOptions)) |
|
| 93 | +{ |
|
| 94 | +$xOptions = ['include' => $xOptions]; |
|
| 95 | +} |
|
| 96 | +elseif(!is_array($xOptions)) |
|
| 97 | +{ |
|
| 98 | +throw new SetupException($this->xTranslator->trans('errors.objects.invalid-declaration')); |
|
| 99 | +} |
|
| 100 | +return $xOptions; |
|
| 101 | +} |
|
| 102 | 102 | |
| 103 | - /** |
|
| 103 | +/** |
|
| 104 | 104 | * Register a user defined function |
| 105 | 105 | * |
| 106 | 106 | * @param string $sType The type of request handler being registered |
@@ -109,149 +109,149 @@ discard block |
||
| 109 | 109 | * |
| 110 | 110 | * @return bool |
| 111 | 111 | */ |
| 112 | - public function register(string $sType, string $sCallable, array $aOptions): bool |
|
| 113 | - { |
|
| 114 | - $sPhpFunction = trim($sCallable); |
|
| 115 | - $sFunction = $sPhpFunction; |
|
| 116 | - // Check if an alias is defined |
|
| 117 | - if(isset($aOptions['alias'])) |
|
| 118 | - { |
|
| 119 | - $sFunction = (string)$aOptions['alias']; |
|
| 120 | - unset($aOptions['alias']); |
|
| 121 | - } |
|
| 122 | - $this->aFunctions[$sFunction] = $sPhpFunction; |
|
| 123 | - $this->aOptions[$sFunction] = $aOptions; |
|
| 124 | - return true; |
|
| 125 | - } |
|
| 112 | +public function register(string $sType, string $sCallable, array $aOptions): bool |
|
| 113 | +{ |
|
| 114 | +$sPhpFunction = trim($sCallable); |
|
| 115 | +$sFunction = $sPhpFunction; |
|
| 116 | +// Check if an alias is defined |
|
| 117 | +if(isset($aOptions['alias'])) |
|
| 118 | +{ |
|
| 119 | +$sFunction = (string)$aOptions['alias']; |
|
| 120 | +unset($aOptions['alias']); |
|
| 121 | +} |
|
| 122 | +$this->aFunctions[$sFunction] = $sPhpFunction; |
|
| 123 | +$this->aOptions[$sFunction] = $aOptions; |
|
| 124 | +return true; |
|
| 125 | +} |
|
| 126 | 126 | |
| 127 | - /** |
|
| 127 | +/** |
|
| 128 | 128 | * @inheritDoc |
| 129 | 129 | */ |
| 130 | - public function getHash(): string |
|
| 131 | - { |
|
| 132 | - return md5(implode('', array_keys($this->aFunctions))); |
|
| 133 | - } |
|
| 130 | +public function getHash(): string |
|
| 131 | +{ |
|
| 132 | +return md5(implode('', array_keys($this->aFunctions))); |
|
| 133 | +} |
|
| 134 | 134 | |
| 135 | - /** |
|
| 135 | +/** |
|
| 136 | 136 | * @inheritDoc |
| 137 | 137 | */ |
| 138 | - public function getCallable(string $sCallable): CallableFunction|null |
|
| 139 | - { |
|
| 140 | - $sFunction = trim($sCallable); |
|
| 141 | - if(!isset($this->aFunctions[$sFunction])) |
|
| 142 | - { |
|
| 143 | - return null; |
|
| 144 | - } |
|
| 145 | - $xCallable = new CallableFunction($this->di, $sFunction, |
|
| 146 | - $this->sPrefix . $sFunction, $this->aFunctions[$sFunction]); |
|
| 147 | - foreach($this->aOptions[$sFunction] as $sName => $sValue) |
|
| 148 | - { |
|
| 149 | - $xCallable->configure($sName, $sValue); |
|
| 150 | - } |
|
| 151 | - return $xCallable; |
|
| 152 | - } |
|
| 138 | +public function getCallable(string $sCallable): CallableFunction|null |
|
| 139 | +{ |
|
| 140 | +$sFunction = trim($sCallable); |
|
| 141 | +if(!isset($this->aFunctions[$sFunction])) |
|
| 142 | +{ |
|
| 143 | +return null; |
|
| 144 | +} |
|
| 145 | +$xCallable = new CallableFunction($this->di, $sFunction, |
|
| 146 | +$this->sPrefix . $sFunction, $this->aFunctions[$sFunction]); |
|
| 147 | +foreach($this->aOptions[$sFunction] as $sName => $sValue) |
|
| 148 | +{ |
|
| 149 | +$xCallable->configure($sName, $sValue); |
|
| 150 | +} |
|
| 151 | +return $xCallable; |
|
| 152 | +} |
|
| 153 | 153 | |
| 154 | - /** |
|
| 154 | +/** |
|
| 155 | 155 | * Generate the javascript function stub that is sent to the browser on initial page load |
| 156 | 156 | * |
| 157 | 157 | * @param CallableFunction $xFunction |
| 158 | 158 | * |
| 159 | 159 | * @return string |
| 160 | 160 | */ |
| 161 | - private function getCallableScript(CallableFunction $xFunction): string |
|
| 162 | - { |
|
| 163 | - return $this->xTemplateEngine->render('jaxon::callables/function.js', [ |
|
| 164 | - 'sName' => $xFunction->getName(), |
|
| 165 | - 'sJsName' => $xFunction->getJsName(), |
|
| 166 | - 'aOptions' => $xFunction->getOptions(), |
|
| 167 | - ]); |
|
| 168 | - } |
|
| 161 | +private function getCallableScript(CallableFunction $xFunction): string |
|
| 162 | +{ |
|
| 163 | +return $this->xTemplateEngine->render('jaxon::callables/function.js', [ |
|
| 164 | +'sName' => $xFunction->getName(), |
|
| 165 | +'sJsName' => $xFunction->getJsName(), |
|
| 166 | +'aOptions' => $xFunction->getOptions(), |
|
| 167 | +]); |
|
| 168 | +} |
|
| 169 | 169 | |
| 170 | - /** |
|
| 170 | +/** |
|
| 171 | 171 | * @inheritDoc |
| 172 | 172 | */ |
| 173 | - public function getScript(): string |
|
| 174 | - { |
|
| 175 | - $code = ''; |
|
| 176 | - foreach(array_keys($this->aFunctions) as $sFunction) |
|
| 177 | - { |
|
| 178 | - $xFunction = $this->getCallable($sFunction); |
|
| 179 | - $code .= $this->getCallableScript($xFunction); |
|
| 180 | - } |
|
| 181 | - return $code; |
|
| 182 | - } |
|
| 173 | +public function getScript(): string |
|
| 174 | +{ |
|
| 175 | +$code = ''; |
|
| 176 | +foreach(array_keys($this->aFunctions) as $sFunction) |
|
| 177 | +{ |
|
| 178 | +$xFunction = $this->getCallable($sFunction); |
|
| 179 | +$code .= $this->getCallableScript($xFunction); |
|
| 180 | +} |
|
| 181 | +return $code; |
|
| 182 | +} |
|
| 183 | 183 | |
| 184 | - /** |
|
| 184 | +/** |
|
| 185 | 185 | * @inheritDoc |
| 186 | 186 | */ |
| 187 | - public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
|
| 188 | - { |
|
| 189 | - $aCall = $xRequest->getAttribute('jxncall'); |
|
| 190 | - // throw new \Exception(json_encode(['call' => $aCall])); |
|
| 191 | - return $aCall !== null && ($aCall['type'] ?? '') === 'func' && isset($aCall['name']); |
|
| 192 | - } |
|
| 187 | +public static function canProcessRequest(ServerRequestInterface $xRequest): bool |
|
| 188 | +{ |
|
| 189 | +$aCall = $xRequest->getAttribute('jxncall'); |
|
| 190 | +// throw new \Exception(json_encode(['call' => $aCall])); |
|
| 191 | +return $aCall !== null && ($aCall['type'] ?? '') === 'func' && isset($aCall['name']); |
|
| 192 | +} |
|
| 193 | 193 | |
| 194 | - /** |
|
| 194 | +/** |
|
| 195 | 195 | * @inheritDoc |
| 196 | 196 | */ |
| 197 | - public function setTarget(ServerRequestInterface $xRequest): Target |
|
| 198 | - { |
|
| 199 | - $aCall = $xRequest->getAttribute('jxncall'); |
|
| 200 | - $this->xTarget = Target::makeFunction(trim($aCall['name'])); |
|
| 201 | - return $this->xTarget; |
|
| 202 | - } |
|
| 197 | +public function setTarget(ServerRequestInterface $xRequest): Target |
|
| 198 | +{ |
|
| 199 | +$aCall = $xRequest->getAttribute('jxncall'); |
|
| 200 | +$this->xTarget = Target::makeFunction(trim($aCall['name'])); |
|
| 201 | +return $this->xTarget; |
|
| 202 | +} |
|
| 203 | 203 | |
| 204 | - /** |
|
| 204 | +/** |
|
| 205 | 205 | * @param Exception $xException |
| 206 | 206 | * @param string $sErrorMessage |
| 207 | 207 | * |
| 208 | 208 | * @throws RequestException |
| 209 | 209 | * @return void |
| 210 | 210 | */ |
| 211 | - private function throwException(Exception $xException, string $sErrorMessage): void |
|
| 212 | - { |
|
| 213 | - $this->di->getLogger()->error($xException->getMessage()); |
|
| 214 | - throw new RequestException($sErrorMessage . (!$this->bDebug ? '' : |
|
| 215 | - "\n" . $xException->getMessage())); |
|
| 216 | - } |
|
| 211 | +private function throwException(Exception $xException, string $sErrorMessage): void |
|
| 212 | +{ |
|
| 213 | +$this->di->getLogger()->error($xException->getMessage()); |
|
| 214 | +throw new RequestException($sErrorMessage . (!$this->bDebug ? '' : |
|
| 215 | +"\n" . $xException->getMessage())); |
|
| 216 | +} |
|
| 217 | 217 | |
| 218 | - /** |
|
| 218 | +/** |
|
| 219 | 219 | * @inheritDoc |
| 220 | 220 | * @throws RequestException |
| 221 | 221 | */ |
| 222 | - public function processRequest(): void |
|
| 223 | - { |
|
| 224 | - $sRequestedFunction = $this->xTarget->getFunctionName(); |
|
| 222 | +public function processRequest(): void |
|
| 223 | +{ |
|
| 224 | +$sRequestedFunction = $this->xTarget->getFunctionName(); |
|
| 225 | 225 | |
| 226 | - // Security check: make sure the requested function was registered. |
|
| 227 | - if(!$this->xValidator->validateFunction($sRequestedFunction) || |
|
| 228 | - !isset($this->aFunctions[$sRequestedFunction])) |
|
| 229 | - { |
|
| 230 | - // Unable to find the requested function |
|
| 231 | - throw new RequestException($this->xTranslator->trans('errors.functions.invalid', |
|
| 232 | - ['name' => $sRequestedFunction])); |
|
| 233 | - } |
|
| 226 | +// Security check: make sure the requested function was registered. |
|
| 227 | +if(!$this->xValidator->validateFunction($sRequestedFunction) || |
|
| 228 | +!isset($this->aFunctions[$sRequestedFunction])) |
|
| 229 | +{ |
|
| 230 | +// Unable to find the requested function |
|
| 231 | +throw new RequestException($this->xTranslator->trans('errors.functions.invalid', |
|
| 232 | + ['name' => $sRequestedFunction])); |
|
| 233 | +} |
|
| 234 | 234 | |
| 235 | - try |
|
| 236 | - { |
|
| 237 | - /** @var CallableFunction */ |
|
| 238 | - $xFunction = $this->getCallable($sRequestedFunction); |
|
| 239 | - } |
|
| 240 | - catch(Exception $e) |
|
| 241 | - { |
|
| 242 | - // Unable to find the requested function |
|
| 243 | - $this->throwException($e, $this->xTranslator->trans('errors.functions.invalid', |
|
| 244 | - ['name' => $sRequestedFunction])); |
|
| 245 | - } |
|
| 246 | - try |
|
| 247 | - { |
|
| 248 | - $xFunction->call($this->xTarget->args()); |
|
| 249 | - } |
|
| 250 | - catch(Exception $e) |
|
| 251 | - { |
|
| 252 | - // Unable to execute the requested function |
|
| 253 | - $this->throwException($e, $this->xTranslator->trans('errors.functions.call', |
|
| 254 | - ['name' => $sRequestedFunction])); |
|
| 255 | - } |
|
| 256 | - } |
|
| 235 | +try |
|
| 236 | +{ |
|
| 237 | +/** @var CallableFunction */ |
|
| 238 | +$xFunction = $this->getCallable($sRequestedFunction); |
|
| 239 | +} |
|
| 240 | +catch(Exception $e) |
|
| 241 | +{ |
|
| 242 | +// Unable to find the requested function |
|
| 243 | +$this->throwException($e, $this->xTranslator->trans('errors.functions.invalid', |
|
| 244 | + ['name' => $sRequestedFunction])); |
|
| 245 | +} |
|
| 246 | +try |
|
| 247 | +{ |
|
| 248 | +$xFunction->call($this->xTarget->args()); |
|
| 249 | +} |
|
| 250 | +catch(Exception $e) |
|
| 251 | +{ |
|
| 252 | +// Unable to execute the requested function |
|
| 253 | +$this->throwException($e, $this->xTranslator->trans('errors.functions.call', |
|
| 254 | + ['name' => $sRequestedFunction])); |
|
| 255 | +} |
|
| 256 | +} |
|
| 257 | 257 | } |
@@ -28,29 +28,29 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | class CallableFunction |
| 30 | 30 | { |
| 31 | - /** |
|
| 31 | +/** |
|
| 32 | 32 | * A string or an array which defines the registered PHP function |
| 33 | 33 | * |
| 34 | 34 | * @var string|array |
| 35 | 35 | */ |
| 36 | - private $xPhpFunction; |
|
| 36 | +private $xPhpFunction; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 38 | +/** |
|
| 39 | 39 | * The path and file name of the include file where the function is defined |
| 40 | 40 | * |
| 41 | 41 | * @var string |
| 42 | 42 | */ |
| 43 | - private $sInclude = ''; |
|
| 43 | +private $sInclude = ''; |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * An associative array containing call options that will be sent |
| 47 | 47 | * to the browser with the client script. |
| 48 | 48 | * |
| 49 | 49 | * @var array |
| 50 | 50 | */ |
| 51 | - private $aOptions = []; |
|
| 51 | +private $aOptions = []; |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * The constructor |
| 55 | 55 | * |
| 56 | 56 | * @param Container $di |
@@ -58,43 +58,43 @@ discard block |
||
| 58 | 58 | * @param string $sJsFunction |
| 59 | 59 | * @param string $sPhpFunction |
| 60 | 60 | */ |
| 61 | - public function __construct(private Container $di, private string $sFunction, |
|
| 62 | - private string $sJsFunction, string $sPhpFunction) |
|
| 63 | - { |
|
| 64 | - $this->xPhpFunction = $sPhpFunction; |
|
| 65 | - } |
|
| 61 | +public function __construct(private Container $di, private string $sFunction, |
|
| 62 | +private string $sJsFunction, string $sPhpFunction) |
|
| 63 | +{ |
|
| 64 | +$this->xPhpFunction = $sPhpFunction; |
|
| 65 | +} |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | +/** |
|
| 68 | 68 | * Get the name of the function being referenced |
| 69 | 69 | * |
| 70 | 70 | * @return string |
| 71 | 71 | */ |
| 72 | - public function getName(): string |
|
| 73 | - { |
|
| 74 | - return $this->sFunction; |
|
| 75 | - } |
|
| 72 | +public function getName(): string |
|
| 73 | +{ |
|
| 74 | +return $this->sFunction; |
|
| 75 | +} |
|
| 76 | 76 | |
| 77 | - /** |
|
| 77 | +/** |
|
| 78 | 78 | * Get name of the corresponding javascript function |
| 79 | 79 | * |
| 80 | 80 | * @return string |
| 81 | 81 | */ |
| 82 | - public function getJsName(): string |
|
| 83 | - { |
|
| 84 | - return $this->sJsFunction; |
|
| 85 | - } |
|
| 82 | +public function getJsName(): string |
|
| 83 | +{ |
|
| 84 | +return $this->sJsFunction; |
|
| 85 | +} |
|
| 86 | 86 | |
| 87 | - /** |
|
| 87 | +/** |
|
| 88 | 88 | * Get the config options of the function being referenced |
| 89 | 89 | * |
| 90 | 90 | * @return array |
| 91 | 91 | */ |
| 92 | - public function getOptions(): array |
|
| 93 | - { |
|
| 94 | - return $this->aOptions; |
|
| 95 | - } |
|
| 92 | +public function getOptions(): array |
|
| 93 | +{ |
|
| 94 | +return $this->aOptions; |
|
| 95 | +} |
|
| 96 | 96 | |
| 97 | - /** |
|
| 97 | +/** |
|
| 98 | 98 | * Set call options for this instance |
| 99 | 99 | * |
| 100 | 100 | * @param string $sName The name of the configuration option |
@@ -102,20 +102,20 @@ discard block |
||
| 102 | 102 | * |
| 103 | 103 | * @return void |
| 104 | 104 | */ |
| 105 | - public function configure(string $sName, string $sValue): void |
|
| 106 | - { |
|
| 107 | - switch($sName) |
|
| 108 | - { |
|
| 109 | - case 'class': // The user function is a method in the given class |
|
| 110 | - $this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
| 111 | - break; |
|
| 112 | - case 'include': |
|
| 113 | - $this->sInclude = $sValue; |
|
| 114 | - break; |
|
| 115 | - default: |
|
| 116 | - $this->aOptions[$sName] = $sValue; |
|
| 117 | - break; |
|
| 118 | - } |
|
| 105 | +public function configure(string $sName, string $sValue): void |
|
| 106 | +{ |
|
| 107 | +switch($sName) |
|
| 108 | +{ |
|
| 109 | +case 'class': // The user function is a method in the given class |
|
| 110 | +$this->xPhpFunction = [$sValue, $this->xPhpFunction]; |
|
| 111 | +break; |
|
| 112 | +case 'include': |
|
| 113 | +$this->sInclude = $sValue; |
|
| 114 | +break; |
|
| 115 | +default: |
|
| 116 | +$this->aOptions[$sName] = $sValue; |
|
| 117 | +break; |
|
| 118 | +} |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -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\App\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\App\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 99 | +} |
|
| 100 | 100 | } |
@@ -16,382 +16,382 @@ |
||
| 16 | 16 | |
| 17 | 17 | class AnnotationTest 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(Annotated::class, ['saveFiles', 'doNot']); |
|
| 66 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 67 | - $aProperties = $xMetadata->getProperties(); |
|
| 68 | - $aProtected = $xMetadata->getProtectedMethods(); |
|
| 63 | +public function testUploadAndExcludeAnnotation() |
|
| 64 | +{ |
|
| 65 | +$xMetadata = $this->getAttributes(Annotated::class, ['saveFiles', 'doNot']); |
|
| 66 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 67 | +$aProperties = $xMetadata->getProperties(); |
|
| 68 | +$aProtected = $xMetadata->getProtectedMethods(); |
|
| 69 | 69 | |
| 70 | - $this->assertFalse($bExcluded); |
|
| 70 | +$this->assertFalse($bExcluded); |
|
| 71 | 71 | |
| 72 | - $this->assertCount(1, $aProperties); |
|
| 73 | - $this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 74 | - $this->assertCount(1, $aProperties['saveFiles']); |
|
| 75 | - $this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 72 | +$this->assertCount(1, $aProperties); |
|
| 73 | +$this->assertArrayHasKey('saveFiles', $aProperties); |
|
| 74 | +$this->assertCount(1, $aProperties['saveFiles']); |
|
| 75 | +$this->assertEquals("'user-files'", $aProperties['saveFiles']['upload']); |
|
| 76 | 76 | |
| 77 | - $this->assertCount(1, $aProtected); |
|
| 78 | - $this->assertEquals('doNot', $aProtected[0]); |
|
| 79 | - } |
|
| 77 | +$this->assertCount(1, $aProtected); |
|
| 78 | +$this->assertEquals('doNot', $aProtected[0]); |
|
| 79 | +} |
|
| 80 | 80 | |
| 81 | - /** |
|
| 81 | +/** |
|
| 82 | 82 | * @throws SetupException |
| 83 | 83 | */ |
| 84 | - public function testDataBagAnnotation() |
|
| 85 | - { |
|
| 86 | - $xMetadata = $this->getAttributes(Annotated::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(Annotated::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 testServerCallbacksAnnotation() |
|
| 104 | - { |
|
| 105 | - $xMetadata = $this->getAttributes(Annotated::class, |
|
| 106 | - ['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 107 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 108 | - $aProperties = $xMetadata->getProperties(); |
|
| 109 | - |
|
| 110 | - $this->assertFalse($bExcluded); |
|
| 111 | - |
|
| 112 | - $this->assertCount(3, $aProperties); |
|
| 113 | - $this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 114 | - $this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 115 | - $this->assertArrayHasKey('cbParams', $aProperties); |
|
| 116 | - |
|
| 117 | - $this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 118 | - $this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 119 | - $this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 120 | - $this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 121 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 122 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 123 | - $this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 124 | - $this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 125 | - $this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 126 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 127 | - $this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 128 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 129 | - $this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 130 | - |
|
| 131 | - $this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 132 | - $this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 133 | - $this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 134 | - $this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 135 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 136 | - $this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 137 | - $this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 138 | - $this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 139 | - $this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 140 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 141 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 142 | - $this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 143 | - $this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 103 | +public function testServerCallbacksAnnotation() |
|
| 104 | +{ |
|
| 105 | +$xMetadata = $this->getAttributes(Annotated::class, |
|
| 106 | +['cbSingle', 'cbMultiple', 'cbParams']); |
|
| 107 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 108 | +$aProperties = $xMetadata->getProperties(); |
|
| 109 | + |
|
| 110 | +$this->assertFalse($bExcluded); |
|
| 111 | + |
|
| 112 | +$this->assertCount(3, $aProperties); |
|
| 113 | +$this->assertArrayHasKey('cbSingle', $aProperties); |
|
| 114 | +$this->assertArrayHasKey('cbMultiple', $aProperties); |
|
| 115 | +$this->assertArrayHasKey('cbParams', $aProperties); |
|
| 116 | + |
|
| 117 | +$this->assertCount(1, $aProperties['cbSingle']['__before']); |
|
| 118 | +$this->assertCount(2, $aProperties['cbMultiple']['__before']); |
|
| 119 | +$this->assertCount(2, $aProperties['cbParams']['__before']); |
|
| 120 | +$this->assertArrayHasKey('funcBefore', $aProperties['cbSingle']['__before']); |
|
| 121 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbMultiple']['__before']); |
|
| 122 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbMultiple']['__before']); |
|
| 123 | +$this->assertArrayHasKey('funcBefore1', $aProperties['cbParams']['__before']); |
|
| 124 | +$this->assertArrayHasKey('funcBefore2', $aProperties['cbParams']['__before']); |
|
| 125 | +$this->assertIsArray($aProperties['cbSingle']['__before']['funcBefore']); |
|
| 126 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore1']); |
|
| 127 | +$this->assertIsArray($aProperties['cbMultiple']['__before']['funcBefore2']); |
|
| 128 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore1']); |
|
| 129 | +$this->assertIsArray($aProperties['cbParams']['__before']['funcBefore2']); |
|
| 130 | + |
|
| 131 | +$this->assertCount(1, $aProperties['cbSingle']['__after']); |
|
| 132 | +$this->assertCount(3, $aProperties['cbMultiple']['__after']); |
|
| 133 | +$this->assertCount(1, $aProperties['cbParams']['__after']); |
|
| 134 | +$this->assertArrayHasKey('funcAfter', $aProperties['cbSingle']['__after']); |
|
| 135 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbMultiple']['__after']); |
|
| 136 | +$this->assertArrayHasKey('funcAfter2', $aProperties['cbMultiple']['__after']); |
|
| 137 | +$this->assertArrayHasKey('funcAfter3', $aProperties['cbMultiple']['__after']); |
|
| 138 | +$this->assertArrayHasKey('funcAfter1', $aProperties['cbParams']['__after']); |
|
| 139 | +$this->assertIsArray($aProperties['cbSingle']['__after']['funcAfter']); |
|
| 140 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter1']); |
|
| 141 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter2']); |
|
| 142 | +$this->assertIsArray($aProperties['cbMultiple']['__after']['funcAfter3']); |
|
| 143 | +$this->assertIsArray($aProperties['cbParams']['__after']['funcAfter1']); |
|
| 144 | +} |
|
| 145 | + |
|
| 146 | +/** |
|
| 147 | 147 | * @throws SetupException |
| 148 | 148 | */ |
| 149 | - public function testContainerAnnotation() |
|
| 150 | - { |
|
| 151 | - $xMetadata = $this->getAttributes(Annotated::class, ['di1', 'di2']); |
|
| 152 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 153 | - $aProperties = $xMetadata->getProperties(); |
|
| 154 | - |
|
| 155 | - $this->assertFalse($bExcluded); |
|
| 156 | - |
|
| 157 | - $this->assertCount(2, $aProperties); |
|
| 158 | - $this->assertArrayHasKey('di1', $aProperties); |
|
| 159 | - $this->assertArrayHasKey('di2', $aProperties); |
|
| 160 | - $this->assertCount(2, $aProperties['di1']['__di']); |
|
| 161 | - $this->assertCount(2, $aProperties['di2']['__di']); |
|
| 162 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 163 | - $this->assertEquals('Jaxon\Annotations\Tests\App\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 164 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 165 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - /** |
|
| 149 | +public function testContainerAnnotation() |
|
| 150 | +{ |
|
| 151 | +$xMetadata = $this->getAttributes(Annotated::class, ['di1', 'di2']); |
|
| 152 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 153 | +$aProperties = $xMetadata->getProperties(); |
|
| 154 | + |
|
| 155 | +$this->assertFalse($bExcluded); |
|
| 156 | + |
|
| 157 | +$this->assertCount(2, $aProperties); |
|
| 158 | +$this->assertArrayHasKey('di1', $aProperties); |
|
| 159 | +$this->assertArrayHasKey('di2', $aProperties); |
|
| 160 | +$this->assertCount(2, $aProperties['di1']['__di']); |
|
| 161 | +$this->assertCount(2, $aProperties['di2']['__di']); |
|
| 162 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di1']['__di']['colorService']); |
|
| 163 | +$this->assertEquals('Jaxon\Annotations\Tests\App\Ajax\FontService', $aProperties['di1']['__di']['fontService']); |
|
| 164 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['di2']['__di']['colorService']); |
|
| 165 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['di2']['__di']['textService']); |
|
| 166 | +} |
|
| 167 | + |
|
| 168 | +/** |
|
| 169 | 169 | * @throws SetupException |
| 170 | 170 | */ |
| 171 | - public function testClassAnnotation() |
|
| 172 | - { |
|
| 173 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 174 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 175 | - $aProperties = $xMetadata->getProperties(); |
|
| 176 | - |
|
| 177 | - $this->assertFalse($bExcluded); |
|
| 178 | - |
|
| 179 | - $this->assertCount(1, $aProperties); |
|
| 180 | - $this->assertArrayHasKey('*', $aProperties); |
|
| 181 | - $this->assertCount(5, $aProperties['*']); |
|
| 182 | - $this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 183 | - $this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 184 | - $this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 185 | - $this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 171 | +public function testClassAnnotation() |
|
| 172 | +{ |
|
| 173 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 174 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 175 | +$aProperties = $xMetadata->getProperties(); |
|
| 176 | + |
|
| 177 | +$this->assertFalse($bExcluded); |
|
| 178 | + |
|
| 179 | +$this->assertCount(1, $aProperties); |
|
| 180 | +$this->assertArrayHasKey('*', $aProperties); |
|
| 181 | +$this->assertCount(5, $aProperties['*']); |
|
| 182 | +$this->assertArrayHasKey('bags', $aProperties['*']); |
|
| 183 | +$this->assertArrayHasKey('callback', $aProperties['*']); |
|
| 184 | +$this->assertArrayHasKey('__before', $aProperties['*']); |
|
| 185 | +$this->assertArrayHasKey('__after', $aProperties['*']); |
|
| 186 | +} |
|
| 187 | + |
|
| 188 | +/** |
|
| 189 | 189 | * @throws SetupException |
| 190 | 190 | */ |
| 191 | - public function testClassBagsAnnotation() |
|
| 192 | - { |
|
| 193 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 194 | - $aProperties = $xMetadata->getProperties(); |
|
| 191 | +public function testClassBagsAnnotation() |
|
| 192 | +{ |
|
| 193 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 194 | +$aProperties = $xMetadata->getProperties(); |
|
| 195 | 195 | |
| 196 | - $this->assertCount(2, $aProperties['*']['bags']); |
|
| 197 | - $this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 198 | - $this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 199 | - } |
|
| 196 | +$this->assertCount(2, $aProperties['*']['bags']); |
|
| 197 | +$this->assertEquals('user.name', $aProperties['*']['bags'][0]); |
|
| 198 | +$this->assertEquals('page.number', $aProperties['*']['bags'][1]); |
|
| 199 | +} |
|
| 200 | 200 | |
| 201 | - /** |
|
| 201 | +/** |
|
| 202 | 202 | * @throws SetupException |
| 203 | 203 | */ |
| 204 | - public function testClassCallbackAnnotation() |
|
| 205 | - { |
|
| 206 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 207 | - $aProperties = $xMetadata->getProperties(); |
|
| 204 | +public function testClassCallbackAnnotation() |
|
| 205 | +{ |
|
| 206 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 207 | +$aProperties = $xMetadata->getProperties(); |
|
| 208 | 208 | |
| 209 | - $this->assertIsArray($aProperties['*']['callback']); |
|
| 210 | - $this->assertEquals('jaxon.callback.global', $aProperties['*']['callback'][0]); |
|
| 211 | - } |
|
| 209 | +$this->assertIsArray($aProperties['*']['callback']); |
|
| 210 | +$this->assertEquals('jaxon.callback.global', $aProperties['*']['callback'][0]); |
|
| 211 | +} |
|
| 212 | 212 | |
| 213 | - /** |
|
| 213 | +/** |
|
| 214 | 214 | * @throws SetupException |
| 215 | 215 | */ |
| 216 | - public function testClassBeforeAnnotation() |
|
| 217 | - { |
|
| 218 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 219 | - $aProperties = $xMetadata->getProperties(); |
|
| 220 | - |
|
| 221 | - $this->assertCount(2, $aProperties['*']['__before']); |
|
| 222 | - $this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 223 | - $this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 224 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 225 | - $this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 216 | +public function testClassBeforeAnnotation() |
|
| 217 | +{ |
|
| 218 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 219 | +$aProperties = $xMetadata->getProperties(); |
|
| 220 | + |
|
| 221 | +$this->assertCount(2, $aProperties['*']['__before']); |
|
| 222 | +$this->assertArrayHasKey('funcBefore1', $aProperties['*']['__before']); |
|
| 223 | +$this->assertArrayHasKey('funcBefore2', $aProperties['*']['__before']); |
|
| 224 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore1']); |
|
| 225 | +$this->assertIsArray($aProperties['*']['__before']['funcBefore2']); |
|
| 226 | +} |
|
| 227 | + |
|
| 228 | +/** |
|
| 229 | 229 | * @throws SetupException |
| 230 | 230 | */ |
| 231 | - public function testClassAfterAnnotation() |
|
| 232 | - { |
|
| 233 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 234 | - $aProperties = $xMetadata->getProperties(); |
|
| 235 | - |
|
| 236 | - $this->assertCount(3, $aProperties['*']['__after']); |
|
| 237 | - $this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 238 | - $this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 239 | - $this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 240 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 241 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 242 | - $this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - /** |
|
| 231 | +public function testClassAfterAnnotation() |
|
| 232 | +{ |
|
| 233 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 234 | +$aProperties = $xMetadata->getProperties(); |
|
| 235 | + |
|
| 236 | +$this->assertCount(3, $aProperties['*']['__after']); |
|
| 237 | +$this->assertArrayHasKey('funcAfter1', $aProperties['*']['__after']); |
|
| 238 | +$this->assertArrayHasKey('funcAfter2', $aProperties['*']['__after']); |
|
| 239 | +$this->assertArrayHasKey('funcAfter3', $aProperties['*']['__after']); |
|
| 240 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter1']); |
|
| 241 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter2']); |
|
| 242 | +$this->assertIsArray($aProperties['*']['__after']['funcAfter3']); |
|
| 243 | +} |
|
| 244 | + |
|
| 245 | +/** |
|
| 246 | 246 | * @throws SetupException |
| 247 | 247 | */ |
| 248 | - public function testClassDiAnnotation() |
|
| 249 | - { |
|
| 250 | - $xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 251 | - $aProperties = $xMetadata->getProperties(); |
|
| 252 | - |
|
| 253 | - $this->assertCount(3, $aProperties['*']['__di']); |
|
| 254 | - $this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 255 | - $this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 256 | - $this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 257 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 258 | - $this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 259 | - $this->assertEquals('Jaxon\Annotations\Tests\App\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - /** |
|
| 248 | +public function testClassDiAnnotation() |
|
| 249 | +{ |
|
| 250 | +$xMetadata = $this->getAttributes(ClassAnnotated::class, []); |
|
| 251 | +$aProperties = $xMetadata->getProperties(); |
|
| 252 | + |
|
| 253 | +$this->assertCount(3, $aProperties['*']['__di']); |
|
| 254 | +$this->assertArrayHasKey('colorService', $aProperties['*']['__di']); |
|
| 255 | +$this->assertArrayHasKey('textService', $aProperties['*']['__di']); |
|
| 256 | +$this->assertArrayHasKey('fontService', $aProperties['*']['__di']); |
|
| 257 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\ColorService', $aProperties['*']['__di']['colorService']); |
|
| 258 | +$this->assertEquals('Jaxon\Annotations\Tests\Service\TextService', $aProperties['*']['__di']['textService']); |
|
| 259 | +$this->assertEquals('Jaxon\Annotations\Tests\App\Ajax\FontService', $aProperties['*']['__di']['fontService']); |
|
| 260 | +} |
|
| 261 | + |
|
| 262 | +/** |
|
| 263 | 263 | * @throws SetupException |
| 264 | 264 | */ |
| 265 | - public function testClassExcludeAnnotation() |
|
| 266 | - { |
|
| 267 | - $xMetadata = $this->getAttributes(ClassExcluded::class, |
|
| 268 | - ['doNot', 'withBags', 'cbSingle']); |
|
| 269 | - $bExcluded = $xMetadata->isExcluded(); |
|
| 270 | - $aProperties = $xMetadata->getProperties(); |
|
| 271 | - $aProtected = $xMetadata->getProtectedMethods(); |
|
| 272 | - |
|
| 273 | - $this->assertTrue($bExcluded); |
|
| 274 | - $this->assertEmpty($aProperties); |
|
| 275 | - $this->assertEmpty($aProtected); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - public function testExcludeAnnotationError() |
|
| 279 | - { |
|
| 280 | - $this->expectException(SetupException::class); |
|
| 281 | - $this->getAttributes(Annotated::class, ['doNotError']); |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - public function testDataBagAnnotationError() |
|
| 285 | - { |
|
| 286 | - $this->expectException(SetupException::class); |
|
| 287 | - $this->getAttributes(Annotated::class, ['withBagsError']); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - public function testUploadAnnotationWrongName() |
|
| 291 | - { |
|
| 292 | - $this->expectException(SetupException::class); |
|
| 293 | - $this->getAttributes(Annotated::class, ['saveFilesWrongName']); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - public function testUploadAnnotationMultiple() |
|
| 297 | - { |
|
| 298 | - $this->expectException(SetupException::class); |
|
| 299 | - $this->getAttributes(Annotated::class, ['saveFilesMultiple']); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - public function testCallbacksBeforeAnnotationNoCall() |
|
| 303 | - { |
|
| 304 | - $this->expectException(SetupException::class); |
|
| 305 | - $this->getAttributes(Annotated::class, ['cbBeforeNoCall']); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - public function testCallbacksBeforeAnnotationUnknownAttr() |
|
| 309 | - { |
|
| 310 | - $this->expectException(SetupException::class); |
|
| 311 | - $this->getAttributes(Annotated::class, ['cbBeforeUnknownAttr']); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - public function testCallbacksBeforeAnnotationWrongAttrType() |
|
| 315 | - { |
|
| 316 | - $this->expectException(SetupException::class); |
|
| 317 | - $this->getAttributes(Annotated::class, ['cbBeforeWrongAttrType']); |
|
| 318 | - } |
|
| 319 | - |
|
| 320 | - public function testCallbacksAfterAnnotationNoCall() |
|
| 321 | - { |
|
| 322 | - $this->expectException(SetupException::class); |
|
| 323 | - $this->getAttributes(Annotated::class, ['cbAfterNoCall']); |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - public function testCallbacksAfterAnnotationUnknownAttr() |
|
| 327 | - { |
|
| 328 | - $this->expectException(SetupException::class); |
|
| 329 | - $this->getAttributes(Annotated::class, ['cbAfterUnknownAttr']); |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - public function testCallbacksAfterAnnotationWrongAttrType() |
|
| 333 | - { |
|
| 334 | - $this->expectException(SetupException::class); |
|
| 335 | - $this->getAttributes(Annotated::class, ['cbAfterWrongAttrType']); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - public function testContainerAnnotationUnknownAttr() |
|
| 339 | - { |
|
| 340 | - $this->expectException(SetupException::class); |
|
| 341 | - $this->getAttributes(Annotated::class, ['diUnknownAttr']); |
|
| 342 | - } |
|
| 343 | - |
|
| 344 | - public function testContainerAnnotationWrongAttrType() |
|
| 345 | - { |
|
| 346 | - $this->expectException(SetupException::class); |
|
| 347 | - $this->getAttributes(Annotated::class, ['diWrongAttrType']); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - public function testContainerAnnotationWrongClassType() |
|
| 351 | - { |
|
| 352 | - $this->expectException(SetupException::class); |
|
| 353 | - $this->getAttributes(Annotated::class, ['diWrongClassType']); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - public function testContainerAnnotationWrongVarCount() |
|
| 357 | - { |
|
| 358 | - $this->expectException(SetupException::class); |
|
| 359 | - $this->getAttributes(Annotated::class, ['diWrongVarCount']); |
|
| 360 | - } |
|
| 361 | - |
|
| 362 | - public function testContainerErrorTwiceOnProp() |
|
| 363 | - { |
|
| 364 | - $this->expectException(SetupException::class); |
|
| 365 | - $this->getAttributes(ContainerError::class, [], ['prop']); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - public function testCallbackErrorNoName() |
|
| 369 | - { |
|
| 370 | - $this->expectException(SetupException::class); |
|
| 371 | - $this->getAttributes(CallbackError::class, ['noName']); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - public function testCallbackErrorWrongNameType() |
|
| 375 | - { |
|
| 376 | - $this->expectException(SetupException::class); |
|
| 377 | - $this->getAttributes(CallbackError::class, ['wrongNameType']); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - public function testCallbackErrorWrongNameAttr() |
|
| 381 | - { |
|
| 382 | - $this->expectException(SetupException::class); |
|
| 383 | - $this->getAttributes(CallbackError::class, ['wrongNameAttr']); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - public function testCallbackErrorNameWithSpace() |
|
| 387 | - { |
|
| 388 | - $this->expectException(SetupException::class); |
|
| 389 | - $this->getAttributes(CallbackError::class, ['nameWithSpace']); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - public function testCallbackErrorStartWithInt() |
|
| 393 | - { |
|
| 394 | - $this->expectException(SetupException::class); |
|
| 395 | - $this->getAttributes(CallbackError::class, ['startWithInt']); |
|
| 396 | - } |
|
| 265 | +public function testClassExcludeAnnotation() |
|
| 266 | +{ |
|
| 267 | +$xMetadata = $this->getAttributes(ClassExcluded::class, |
|
| 268 | +['doNot', 'withBags', 'cbSingle']); |
|
| 269 | +$bExcluded = $xMetadata->isExcluded(); |
|
| 270 | +$aProperties = $xMetadata->getProperties(); |
|
| 271 | +$aProtected = $xMetadata->getProtectedMethods(); |
|
| 272 | + |
|
| 273 | +$this->assertTrue($bExcluded); |
|
| 274 | +$this->assertEmpty($aProperties); |
|
| 275 | +$this->assertEmpty($aProtected); |
|
| 276 | +} |
|
| 277 | + |
|
| 278 | +public function testExcludeAnnotationError() |
|
| 279 | +{ |
|
| 280 | +$this->expectException(SetupException::class); |
|
| 281 | +$this->getAttributes(Annotated::class, ['doNotError']); |
|
| 282 | +} |
|
| 283 | + |
|
| 284 | +public function testDataBagAnnotationError() |
|
| 285 | +{ |
|
| 286 | +$this->expectException(SetupException::class); |
|
| 287 | +$this->getAttributes(Annotated::class, ['withBagsError']); |
|
| 288 | +} |
|
| 289 | + |
|
| 290 | +public function testUploadAnnotationWrongName() |
|
| 291 | +{ |
|
| 292 | +$this->expectException(SetupException::class); |
|
| 293 | +$this->getAttributes(Annotated::class, ['saveFilesWrongName']); |
|
| 294 | +} |
|
| 295 | + |
|
| 296 | +public function testUploadAnnotationMultiple() |
|
| 297 | +{ |
|
| 298 | +$this->expectException(SetupException::class); |
|
| 299 | +$this->getAttributes(Annotated::class, ['saveFilesMultiple']); |
|
| 300 | +} |
|
| 301 | + |
|
| 302 | +public function testCallbacksBeforeAnnotationNoCall() |
|
| 303 | +{ |
|
| 304 | +$this->expectException(SetupException::class); |
|
| 305 | +$this->getAttributes(Annotated::class, ['cbBeforeNoCall']); |
|
| 306 | +} |
|
| 307 | + |
|
| 308 | +public function testCallbacksBeforeAnnotationUnknownAttr() |
|
| 309 | +{ |
|
| 310 | +$this->expectException(SetupException::class); |
|
| 311 | +$this->getAttributes(Annotated::class, ['cbBeforeUnknownAttr']); |
|
| 312 | +} |
|
| 313 | + |
|
| 314 | +public function testCallbacksBeforeAnnotationWrongAttrType() |
|
| 315 | +{ |
|
| 316 | +$this->expectException(SetupException::class); |
|
| 317 | +$this->getAttributes(Annotated::class, ['cbBeforeWrongAttrType']); |
|
| 318 | +} |
|
| 319 | + |
|
| 320 | +public function testCallbacksAfterAnnotationNoCall() |
|
| 321 | +{ |
|
| 322 | +$this->expectException(SetupException::class); |
|
| 323 | +$this->getAttributes(Annotated::class, ['cbAfterNoCall']); |
|
| 324 | +} |
|
| 325 | + |
|
| 326 | +public function testCallbacksAfterAnnotationUnknownAttr() |
|
| 327 | +{ |
|
| 328 | +$this->expectException(SetupException::class); |
|
| 329 | +$this->getAttributes(Annotated::class, ['cbAfterUnknownAttr']); |
|
| 330 | +} |
|
| 331 | + |
|
| 332 | +public function testCallbacksAfterAnnotationWrongAttrType() |
|
| 333 | +{ |
|
| 334 | +$this->expectException(SetupException::class); |
|
| 335 | +$this->getAttributes(Annotated::class, ['cbAfterWrongAttrType']); |
|
| 336 | +} |
|
| 337 | + |
|
| 338 | +public function testContainerAnnotationUnknownAttr() |
|
| 339 | +{ |
|
| 340 | +$this->expectException(SetupException::class); |
|
| 341 | +$this->getAttributes(Annotated::class, ['diUnknownAttr']); |
|
| 342 | +} |
|
| 343 | + |
|
| 344 | +public function testContainerAnnotationWrongAttrType() |
|
| 345 | +{ |
|
| 346 | +$this->expectException(SetupException::class); |
|
| 347 | +$this->getAttributes(Annotated::class, ['diWrongAttrType']); |
|
| 348 | +} |
|
| 349 | + |
|
| 350 | +public function testContainerAnnotationWrongClassType() |
|
| 351 | +{ |
|
| 352 | +$this->expectException(SetupException::class); |
|
| 353 | +$this->getAttributes(Annotated::class, ['diWrongClassType']); |
|
| 354 | +} |
|
| 355 | + |
|
| 356 | +public function testContainerAnnotationWrongVarCount() |
|
| 357 | +{ |
|
| 358 | +$this->expectException(SetupException::class); |
|
| 359 | +$this->getAttributes(Annotated::class, ['diWrongVarCount']); |
|
| 360 | +} |
|
| 361 | + |
|
| 362 | +public function testContainerErrorTwiceOnProp() |
|
| 363 | +{ |
|
| 364 | +$this->expectException(SetupException::class); |
|
| 365 | +$this->getAttributes(ContainerError::class, [], ['prop']); |
|
| 366 | +} |
|
| 367 | + |
|
| 368 | +public function testCallbackErrorNoName() |
|
| 369 | +{ |
|
| 370 | +$this->expectException(SetupException::class); |
|
| 371 | +$this->getAttributes(CallbackError::class, ['noName']); |
|
| 372 | +} |
|
| 373 | + |
|
| 374 | +public function testCallbackErrorWrongNameType() |
|
| 375 | +{ |
|
| 376 | +$this->expectException(SetupException::class); |
|
| 377 | +$this->getAttributes(CallbackError::class, ['wrongNameType']); |
|
| 378 | +} |
|
| 379 | + |
|
| 380 | +public function testCallbackErrorWrongNameAttr() |
|
| 381 | +{ |
|
| 382 | +$this->expectException(SetupException::class); |
|
| 383 | +$this->getAttributes(CallbackError::class, ['wrongNameAttr']); |
|
| 384 | +} |
|
| 385 | + |
|
| 386 | +public function testCallbackErrorNameWithSpace() |
|
| 387 | +{ |
|
| 388 | +$this->expectException(SetupException::class); |
|
| 389 | +$this->getAttributes(CallbackError::class, ['nameWithSpace']); |
|
| 390 | +} |
|
| 391 | + |
|
| 392 | +public function testCallbackErrorStartWithInt() |
|
| 393 | +{ |
|
| 394 | +$this->expectException(SetupException::class); |
|
| 395 | +$this->getAttributes(CallbackError::class, ['startWithInt']); |
|
| 396 | +} |
|
| 397 | 397 | } |
@@ -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\App\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\App\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\App\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\App\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\App\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\App\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\App\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\App\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\App\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\App\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 | } |