@@ -19,25 +19,25 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | class JxnCall extends AbstractCall |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * The constructor. |
| 24 | 24 | * |
| 25 | 25 | * @param string $sPrefix The call prefix |
| 26 | 26 | */ |
| 27 | - public function __construct(protected string $sPrefix) |
|
| 28 | - {} |
|
| 27 | +public function __construct(protected string $sPrefix) |
|
| 28 | +{} |
|
| 29 | 29 | |
| 30 | - /** |
|
| 30 | +/** |
|
| 31 | 31 | * Create a js expression |
| 32 | 32 | * |
| 33 | 33 | * @return JsExpr |
| 34 | 34 | */ |
| 35 | - protected function _expr(): JsExpr |
|
| 36 | - { |
|
| 37 | - return new JsExpr(); |
|
| 38 | - } |
|
| 35 | +protected function _expr(): JsExpr |
|
| 36 | +{ |
|
| 37 | +return new JsExpr(); |
|
| 38 | +} |
|
| 39 | 39 | |
| 40 | - /** |
|
| 40 | +/** |
|
| 41 | 41 | * Add a call to a js function on the current object |
| 42 | 42 | * |
| 43 | 43 | * @param string $sMethod |
@@ -45,36 +45,36 @@ discard block |
||
| 45 | 45 | * |
| 46 | 46 | * @return JsExpr |
| 47 | 47 | */ |
| 48 | - public function __call(string $sMethod, array $aArguments): JsExpr |
|
| 49 | - { |
|
| 50 | - return parent::__call("{$this->sPrefix}{$sMethod}", $aArguments); |
|
| 51 | - } |
|
| 48 | +public function __call(string $sMethod, array $aArguments): JsExpr |
|
| 49 | +{ |
|
| 50 | +return parent::__call("{$this->sPrefix}{$sMethod}", $aArguments); |
|
| 51 | +} |
|
| 52 | 52 | |
| 53 | - /** |
|
| 53 | +/** |
|
| 54 | 54 | * @return string |
| 55 | 55 | */ |
| 56 | - public function _class(): string |
|
| 57 | - { |
|
| 58 | - return ''; |
|
| 59 | - } |
|
| 56 | +public function _class(): string |
|
| 57 | +{ |
|
| 58 | +return ''; |
|
| 59 | +} |
|
| 60 | 60 | |
| 61 | - /** |
|
| 61 | +/** |
|
| 62 | 62 | * Convert this call to array, when converting the response into json. |
| 63 | 63 | * |
| 64 | 64 | * @return array |
| 65 | 65 | */ |
| 66 | - public function jsonSerialize(): array |
|
| 67 | - { |
|
| 68 | - return (new JsExpr(Attr::get($this->_class())))->jsonSerialize(); |
|
| 69 | - } |
|
| 66 | +public function jsonSerialize(): array |
|
| 67 | +{ |
|
| 68 | +return (new JsExpr(Attr::get($this->_class())))->jsonSerialize(); |
|
| 69 | +} |
|
| 70 | 70 | |
| 71 | - /** |
|
| 71 | +/** |
|
| 72 | 72 | * Returns a call to jaxon as a string |
| 73 | 73 | * |
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | - public function __toString(): string |
|
| 77 | - { |
|
| 78 | - return (new JsExpr(Attr::get($this->_class())))->__toString(); |
|
| 79 | - } |
|
| 76 | +public function __toString(): string |
|
| 77 | +{ |
|
| 78 | +return (new JsExpr(Attr::get($this->_class())))->__toString(); |
|
| 79 | +} |
|
| 80 | 80 | } |
@@ -21,29 +21,29 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | class JsSelectorCall extends AbstractJsCall |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * The constructor. |
| 26 | 26 | * |
| 27 | 27 | * @param Closure|null $xExprCb |
| 28 | 28 | * @param string $sElementId The DOM element id |
| 29 | 29 | */ |
| 30 | - public function __construct(?Closure $xExprCb, protected string $sElementId) |
|
| 31 | - { |
|
| 32 | - parent::__construct($xExprCb); |
|
| 33 | - } |
|
| 30 | +public function __construct(?Closure $xExprCb, protected string $sElementId) |
|
| 31 | +{ |
|
| 32 | +parent::__construct($xExprCb); |
|
| 33 | +} |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | +/** |
|
| 36 | 36 | * Get the call to add to the expression |
| 37 | 37 | * |
| 38 | 38 | * @return Selector |
| 39 | 39 | */ |
| 40 | - protected function _exprCall(): Selector |
|
| 41 | - { |
|
| 42 | - // If the value is '', return the js "this" object, otherwise, the selected DOM element. |
|
| 43 | - return new Selector('js', $this->sElementId ?: 'this'); |
|
| 44 | - } |
|
| 40 | +protected function _exprCall(): Selector |
|
| 41 | +{ |
|
| 42 | +// If the value is '', return the js "this" object, otherwise, the selected DOM element. |
|
| 43 | +return new Selector('js', $this->sElementId ?: 'this'); |
|
| 44 | +} |
|
| 45 | 45 | |
| 46 | - /** |
|
| 46 | +/** |
|
| 47 | 47 | * Set an event handler on the selected elements |
| 48 | 48 | * |
| 49 | 49 | * @param string $sName |
@@ -51,28 +51,28 @@ discard block |
||
| 51 | 51 | * |
| 52 | 52 | * @return JsExpr |
| 53 | 53 | */ |
| 54 | - public function addEventListener(string $sName, JsExpr $xHandler): JsExpr |
|
| 55 | - { |
|
| 56 | - return $this->_expr()->event('js', $sName, $xHandler); |
|
| 57 | - } |
|
| 54 | +public function addEventListener(string $sName, JsExpr $xHandler): JsExpr |
|
| 55 | +{ |
|
| 56 | +return $this->_expr()->event('js', $sName, $xHandler); |
|
| 57 | +} |
|
| 58 | 58 | |
| 59 | - /** |
|
| 59 | +/** |
|
| 60 | 60 | * Set an "click" event handler on the first selected element |
| 61 | 61 | * |
| 62 | 62 | * @param JsExpr $xHandler |
| 63 | 63 | * |
| 64 | 64 | * @return JsExpr |
| 65 | 65 | */ |
| 66 | - public function click(JsExpr $xHandler): JsExpr |
|
| 67 | - { |
|
| 68 | - return $this->_expr()->event('js', 'click', $xHandler); |
|
| 69 | - } |
|
| 66 | +public function click(JsExpr $xHandler): JsExpr |
|
| 67 | +{ |
|
| 68 | +return $this->_expr()->event('js', 'click', $xHandler); |
|
| 69 | +} |
|
| 70 | 70 | |
| 71 | - /** |
|
| 71 | +/** |
|
| 72 | 72 | * @return HtmlReader |
| 73 | 73 | */ |
| 74 | - public function rd(): HtmlReader |
|
| 75 | - { |
|
| 76 | - return new HtmlReader($this->sElementId); |
|
| 77 | - } |
|
| 74 | +public function rd(): HtmlReader |
|
| 75 | +{ |
|
| 76 | +return new HtmlReader($this->sElementId); |
|
| 77 | +} |
|
| 78 | 78 | } |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | abstract class AbstractCall implements JsonSerializable |
| 21 | 21 | { |
| 22 | - /** |
|
| 22 | +/** |
|
| 23 | 23 | * Create a js expression |
| 24 | 24 | * |
| 25 | 25 | * @return JsExpr |
| 26 | 26 | */ |
| 27 | - abstract protected function _expr(): JsExpr; |
|
| 27 | +abstract protected function _expr(): JsExpr; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | +/** |
|
| 30 | 30 | * Add a call to a js function on the current object |
| 31 | 31 | * |
| 32 | 32 | * @param string $sMethod |
@@ -34,28 +34,28 @@ discard block |
||
| 34 | 34 | * |
| 35 | 35 | * @return JsExpr |
| 36 | 36 | */ |
| 37 | - public function __call(string $sMethod, array $aArguments): JsExpr |
|
| 38 | - { |
|
| 39 | - return $this->_expr()->__call($sMethod, $aArguments); |
|
| 40 | - } |
|
| 37 | +public function __call(string $sMethod, array $aArguments): JsExpr |
|
| 38 | +{ |
|
| 39 | +return $this->_expr()->__call($sMethod, $aArguments); |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - /** |
|
| 42 | +/** |
|
| 43 | 43 | * Convert this call to array, when converting the response into json. |
| 44 | 44 | * |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - public function jsonSerialize(): array |
|
| 48 | - { |
|
| 49 | - return $this->_expr()->jsonSerialize(); |
|
| 50 | - } |
|
| 47 | +public function jsonSerialize(): array |
|
| 48 | +{ |
|
| 49 | +return $this->_expr()->jsonSerialize(); |
|
| 50 | +} |
|
| 51 | 51 | |
| 52 | - /** |
|
| 52 | +/** |
|
| 53 | 53 | * Returns a call to jaxon as a string |
| 54 | 54 | * |
| 55 | 55 | * @return string |
| 56 | 56 | */ |
| 57 | - public function __toString(): string |
|
| 58 | - { |
|
| 59 | - return $this->_expr()->__toString(); |
|
| 60 | - } |
|
| 57 | +public function __toString(): string |
|
| 58 | +{ |
|
| 59 | +return $this->_expr()->__toString(); |
|
| 60 | +} |
|
| 61 | 61 | } |
@@ -1,49 +1,49 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'core' => [ |
|
| 5 | - 'version' => Jaxon\Jaxon::VERSION, |
|
| 6 | - 'language' => 'en', |
|
| 7 | - 'encoding' => 'utf-8', |
|
| 8 | - 'decode_utf8' => false, |
|
| 9 | - 'prefix' => [ |
|
| 10 | - 'function' => 'jaxon_', |
|
| 11 | - 'class' => 'Jaxon', |
|
| 12 | - ], |
|
| 13 | - 'request' => [ |
|
| 14 | - 'mode' => 'asynchronous', |
|
| 15 | - 'method' => 'POST', // W3C: Method is case-sensitive |
|
| 16 | - ], |
|
| 17 | - 'response' => [ |
|
| 18 | - 'send' => true, |
|
| 19 | - ], |
|
| 20 | - 'debug' => [ |
|
| 21 | - 'on' => false, |
|
| 22 | - 'verbose' => false, |
|
| 23 | - ], |
|
| 24 | - 'process' => [ |
|
| 25 | - 'exit' => true, |
|
| 26 | - 'timeout' => 6000, |
|
| 27 | - ], |
|
| 28 | - 'error' => [ |
|
| 29 | - 'handle' => false, |
|
| 30 | - 'log_file' => '', |
|
| 31 | - ], |
|
| 32 | - 'jquery' => [ |
|
| 33 | - 'no_conflict' => false, |
|
| 34 | - ], |
|
| 35 | - ], |
|
| 36 | - 'js' => [ |
|
| 37 | - 'lib' => [ |
|
| 38 | - 'output_id' => 0, |
|
| 39 | - 'queue_size' => 0, |
|
| 40 | - 'load_timeout' => 2000, |
|
| 41 | - 'show_status' => false, |
|
| 42 | - 'show_cursor' => true, |
|
| 43 | - ], |
|
| 44 | - 'app' => [ |
|
| 45 | - 'dir' => '', |
|
| 46 | - 'options' => '', |
|
| 47 | - ], |
|
| 48 | - ], |
|
| 4 | +'core' => [ |
|
| 5 | +'version' => Jaxon\Jaxon::VERSION, |
|
| 6 | +'language' => 'en', |
|
| 7 | +'encoding' => 'utf-8', |
|
| 8 | +'decode_utf8' => false, |
|
| 9 | +'prefix' => [ |
|
| 10 | +'function' => 'jaxon_', |
|
| 11 | +'class' => 'Jaxon', |
|
| 12 | +], |
|
| 13 | +'request' => [ |
|
| 14 | +'mode' => 'asynchronous', |
|
| 15 | +'method' => 'POST', // W3C: Method is case-sensitive |
|
| 16 | +], |
|
| 17 | +'response' => [ |
|
| 18 | +'send' => true, |
|
| 19 | +], |
|
| 20 | +'debug' => [ |
|
| 21 | +'on' => false, |
|
| 22 | +'verbose' => false, |
|
| 23 | +], |
|
| 24 | +'process' => [ |
|
| 25 | +'exit' => true, |
|
| 26 | +'timeout' => 6000, |
|
| 27 | +], |
|
| 28 | +'error' => [ |
|
| 29 | +'handle' => false, |
|
| 30 | +'log_file' => '', |
|
| 31 | +], |
|
| 32 | +'jquery' => [ |
|
| 33 | +'no_conflict' => false, |
|
| 34 | +], |
|
| 35 | +], |
|
| 36 | +'js' => [ |
|
| 37 | +'lib' => [ |
|
| 38 | +'output_id' => 0, |
|
| 39 | +'queue_size' => 0, |
|
| 40 | +'load_timeout' => 2000, |
|
| 41 | +'show_status' => false, |
|
| 42 | +'show_cursor' => true, |
|
| 43 | +], |
|
| 44 | +'app' => [ |
|
| 45 | +'dir' => '', |
|
| 46 | +'options' => '', |
|
| 47 | +], |
|
| 48 | +], |
|
| 49 | 49 | ]; |
@@ -24,383 +24,383 @@ |
||
| 24 | 24 | |
| 25 | 25 | class SetupTest extends TestCase |
| 26 | 26 | { |
| 27 | - /** |
|
| 27 | +/** |
|
| 28 | 28 | * @throws SetupException |
| 29 | 29 | */ |
| 30 | - public function setUp(): void |
|
| 31 | - { |
|
| 32 | - _register(); |
|
| 33 | - jaxon()->setOption('core.prefix.class', ''); |
|
| 34 | - jaxon()->setOption('core.request.uri', 'http://example.test/path'); |
|
| 35 | - jaxon()->register(Jaxon::CALLABLE_CLASS, Dialog::class); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - /** |
|
| 30 | +public function setUp(): void |
|
| 31 | +{ |
|
| 32 | +_register(); |
|
| 33 | +jaxon()->setOption('core.prefix.class', ''); |
|
| 34 | +jaxon()->setOption('core.request.uri', 'http://example.test/path'); |
|
| 35 | +jaxon()->register(Jaxon::CALLABLE_CLASS, Dialog::class); |
|
| 36 | +} |
|
| 37 | + |
|
| 38 | +/** |
|
| 39 | 39 | * @throws SetupException |
| 40 | 40 | */ |
| 41 | - public function tearDown(): void |
|
| 42 | - { |
|
| 43 | - jaxon()->reset(); |
|
| 44 | - parent::tearDown(); |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - public function testDialogSettings() |
|
| 48 | - { |
|
| 49 | - $this->assertEquals('', dialog()->getConfirmLibrary()->getName()); |
|
| 50 | - $this->assertEquals(Alert::class, get_class(dialog()->getConfirmLibrary())); |
|
| 51 | - $this->assertEquals(Alert::class, get_class(dialog()->getAlertLibrary())); |
|
| 52 | - $this->assertEquals(null, dialog()->getModalLibrary()); |
|
| 53 | - |
|
| 54 | - jaxon()->setAppOptions([ |
|
| 55 | - 'modal' => 'alertify', |
|
| 56 | - 'alert' => 'alertify', |
|
| 57 | - 'confirm' => 'alertify', |
|
| 58 | - ], 'dialogs.default'); |
|
| 59 | - $this->assertEquals(Alertify::class, get_class(dialog()->getConfirmLibrary())); |
|
| 60 | - $this->assertEquals(Alertify::class, get_class(dialog()->getAlertLibrary())); |
|
| 61 | - $this->assertEquals(Alertify::class, get_class(dialog()->getModalLibrary())); |
|
| 62 | - |
|
| 63 | - jaxon()->setAppOptions([ |
|
| 64 | - 'modal' => 'bootbox', |
|
| 65 | - 'alert' => 'bootbox', |
|
| 66 | - 'confirm' => 'bootbox', |
|
| 67 | - ], 'dialogs.default'); |
|
| 68 | - $this->assertEquals(Bootbox::class, get_class(dialog()->getConfirmLibrary())); |
|
| 69 | - $this->assertEquals(Bootbox::class, get_class(dialog()->getAlertLibrary())); |
|
| 70 | - $this->assertEquals(Bootbox::class, get_class(dialog()->getModalLibrary())); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - public function testDialogOptions() |
|
| 74 | - { |
|
| 75 | - jaxon()->app()->setup(__DIR__ . '/../config/dialog.php'); |
|
| 76 | - $this->assertStringContainsString('toast-top-center', jaxon()->script()); |
|
| 77 | - |
|
| 78 | - /** @var DialogPlugin */ |
|
| 79 | - $xDialogPlugin = jaxon()->di()->g(DialogPlugin::class); |
|
| 80 | - $this->assertStringContainsString('5.0.0', $xDialogPlugin->getHash()); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - public function testDialogDefaultMethods() |
|
| 84 | - { |
|
| 85 | - dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 86 | - // Registering a library twice should not cause any issue. |
|
| 87 | - dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 88 | - jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 89 | - $xConfirmLibrary = dialog()->getConfirmLibrary(); |
|
| 90 | - $this->assertEquals('', $xConfirmLibrary->getUri()); |
|
| 91 | - $this->assertEquals('', $xConfirmLibrary->getJs()); |
|
| 92 | - $this->assertEquals('', $xConfirmLibrary->getScript()); |
|
| 93 | - $this->assertEquals('', $xConfirmLibrary->getJsCode()->sJs); |
|
| 94 | - $this->assertEquals('', $xConfirmLibrary->getJsCode()->sJsBefore); |
|
| 95 | - $this->assertEquals('', $xConfirmLibrary->getJsCode()->sJsAfter); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - public function testExtDialogLibrary() |
|
| 99 | - { |
|
| 100 | - dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 101 | - jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 102 | - $this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - public function testExtDialogLibraryConfigSet() |
|
| 106 | - { |
|
| 107 | - jaxon()->setAppOption('dialogs.lib.ext', [ |
|
| 108 | - TestDialogLibrary::NAME => TestDialogLibrary::class, |
|
| 109 | - ]); |
|
| 110 | - jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 111 | - $this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - public function testExtDialogLibraryConfigFile() |
|
| 115 | - { |
|
| 116 | - jaxon()->app()->setup(__DIR__ . '/../config/ext.php'); |
|
| 117 | - $this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - public function testDialogJsCode() |
|
| 121 | - { |
|
| 122 | - jaxon()->setAppOption('dialogs.lib.use', ['bootbox', 'alertify', 'cute']); |
|
| 123 | - $sJsCode = jaxon()->js(); |
|
| 124 | - $this->assertStringContainsString('bootbox.min.js', $sJsCode); |
|
| 125 | - $this->assertStringContainsString('alertify.min.js', $sJsCode); |
|
| 126 | - $this->assertStringContainsString('cute-alert.js', $sJsCode); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - public function testDialogCssCode() |
|
| 130 | - { |
|
| 131 | - jaxon()->setAppOption('dialogs.lib.use', ['alertify', 'cute']); |
|
| 132 | - $sCssCode = jaxon()->css(); |
|
| 133 | - $this->assertStringContainsString('alertify.min.css', $sCssCode); |
|
| 134 | - $this->assertStringContainsString('cute-alert/style.css', $sCssCode); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 41 | +public function tearDown(): void |
|
| 42 | +{ |
|
| 43 | +jaxon()->reset(); |
|
| 44 | +parent::tearDown(); |
|
| 45 | +} |
|
| 46 | + |
|
| 47 | +public function testDialogSettings() |
|
| 48 | +{ |
|
| 49 | +$this->assertEquals('', dialog()->getConfirmLibrary()->getName()); |
|
| 50 | +$this->assertEquals(Alert::class, get_class(dialog()->getConfirmLibrary())); |
|
| 51 | +$this->assertEquals(Alert::class, get_class(dialog()->getAlertLibrary())); |
|
| 52 | +$this->assertEquals(null, dialog()->getModalLibrary()); |
|
| 53 | + |
|
| 54 | +jaxon()->setAppOptions([ |
|
| 55 | +'modal' => 'alertify', |
|
| 56 | +'alert' => 'alertify', |
|
| 57 | +'confirm' => 'alertify', |
|
| 58 | +], 'dialogs.default'); |
|
| 59 | +$this->assertEquals(Alertify::class, get_class(dialog()->getConfirmLibrary())); |
|
| 60 | +$this->assertEquals(Alertify::class, get_class(dialog()->getAlertLibrary())); |
|
| 61 | +$this->assertEquals(Alertify::class, get_class(dialog()->getModalLibrary())); |
|
| 62 | + |
|
| 63 | +jaxon()->setAppOptions([ |
|
| 64 | +'modal' => 'bootbox', |
|
| 65 | +'alert' => 'bootbox', |
|
| 66 | +'confirm' => 'bootbox', |
|
| 67 | +], 'dialogs.default'); |
|
| 68 | +$this->assertEquals(Bootbox::class, get_class(dialog()->getConfirmLibrary())); |
|
| 69 | +$this->assertEquals(Bootbox::class, get_class(dialog()->getAlertLibrary())); |
|
| 70 | +$this->assertEquals(Bootbox::class, get_class(dialog()->getModalLibrary())); |
|
| 71 | +} |
|
| 72 | + |
|
| 73 | +public function testDialogOptions() |
|
| 74 | +{ |
|
| 75 | +jaxon()->app()->setup(__DIR__ . '/../config/dialog.php'); |
|
| 76 | +$this->assertStringContainsString('toast-top-center', jaxon()->script()); |
|
| 77 | + |
|
| 78 | +/** @var DialogPlugin */ |
|
| 79 | +$xDialogPlugin = jaxon()->di()->g(DialogPlugin::class); |
|
| 80 | +$this->assertStringContainsString('5.0.0', $xDialogPlugin->getHash()); |
|
| 81 | +} |
|
| 82 | + |
|
| 83 | +public function testDialogDefaultMethods() |
|
| 84 | +{ |
|
| 85 | +dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 86 | +// Registering a library twice should not cause any issue. |
|
| 87 | +dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 88 | +jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 89 | +$xConfirmLibrary = dialog()->getConfirmLibrary(); |
|
| 90 | +$this->assertEquals('', $xConfirmLibrary->getUri()); |
|
| 91 | +$this->assertEquals('', $xConfirmLibrary->getJs()); |
|
| 92 | +$this->assertEquals('', $xConfirmLibrary->getScript()); |
|
| 93 | +$this->assertEquals('', $xConfirmLibrary->getJsCode()->sJs); |
|
| 94 | +$this->assertEquals('', $xConfirmLibrary->getJsCode()->sJsBefore); |
|
| 95 | +$this->assertEquals('', $xConfirmLibrary->getJsCode()->sJsAfter); |
|
| 96 | +} |
|
| 97 | + |
|
| 98 | +public function testExtDialogLibrary() |
|
| 99 | +{ |
|
| 100 | +dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 101 | +jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 102 | +$this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 103 | +} |
|
| 104 | + |
|
| 105 | +public function testExtDialogLibraryConfigSet() |
|
| 106 | +{ |
|
| 107 | +jaxon()->setAppOption('dialogs.lib.ext', [ |
|
| 108 | +TestDialogLibrary::NAME => TestDialogLibrary::class, |
|
| 109 | +]); |
|
| 110 | +jaxon()->setAppOption('dialogs.default.confirm', TestDialogLibrary::NAME); |
|
| 111 | +$this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 112 | +} |
|
| 113 | + |
|
| 114 | +public function testExtDialogLibraryConfigFile() |
|
| 115 | +{ |
|
| 116 | +jaxon()->app()->setup(__DIR__ . '/../config/ext.php'); |
|
| 117 | +$this->assertEquals(TestDialogLibrary::class, get_class(dialog()->getConfirmLibrary())); |
|
| 118 | +} |
|
| 119 | + |
|
| 120 | +public function testDialogJsCode() |
|
| 121 | +{ |
|
| 122 | +jaxon()->setAppOption('dialogs.lib.use', ['bootbox', 'alertify', 'cute']); |
|
| 123 | +$sJsCode = jaxon()->js(); |
|
| 124 | +$this->assertStringContainsString('bootbox.min.js', $sJsCode); |
|
| 125 | +$this->assertStringContainsString('alertify.min.js', $sJsCode); |
|
| 126 | +$this->assertStringContainsString('cute-alert.js', $sJsCode); |
|
| 127 | +} |
|
| 128 | + |
|
| 129 | +public function testDialogCssCode() |
|
| 130 | +{ |
|
| 131 | +jaxon()->setAppOption('dialogs.lib.use', ['alertify', 'cute']); |
|
| 132 | +$sCssCode = jaxon()->css(); |
|
| 133 | +$this->assertStringContainsString('alertify.min.css', $sCssCode); |
|
| 134 | +$this->assertStringContainsString('cute-alert/style.css', $sCssCode); |
|
| 135 | +} |
|
| 136 | + |
|
| 137 | +/** |
|
| 138 | 138 | * @throws UriException |
| 139 | 139 | */ |
| 140 | - public function testDialogScriptCode() |
|
| 141 | - { |
|
| 142 | - jaxon()->setAppOptions([ |
|
| 143 | - 'default' => [ |
|
| 144 | - 'modal' => 'alertify', |
|
| 145 | - 'alert' => 'alertify', |
|
| 146 | - 'confirm' => 'alertify', |
|
| 147 | - ], |
|
| 148 | - 'lib' => [ |
|
| 149 | - 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 150 | - ], |
|
| 151 | - ], 'dialogs'); |
|
| 152 | - |
|
| 153 | - $sScriptCode = jaxon()->getScript(); |
|
| 154 | - $this->assertStringContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 155 | - $this->assertStringContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 156 | - $this->assertStringContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 157 | - $this->assertStringContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /** |
|
| 140 | +public function testDialogScriptCode() |
|
| 141 | +{ |
|
| 142 | +jaxon()->setAppOptions([ |
|
| 143 | +'default' => [ |
|
| 144 | + 'modal' => 'alertify', |
|
| 145 | + 'alert' => 'alertify', |
|
| 146 | + 'confirm' => 'alertify', |
|
| 147 | +], |
|
| 148 | +'lib' => [ |
|
| 149 | + 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 150 | +], |
|
| 151 | +], 'dialogs'); |
|
| 152 | + |
|
| 153 | +$sScriptCode = jaxon()->getScript(); |
|
| 154 | +$this->assertStringContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 155 | +$this->assertStringContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 156 | +$this->assertStringContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 157 | +$this->assertStringContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 158 | +} |
|
| 159 | + |
|
| 160 | +/** |
|
| 161 | 161 | * @throws UriException |
| 162 | 162 | */ |
| 163 | - public function testDialogScriptFile() |
|
| 164 | - { |
|
| 165 | - jaxon()->setOptions([ |
|
| 166 | - 'export' => true, |
|
| 167 | - 'minify' => false, |
|
| 168 | - 'file' => 'app', |
|
| 169 | - 'dir' => __DIR__ . '/../js', |
|
| 170 | - 'uri' => 'http://localhost', |
|
| 171 | - ], 'js.app'); |
|
| 172 | - jaxon()->setAppOptions([ |
|
| 173 | - 'default' => [ |
|
| 174 | - 'modal' => 'alertify', |
|
| 175 | - 'alert' => 'alertify', |
|
| 176 | - 'confirm' => 'alertify', |
|
| 177 | - ], |
|
| 178 | - 'lib' => [ |
|
| 179 | - 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 180 | - ], |
|
| 181 | - ], 'dialogs'); |
|
| 182 | - |
|
| 183 | - $sScriptCode = jaxon()->getScript(); |
|
| 184 | - $this->assertStringNotContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 185 | - $this->assertStringNotContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 186 | - $this->assertStringNotContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 187 | - $this->assertStringNotContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 188 | - |
|
| 189 | - $this->assertStringContainsString('/js/alertify.js', $sScriptCode); |
|
| 190 | - $this->assertStringContainsString('/js/bootbox.js', $sScriptCode); |
|
| 191 | - $this->assertStringContainsString('/js/cute.js', $sScriptCode); |
|
| 192 | - $this->assertStringContainsString('/js/jalert.js', $sScriptCode); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 163 | +public function testDialogScriptFile() |
|
| 164 | +{ |
|
| 165 | +jaxon()->setOptions([ |
|
| 166 | +'export' => true, |
|
| 167 | +'minify' => false, |
|
| 168 | +'file' => 'app', |
|
| 169 | +'dir' => __DIR__ . '/../js', |
|
| 170 | +'uri' => 'http://localhost', |
|
| 171 | +], 'js.app'); |
|
| 172 | +jaxon()->setAppOptions([ |
|
| 173 | +'default' => [ |
|
| 174 | + 'modal' => 'alertify', |
|
| 175 | + 'alert' => 'alertify', |
|
| 176 | + 'confirm' => 'alertify', |
|
| 177 | +], |
|
| 178 | +'lib' => [ |
|
| 179 | + 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 180 | +], |
|
| 181 | +], 'dialogs'); |
|
| 182 | + |
|
| 183 | +$sScriptCode = jaxon()->getScript(); |
|
| 184 | +$this->assertStringNotContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 185 | +$this->assertStringNotContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 186 | +$this->assertStringNotContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 187 | +$this->assertStringNotContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 188 | + |
|
| 189 | +$this->assertStringContainsString('/js/alertify.js', $sScriptCode); |
|
| 190 | +$this->assertStringContainsString('/js/bootbox.js', $sScriptCode); |
|
| 191 | +$this->assertStringContainsString('/js/cute.js', $sScriptCode); |
|
| 192 | +$this->assertStringContainsString('/js/jalert.js', $sScriptCode); |
|
| 193 | +} |
|
| 194 | + |
|
| 195 | +/** |
|
| 196 | 196 | * @throws UriException |
| 197 | 197 | */ |
| 198 | - public function testDialogScriptMinFile() |
|
| 199 | - { |
|
| 200 | - jaxon()->setOptions([ |
|
| 201 | - 'export' => true, |
|
| 202 | - 'minify' => true, |
|
| 203 | - 'file' => 'app', |
|
| 204 | - 'dir' => __DIR__ . '/../js', |
|
| 205 | - 'uri' => 'http://localhost', |
|
| 206 | - ], 'js.app'); |
|
| 207 | - jaxon()->setAppOptions([ |
|
| 208 | - 'default' => [ |
|
| 209 | - 'modal' => 'alertify', |
|
| 210 | - 'alert' => 'alertify', |
|
| 211 | - 'confirm' => 'alertify', |
|
| 212 | - ], |
|
| 213 | - 'lib' => [ |
|
| 214 | - 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 215 | - ], |
|
| 216 | - ], 'dialogs'); |
|
| 217 | - |
|
| 218 | - $sScriptCode = jaxon()->getScript(); |
|
| 219 | - $this->assertStringNotContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 220 | - $this->assertStringNotContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 221 | - $this->assertStringNotContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 222 | - $this->assertStringNotContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 223 | - |
|
| 224 | - $this->assertStringContainsString('/js/alertify.min.js', $sScriptCode); |
|
| 225 | - $this->assertStringContainsString('/js/bootbox.min.js', $sScriptCode); |
|
| 226 | - $this->assertStringContainsString('/js/cute.min.js', $sScriptCode); |
|
| 227 | - $this->assertStringContainsString('/js/jalert.min.js', $sScriptCode); |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - public function testAlertifyLibrary() |
|
| 231 | - { |
|
| 232 | - jaxon()->setAppOption('dialogs.lib.use', ['alertify']); |
|
| 233 | - |
|
| 234 | - $this->assertStringContainsString('alertify.min.js', jaxon()->js()); |
|
| 235 | - $this->assertStringContainsString('css/alertify.min.css', jaxon()->css()); |
|
| 236 | - $this->assertStringContainsString('css/themes/default.min.css', jaxon()->css()); |
|
| 237 | - $this->assertStringContainsString("jaxon.dialog.register('alertify'", jaxon()->script()); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - public function testBootboxLibrary() |
|
| 241 | - { |
|
| 242 | - jaxon()->setAppOption('dialogs.lib.use', ['bootbox']); |
|
| 243 | - |
|
| 244 | - $this->assertStringContainsString('bootbox.min.js', jaxon()->js()); |
|
| 245 | - $this->assertStringContainsString("jaxon.dialog.register('bootbox'", jaxon()->script()); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - public function testBootstrap3Library() |
|
| 249 | - { |
|
| 250 | - jaxon()->setAppOption('dialogs.lib.use', ['bootstrap3']); |
|
| 251 | - |
|
| 252 | - $this->assertStringContainsString("jaxon.dialog.register('bootstrap3'", jaxon()->script()); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - public function testBootstrap4Library() |
|
| 256 | - { |
|
| 257 | - jaxon()->setAppOption('dialogs.lib.use', ['bootstrap4']); |
|
| 258 | - |
|
| 259 | - $this->assertStringContainsString("jaxon.dialog.register('bootstrap4'", jaxon()->script()); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - public function testBootstrap5Library() |
|
| 263 | - { |
|
| 264 | - jaxon()->setAppOption('dialogs.lib.use', ['bootstrap5']); |
|
| 265 | - |
|
| 266 | - $this->assertStringContainsString("jaxon.dialog.register('bootstrap5'", jaxon()->script()); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - public function testButterupLibrary() |
|
| 270 | - { |
|
| 271 | - jaxon()->setAppOption('dialogs.lib.use', ['butterup']); |
|
| 272 | - |
|
| 273 | - $this->assertStringContainsString('butterup.min.js', jaxon()->js()); |
|
| 274 | - $this->assertStringContainsString('butterup.min.css', jaxon()->css()); |
|
| 275 | - $this->assertStringContainsString("jaxon.dialog.register('butterup'", jaxon()->script()); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - public function testCuteAlertLibrary() |
|
| 279 | - { |
|
| 280 | - jaxon()->setAppOption('dialogs.lib.use', ['cute']); |
|
| 281 | - |
|
| 282 | - $this->assertStringContainsString('cute-alert/cute-alert.js', jaxon()->js()); |
|
| 283 | - $this->assertStringContainsString('cute-alert/style.css', jaxon()->css()); |
|
| 284 | - $this->assertStringContainsString("jaxon.dialog.register('cute'", jaxon()->script()); |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - public function testIziToastLibrary() |
|
| 288 | - { |
|
| 289 | - jaxon()->setAppOption('dialogs.lib.use', ['izitoast']); |
|
| 290 | - |
|
| 291 | - $this->assertStringContainsString('js/iziToast.min.js', jaxon()->js()); |
|
| 292 | - $this->assertStringContainsString('css/iziToast.min.css', jaxon()->css()); |
|
| 293 | - $this->assertStringContainsString("jaxon.dialog.register('izitoast'", jaxon()->script()); |
|
| 294 | - } |
|
| 295 | - |
|
| 296 | - public function testJAlertLibrary() |
|
| 297 | - { |
|
| 298 | - jaxon()->setAppOption('dialogs.lib.use', ['jalert']); |
|
| 299 | - |
|
| 300 | - $this->assertStringContainsString('jAlert.min.js', jaxon()->js()); |
|
| 301 | - $this->assertStringContainsString('jAlert.min.css', jaxon()->css()); |
|
| 302 | - $this->assertStringContainsString("jaxon.dialog.register('jalert'", jaxon()->script()); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - public function testJQueryConfirmLibrary() |
|
| 306 | - { |
|
| 307 | - jaxon()->setAppOption('dialogs.lib.use', ['jconfirm']); |
|
| 308 | - |
|
| 309 | - $this->assertStringContainsString('jquery-confirm.min.js', jaxon()->js()); |
|
| 310 | - $this->assertStringContainsString('jquery-confirm.min.css', jaxon()->css()); |
|
| 311 | - $this->assertStringContainsString("jaxon.dialog.register('jconfirm'", jaxon()->script()); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - public function testNotifyLibrary() |
|
| 315 | - { |
|
| 316 | - jaxon()->setAppOption('dialogs.lib.use', ['notify']); |
|
| 317 | - |
|
| 318 | - $this->assertStringContainsString('notify.min.js', jaxon()->js()); |
|
| 319 | - $this->assertStringContainsString("jaxon.dialog.register('notify'", jaxon()->script()); |
|
| 320 | - } |
|
| 321 | - |
|
| 322 | - public function testNotyLibrary() |
|
| 323 | - { |
|
| 324 | - jaxon()->setAppOption('dialogs.lib.use', ['noty']); |
|
| 325 | - |
|
| 326 | - $this->assertStringContainsString('noty.min.js', jaxon()->js()); |
|
| 327 | - $this->assertStringContainsString('noty.min.css', jaxon()->css()); |
|
| 328 | - $this->assertStringContainsString("jaxon.dialog.register('noty'", jaxon()->script()); |
|
| 329 | - } |
|
| 330 | - |
|
| 331 | - public function testNotyfLibrary() |
|
| 332 | - { |
|
| 333 | - jaxon()->setAppOption('dialogs.lib.use', ['notyf']); |
|
| 334 | - |
|
| 335 | - $this->assertStringContainsString('notyf.min.js', jaxon()->js()); |
|
| 336 | - $this->assertStringContainsString('notyf.min.css', jaxon()->css()); |
|
| 337 | - $this->assertStringContainsString("jaxon.dialog.register('notyf'", jaxon()->script()); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - public function testQuantumLibrary() |
|
| 341 | - { |
|
| 342 | - jaxon()->setAppOption('dialogs.lib.use', ['quantum']); |
|
| 343 | - |
|
| 344 | - $this->assertStringContainsString('minfile/quantumalert.js', jaxon()->js()); |
|
| 345 | - $this->assertStringContainsString("jaxon.dialog.register('quantum'", jaxon()->script()); |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - public function testSweetAlertLibrary() |
|
| 349 | - { |
|
| 350 | - jaxon()->setAppOption('dialogs.lib.use', ['sweetalert']); |
|
| 351 | - |
|
| 352 | - $this->assertStringContainsString('sweetalert.min.js', jaxon()->js()); |
|
| 353 | - $this->assertStringContainsString("jaxon.dialog.register('sweetalert'", jaxon()->script()); |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - public function testTingleLibrary() |
|
| 357 | - { |
|
| 358 | - jaxon()->setAppOption('dialogs.lib.use', ['tingle']); |
|
| 359 | - |
|
| 360 | - $this->assertStringContainsString('tingle.min.js', jaxon()->js()); |
|
| 361 | - $this->assertStringContainsString('tingle.min.css', jaxon()->css()); |
|
| 362 | - $this->assertStringContainsString("jaxon.dialog.register('tingle'", jaxon()->script()); |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - public function testToastrLibrary() |
|
| 366 | - { |
|
| 367 | - jaxon()->setAppOption('dialogs.lib.use', ['toastr']); |
|
| 368 | - |
|
| 369 | - $this->assertStringContainsString('toastr.min.js', jaxon()->js()); |
|
| 370 | - $this->assertStringContainsString('build/toastr.min.css', jaxon()->css()); |
|
| 371 | - $this->assertStringContainsString("jaxon.dialog.register('toastr'", jaxon()->script()); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - /** |
|
| 198 | +public function testDialogScriptMinFile() |
|
| 199 | +{ |
|
| 200 | +jaxon()->setOptions([ |
|
| 201 | +'export' => true, |
|
| 202 | +'minify' => true, |
|
| 203 | +'file' => 'app', |
|
| 204 | +'dir' => __DIR__ . '/../js', |
|
| 205 | +'uri' => 'http://localhost', |
|
| 206 | +], 'js.app'); |
|
| 207 | +jaxon()->setAppOptions([ |
|
| 208 | +'default' => [ |
|
| 209 | + 'modal' => 'alertify', |
|
| 210 | + 'alert' => 'alertify', |
|
| 211 | + 'confirm' => 'alertify', |
|
| 212 | +], |
|
| 213 | +'lib' => [ |
|
| 214 | + 'use' => ['bootbox', 'cute', 'jalert'], |
|
| 215 | +], |
|
| 216 | +], 'dialogs'); |
|
| 217 | + |
|
| 218 | +$sScriptCode = jaxon()->getScript(); |
|
| 219 | +$this->assertStringNotContainsString("jaxon.dialog.register('alertify'", $sScriptCode); |
|
| 220 | +$this->assertStringNotContainsString("jaxon.dialog.register('bootbox'", $sScriptCode); |
|
| 221 | +$this->assertStringNotContainsString("jaxon.dialog.register('cute'", $sScriptCode); |
|
| 222 | +$this->assertStringNotContainsString("jaxon.dialog.register('jalert'", $sScriptCode); |
|
| 223 | + |
|
| 224 | +$this->assertStringContainsString('/js/alertify.min.js', $sScriptCode); |
|
| 225 | +$this->assertStringContainsString('/js/bootbox.min.js', $sScriptCode); |
|
| 226 | +$this->assertStringContainsString('/js/cute.min.js', $sScriptCode); |
|
| 227 | +$this->assertStringContainsString('/js/jalert.min.js', $sScriptCode); |
|
| 228 | +} |
|
| 229 | + |
|
| 230 | +public function testAlertifyLibrary() |
|
| 231 | +{ |
|
| 232 | +jaxon()->setAppOption('dialogs.lib.use', ['alertify']); |
|
| 233 | + |
|
| 234 | +$this->assertStringContainsString('alertify.min.js', jaxon()->js()); |
|
| 235 | +$this->assertStringContainsString('css/alertify.min.css', jaxon()->css()); |
|
| 236 | +$this->assertStringContainsString('css/themes/default.min.css', jaxon()->css()); |
|
| 237 | +$this->assertStringContainsString("jaxon.dialog.register('alertify'", jaxon()->script()); |
|
| 238 | +} |
|
| 239 | + |
|
| 240 | +public function testBootboxLibrary() |
|
| 241 | +{ |
|
| 242 | +jaxon()->setAppOption('dialogs.lib.use', ['bootbox']); |
|
| 243 | + |
|
| 244 | +$this->assertStringContainsString('bootbox.min.js', jaxon()->js()); |
|
| 245 | +$this->assertStringContainsString("jaxon.dialog.register('bootbox'", jaxon()->script()); |
|
| 246 | +} |
|
| 247 | + |
|
| 248 | +public function testBootstrap3Library() |
|
| 249 | +{ |
|
| 250 | +jaxon()->setAppOption('dialogs.lib.use', ['bootstrap3']); |
|
| 251 | + |
|
| 252 | +$this->assertStringContainsString("jaxon.dialog.register('bootstrap3'", jaxon()->script()); |
|
| 253 | +} |
|
| 254 | + |
|
| 255 | +public function testBootstrap4Library() |
|
| 256 | +{ |
|
| 257 | +jaxon()->setAppOption('dialogs.lib.use', ['bootstrap4']); |
|
| 258 | + |
|
| 259 | +$this->assertStringContainsString("jaxon.dialog.register('bootstrap4'", jaxon()->script()); |
|
| 260 | +} |
|
| 261 | + |
|
| 262 | +public function testBootstrap5Library() |
|
| 263 | +{ |
|
| 264 | +jaxon()->setAppOption('dialogs.lib.use', ['bootstrap5']); |
|
| 265 | + |
|
| 266 | +$this->assertStringContainsString("jaxon.dialog.register('bootstrap5'", jaxon()->script()); |
|
| 267 | +} |
|
| 268 | + |
|
| 269 | +public function testButterupLibrary() |
|
| 270 | +{ |
|
| 271 | +jaxon()->setAppOption('dialogs.lib.use', ['butterup']); |
|
| 272 | + |
|
| 273 | +$this->assertStringContainsString('butterup.min.js', jaxon()->js()); |
|
| 274 | +$this->assertStringContainsString('butterup.min.css', jaxon()->css()); |
|
| 275 | +$this->assertStringContainsString("jaxon.dialog.register('butterup'", jaxon()->script()); |
|
| 276 | +} |
|
| 277 | + |
|
| 278 | +public function testCuteAlertLibrary() |
|
| 279 | +{ |
|
| 280 | +jaxon()->setAppOption('dialogs.lib.use', ['cute']); |
|
| 281 | + |
|
| 282 | +$this->assertStringContainsString('cute-alert/cute-alert.js', jaxon()->js()); |
|
| 283 | +$this->assertStringContainsString('cute-alert/style.css', jaxon()->css()); |
|
| 284 | +$this->assertStringContainsString("jaxon.dialog.register('cute'", jaxon()->script()); |
|
| 285 | +} |
|
| 286 | + |
|
| 287 | +public function testIziToastLibrary() |
|
| 288 | +{ |
|
| 289 | +jaxon()->setAppOption('dialogs.lib.use', ['izitoast']); |
|
| 290 | + |
|
| 291 | +$this->assertStringContainsString('js/iziToast.min.js', jaxon()->js()); |
|
| 292 | +$this->assertStringContainsString('css/iziToast.min.css', jaxon()->css()); |
|
| 293 | +$this->assertStringContainsString("jaxon.dialog.register('izitoast'", jaxon()->script()); |
|
| 294 | +} |
|
| 295 | + |
|
| 296 | +public function testJAlertLibrary() |
|
| 297 | +{ |
|
| 298 | +jaxon()->setAppOption('dialogs.lib.use', ['jalert']); |
|
| 299 | + |
|
| 300 | +$this->assertStringContainsString('jAlert.min.js', jaxon()->js()); |
|
| 301 | +$this->assertStringContainsString('jAlert.min.css', jaxon()->css()); |
|
| 302 | +$this->assertStringContainsString("jaxon.dialog.register('jalert'", jaxon()->script()); |
|
| 303 | +} |
|
| 304 | + |
|
| 305 | +public function testJQueryConfirmLibrary() |
|
| 306 | +{ |
|
| 307 | +jaxon()->setAppOption('dialogs.lib.use', ['jconfirm']); |
|
| 308 | + |
|
| 309 | +$this->assertStringContainsString('jquery-confirm.min.js', jaxon()->js()); |
|
| 310 | +$this->assertStringContainsString('jquery-confirm.min.css', jaxon()->css()); |
|
| 311 | +$this->assertStringContainsString("jaxon.dialog.register('jconfirm'", jaxon()->script()); |
|
| 312 | +} |
|
| 313 | + |
|
| 314 | +public function testNotifyLibrary() |
|
| 315 | +{ |
|
| 316 | +jaxon()->setAppOption('dialogs.lib.use', ['notify']); |
|
| 317 | + |
|
| 318 | +$this->assertStringContainsString('notify.min.js', jaxon()->js()); |
|
| 319 | +$this->assertStringContainsString("jaxon.dialog.register('notify'", jaxon()->script()); |
|
| 320 | +} |
|
| 321 | + |
|
| 322 | +public function testNotyLibrary() |
|
| 323 | +{ |
|
| 324 | +jaxon()->setAppOption('dialogs.lib.use', ['noty']); |
|
| 325 | + |
|
| 326 | +$this->assertStringContainsString('noty.min.js', jaxon()->js()); |
|
| 327 | +$this->assertStringContainsString('noty.min.css', jaxon()->css()); |
|
| 328 | +$this->assertStringContainsString("jaxon.dialog.register('noty'", jaxon()->script()); |
|
| 329 | +} |
|
| 330 | + |
|
| 331 | +public function testNotyfLibrary() |
|
| 332 | +{ |
|
| 333 | +jaxon()->setAppOption('dialogs.lib.use', ['notyf']); |
|
| 334 | + |
|
| 335 | +$this->assertStringContainsString('notyf.min.js', jaxon()->js()); |
|
| 336 | +$this->assertStringContainsString('notyf.min.css', jaxon()->css()); |
|
| 337 | +$this->assertStringContainsString("jaxon.dialog.register('notyf'", jaxon()->script()); |
|
| 338 | +} |
|
| 339 | + |
|
| 340 | +public function testQuantumLibrary() |
|
| 341 | +{ |
|
| 342 | +jaxon()->setAppOption('dialogs.lib.use', ['quantum']); |
|
| 343 | + |
|
| 344 | +$this->assertStringContainsString('minfile/quantumalert.js', jaxon()->js()); |
|
| 345 | +$this->assertStringContainsString("jaxon.dialog.register('quantum'", jaxon()->script()); |
|
| 346 | +} |
|
| 347 | + |
|
| 348 | +public function testSweetAlertLibrary() |
|
| 349 | +{ |
|
| 350 | +jaxon()->setAppOption('dialogs.lib.use', ['sweetalert']); |
|
| 351 | + |
|
| 352 | +$this->assertStringContainsString('sweetalert.min.js', jaxon()->js()); |
|
| 353 | +$this->assertStringContainsString("jaxon.dialog.register('sweetalert'", jaxon()->script()); |
|
| 354 | +} |
|
| 355 | + |
|
| 356 | +public function testTingleLibrary() |
|
| 357 | +{ |
|
| 358 | +jaxon()->setAppOption('dialogs.lib.use', ['tingle']); |
|
| 359 | + |
|
| 360 | +$this->assertStringContainsString('tingle.min.js', jaxon()->js()); |
|
| 361 | +$this->assertStringContainsString('tingle.min.css', jaxon()->css()); |
|
| 362 | +$this->assertStringContainsString("jaxon.dialog.register('tingle'", jaxon()->script()); |
|
| 363 | +} |
|
| 364 | + |
|
| 365 | +public function testToastrLibrary() |
|
| 366 | +{ |
|
| 367 | +jaxon()->setAppOption('dialogs.lib.use', ['toastr']); |
|
| 368 | + |
|
| 369 | +$this->assertStringContainsString('toastr.min.js', jaxon()->js()); |
|
| 370 | +$this->assertStringContainsString('build/toastr.min.css', jaxon()->css()); |
|
| 371 | +$this->assertStringContainsString("jaxon.dialog.register('toastr'", jaxon()->script()); |
|
| 372 | +} |
|
| 373 | + |
|
| 374 | +/** |
|
| 375 | 375 | * @throws SetupException |
| 376 | 376 | */ |
| 377 | - public function testErrorRegisterIncorrectDialogClass() |
|
| 378 | - { |
|
| 379 | - $this->expectException(SetupException::class); |
|
| 380 | - dialog()->registerLibrary(Dialog::class, 'incorrect'); |
|
| 381 | - } |
|
| 382 | - |
|
| 383 | - public function testErrorRegisterIncorrectDialogClassWithInterface() |
|
| 384 | - { |
|
| 385 | - $this->expectException(SetupException::class); |
|
| 386 | - dialog()->registerLibrary(ClassWithInterface::class, 'incorrect'); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - public function testErrorSetWrongAlertLibrary() |
|
| 390 | - { |
|
| 391 | - $this->expectException(SetupException::class); |
|
| 392 | - jaxon()->setAppOption('dialogs.default.alert', 'incorrect'); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - public function testErrorSetWrongModalLibrary() |
|
| 396 | - { |
|
| 397 | - $this->expectException(SetupException::class); |
|
| 398 | - jaxon()->setAppOption('dialogs.default.modal', 'incorrect'); |
|
| 399 | - } |
|
| 400 | - |
|
| 401 | - public function testErrorSetWrongConfirmLibrary() |
|
| 402 | - { |
|
| 403 | - $this->expectException(SetupException::class); |
|
| 404 | - jaxon()->setAppOption('dialogs.default.confirm', 'incorrect'); |
|
| 405 | - } |
|
| 377 | +public function testErrorRegisterIncorrectDialogClass() |
|
| 378 | +{ |
|
| 379 | +$this->expectException(SetupException::class); |
|
| 380 | +dialog()->registerLibrary(Dialog::class, 'incorrect'); |
|
| 381 | +} |
|
| 382 | + |
|
| 383 | +public function testErrorRegisterIncorrectDialogClassWithInterface() |
|
| 384 | +{ |
|
| 385 | +$this->expectException(SetupException::class); |
|
| 386 | +dialog()->registerLibrary(ClassWithInterface::class, 'incorrect'); |
|
| 387 | +} |
|
| 388 | + |
|
| 389 | +public function testErrorSetWrongAlertLibrary() |
|
| 390 | +{ |
|
| 391 | +$this->expectException(SetupException::class); |
|
| 392 | +jaxon()->setAppOption('dialogs.default.alert', 'incorrect'); |
|
| 393 | +} |
|
| 394 | + |
|
| 395 | +public function testErrorSetWrongModalLibrary() |
|
| 396 | +{ |
|
| 397 | +$this->expectException(SetupException::class); |
|
| 398 | +jaxon()->setAppOption('dialogs.default.modal', 'incorrect'); |
|
| 399 | +} |
|
| 400 | + |
|
| 401 | +public function testErrorSetWrongConfirmLibrary() |
|
| 402 | +{ |
|
| 403 | +$this->expectException(SetupException::class); |
|
| 404 | +jaxon()->setAppOption('dialogs.default.confirm', 'incorrect'); |
|
| 405 | +} |
|
| 406 | 406 | } |
@@ -21,472 +21,472 @@ |
||
| 21 | 21 | |
| 22 | 22 | class CallTest extends TestCase |
| 23 | 23 | { |
| 24 | - /** |
|
| 24 | +/** |
|
| 25 | 25 | * @throws SetupException |
| 26 | 26 | */ |
| 27 | - public function setUp(): void |
|
| 28 | - { |
|
| 29 | - _register(); |
|
| 30 | - jaxon()->setOption('core.prefix.class', ''); |
|
| 31 | - jaxon()->setOption('core.request.uri', 'http://example.test/path'); |
|
| 32 | - jaxon()->register(Jaxon::CALLABLE_CLASS, Dialog::class); |
|
| 33 | - dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - /** |
|
| 27 | +public function setUp(): void |
|
| 28 | +{ |
|
| 29 | +_register(); |
|
| 30 | +jaxon()->setOption('core.prefix.class', ''); |
|
| 31 | +jaxon()->setOption('core.request.uri', 'http://example.test/path'); |
|
| 32 | +jaxon()->register(Jaxon::CALLABLE_CLASS, Dialog::class); |
|
| 33 | +dialog()->registerLibrary(TestDialogLibrary::class, TestDialogLibrary::NAME); |
|
| 34 | +} |
|
| 35 | + |
|
| 36 | +/** |
|
| 37 | 37 | * @throws SetupException |
| 38 | 38 | */ |
| 39 | - public function tearDown(): void |
|
| 40 | - { |
|
| 41 | - jaxon()->reset(); |
|
| 42 | - parent::tearDown(); |
|
| 43 | - } |
|
| 39 | +public function tearDown(): void |
|
| 40 | +{ |
|
| 41 | +jaxon()->reset(); |
|
| 42 | +parent::tearDown(); |
|
| 43 | +} |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | +/** |
|
| 46 | 46 | * @throws RequestException |
| 47 | 47 | */ |
| 48 | - public function testDefaultDialogSuccess() |
|
| 49 | - { |
|
| 50 | - // The server request |
|
| 51 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 52 | - return $c->g(ServerRequestCreator::class) |
|
| 53 | - ->fromGlobals() |
|
| 54 | - ->withQueryParams([ |
|
| 55 | - 'jxncall' => json_encode([ |
|
| 56 | - 'type' => 'class', |
|
| 57 | - 'name' => 'Dialog', |
|
| 58 | - 'method' => 'success', |
|
| 59 | - 'args' => [], |
|
| 60 | - ]), |
|
| 61 | - ]); |
|
| 62 | - }); |
|
| 63 | - |
|
| 64 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 65 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 66 | - |
|
| 67 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 68 | - $this->assertCount(1, $aCommands); |
|
| 69 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 48 | +public function testDefaultDialogSuccess() |
|
| 49 | +{ |
|
| 50 | +// The server request |
|
| 51 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 52 | +return $c->g(ServerRequestCreator::class) |
|
| 53 | + ->fromGlobals() |
|
| 54 | + ->withQueryParams([ |
|
| 55 | + 'jxncall' => json_encode([ |
|
| 56 | + 'type' => 'class', |
|
| 57 | + 'name' => 'Dialog', |
|
| 58 | + 'method' => 'success', |
|
| 59 | + 'args' => [], |
|
| 60 | + ]), |
|
| 61 | + ]); |
|
| 62 | +}); |
|
| 63 | + |
|
| 64 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 65 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 66 | + |
|
| 67 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 68 | +$this->assertCount(1, $aCommands); |
|
| 69 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 70 | +} |
|
| 71 | + |
|
| 72 | +/** |
|
| 73 | 73 | * @throws RequestException |
| 74 | 74 | */ |
| 75 | - public function testDialogLibrarySuccess() |
|
| 76 | - { |
|
| 77 | - jaxon()->setAppOptions([ |
|
| 78 | - 'modal' => 'alertify', |
|
| 79 | - 'alert' => 'alertify', |
|
| 80 | - 'confirm' => 'alertify', |
|
| 81 | - ], 'dialogs.default'); |
|
| 82 | - // The server request |
|
| 83 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 84 | - return $c->g(ServerRequestCreator::class) |
|
| 85 | - ->fromGlobals() |
|
| 86 | - ->withQueryParams([ |
|
| 87 | - 'jxncall' => json_encode([ |
|
| 88 | - 'type' => 'class', |
|
| 89 | - 'name' => 'Dialog', |
|
| 90 | - 'method' => 'success', |
|
| 91 | - 'args' => [], |
|
| 92 | - ]), |
|
| 93 | - ]); |
|
| 94 | - }); |
|
| 95 | - |
|
| 96 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 97 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 98 | - |
|
| 99 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 100 | - $this->assertCount(1, $aCommands); |
|
| 101 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 102 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 75 | +public function testDialogLibrarySuccess() |
|
| 76 | +{ |
|
| 77 | +jaxon()->setAppOptions([ |
|
| 78 | +'modal' => 'alertify', |
|
| 79 | +'alert' => 'alertify', |
|
| 80 | +'confirm' => 'alertify', |
|
| 81 | +], 'dialogs.default'); |
|
| 82 | +// The server request |
|
| 83 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 84 | +return $c->g(ServerRequestCreator::class) |
|
| 85 | + ->fromGlobals() |
|
| 86 | + ->withQueryParams([ |
|
| 87 | + 'jxncall' => json_encode([ |
|
| 88 | + 'type' => 'class', |
|
| 89 | + 'name' => 'Dialog', |
|
| 90 | + 'method' => 'success', |
|
| 91 | + 'args' => [], |
|
| 92 | + ]), |
|
| 93 | + ]); |
|
| 94 | +}); |
|
| 95 | + |
|
| 96 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 97 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 98 | + |
|
| 99 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 100 | +$this->assertCount(1, $aCommands); |
|
| 101 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 102 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 103 | +} |
|
| 104 | + |
|
| 105 | +/** |
|
| 106 | 106 | * @throws RequestException |
| 107 | 107 | */ |
| 108 | - public function testDefaultDialogWarning() |
|
| 109 | - { |
|
| 110 | - // The server request |
|
| 111 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 112 | - return $c->g(ServerRequestCreator::class) |
|
| 113 | - ->fromGlobals() |
|
| 114 | - ->withQueryParams([ |
|
| 115 | - 'jxncall' => json_encode([ |
|
| 116 | - 'type' => 'class', |
|
| 117 | - 'name' => 'Dialog', |
|
| 118 | - 'method' => 'warning', |
|
| 119 | - 'args' => [], |
|
| 120 | - ]), |
|
| 121 | - ]); |
|
| 122 | - }); |
|
| 123 | - |
|
| 124 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 125 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 126 | - |
|
| 127 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 128 | - $this->assertCount(1, $aCommands); |
|
| 129 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 108 | +public function testDefaultDialogWarning() |
|
| 109 | +{ |
|
| 110 | +// The server request |
|
| 111 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 112 | +return $c->g(ServerRequestCreator::class) |
|
| 113 | + ->fromGlobals() |
|
| 114 | + ->withQueryParams([ |
|
| 115 | + 'jxncall' => json_encode([ |
|
| 116 | + 'type' => 'class', |
|
| 117 | + 'name' => 'Dialog', |
|
| 118 | + 'method' => 'warning', |
|
| 119 | + 'args' => [], |
|
| 120 | + ]), |
|
| 121 | + ]); |
|
| 122 | +}); |
|
| 123 | + |
|
| 124 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 125 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 126 | + |
|
| 127 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 128 | +$this->assertCount(1, $aCommands); |
|
| 129 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 130 | +} |
|
| 131 | + |
|
| 132 | +/** |
|
| 133 | 133 | * @throws RequestException |
| 134 | 134 | */ |
| 135 | - public function testDialogLibraryWarning() |
|
| 136 | - { |
|
| 137 | - jaxon()->setAppOptions([ |
|
| 138 | - 'modal' => 'alertify', |
|
| 139 | - 'alert' => 'alertify', |
|
| 140 | - 'confirm' => 'alertify', |
|
| 141 | - ], 'dialogs.default'); |
|
| 142 | - // The server request |
|
| 143 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 144 | - return $c->g(ServerRequestCreator::class) |
|
| 145 | - ->fromGlobals() |
|
| 146 | - ->withQueryParams([ |
|
| 147 | - 'jxncall' => json_encode([ |
|
| 148 | - 'type' => 'class', |
|
| 149 | - 'name' => 'Dialog', |
|
| 150 | - 'method' => 'warning', |
|
| 151 | - 'args' => [], |
|
| 152 | - ]), |
|
| 153 | - ]); |
|
| 154 | - }); |
|
| 155 | - |
|
| 156 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 157 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 158 | - |
|
| 159 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 160 | - $this->assertCount(1, $aCommands); |
|
| 161 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 162 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 135 | +public function testDialogLibraryWarning() |
|
| 136 | +{ |
|
| 137 | +jaxon()->setAppOptions([ |
|
| 138 | +'modal' => 'alertify', |
|
| 139 | +'alert' => 'alertify', |
|
| 140 | +'confirm' => 'alertify', |
|
| 141 | +], 'dialogs.default'); |
|
| 142 | +// The server request |
|
| 143 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 144 | +return $c->g(ServerRequestCreator::class) |
|
| 145 | + ->fromGlobals() |
|
| 146 | + ->withQueryParams([ |
|
| 147 | + 'jxncall' => json_encode([ |
|
| 148 | + 'type' => 'class', |
|
| 149 | + 'name' => 'Dialog', |
|
| 150 | + 'method' => 'warning', |
|
| 151 | + 'args' => [], |
|
| 152 | + ]), |
|
| 153 | + ]); |
|
| 154 | +}); |
|
| 155 | + |
|
| 156 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 157 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 158 | + |
|
| 159 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 160 | +$this->assertCount(1, $aCommands); |
|
| 161 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 162 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 163 | +} |
|
| 164 | + |
|
| 165 | +/** |
|
| 166 | 166 | * @throws RequestException |
| 167 | 167 | */ |
| 168 | - public function testDefaultDialogInfo() |
|
| 169 | - { |
|
| 170 | - // The server request |
|
| 171 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 172 | - return $c->g(ServerRequestCreator::class) |
|
| 173 | - ->fromGlobals() |
|
| 174 | - ->withQueryParams([ |
|
| 175 | - 'jxncall' => json_encode([ |
|
| 176 | - 'type' => 'class', |
|
| 177 | - 'name' => 'Dialog', |
|
| 178 | - 'method' => 'info', |
|
| 179 | - 'args' => [], |
|
| 180 | - ]), |
|
| 181 | - ]); |
|
| 182 | - }); |
|
| 183 | - |
|
| 184 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 185 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 186 | - |
|
| 187 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 188 | - $this->assertCount(1, $aCommands); |
|
| 189 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - /** |
|
| 168 | +public function testDefaultDialogInfo() |
|
| 169 | +{ |
|
| 170 | +// The server request |
|
| 171 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 172 | +return $c->g(ServerRequestCreator::class) |
|
| 173 | + ->fromGlobals() |
|
| 174 | + ->withQueryParams([ |
|
| 175 | + 'jxncall' => json_encode([ |
|
| 176 | + 'type' => 'class', |
|
| 177 | + 'name' => 'Dialog', |
|
| 178 | + 'method' => 'info', |
|
| 179 | + 'args' => [], |
|
| 180 | + ]), |
|
| 181 | + ]); |
|
| 182 | +}); |
|
| 183 | + |
|
| 184 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 185 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 186 | + |
|
| 187 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 188 | +$this->assertCount(1, $aCommands); |
|
| 189 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 190 | +} |
|
| 191 | + |
|
| 192 | +/** |
|
| 193 | 193 | * @throws RequestException |
| 194 | 194 | */ |
| 195 | - public function testDialogLibraryInfo() |
|
| 196 | - { |
|
| 197 | - jaxon()->setAppOptions([ |
|
| 198 | - 'modal' => 'alertify', |
|
| 199 | - 'alert' => 'alertify', |
|
| 200 | - 'confirm' => 'alertify', |
|
| 201 | - ], 'dialogs.default'); |
|
| 202 | - // The server request |
|
| 203 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 204 | - return $c->g(ServerRequestCreator::class) |
|
| 205 | - ->fromGlobals() |
|
| 206 | - ->withQueryParams([ |
|
| 207 | - 'jxncall' => json_encode([ |
|
| 208 | - 'type' => 'class', |
|
| 209 | - 'name' => 'Dialog', |
|
| 210 | - 'method' => 'info', |
|
| 211 | - 'args' => [], |
|
| 212 | - ]), |
|
| 213 | - ]); |
|
| 214 | - }); |
|
| 215 | - |
|
| 216 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 217 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 218 | - |
|
| 219 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 220 | - $this->assertCount(1, $aCommands); |
|
| 221 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 222 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - /** |
|
| 195 | +public function testDialogLibraryInfo() |
|
| 196 | +{ |
|
| 197 | +jaxon()->setAppOptions([ |
|
| 198 | +'modal' => 'alertify', |
|
| 199 | +'alert' => 'alertify', |
|
| 200 | +'confirm' => 'alertify', |
|
| 201 | +], 'dialogs.default'); |
|
| 202 | +// The server request |
|
| 203 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 204 | +return $c->g(ServerRequestCreator::class) |
|
| 205 | + ->fromGlobals() |
|
| 206 | + ->withQueryParams([ |
|
| 207 | + 'jxncall' => json_encode([ |
|
| 208 | + 'type' => 'class', |
|
| 209 | + 'name' => 'Dialog', |
|
| 210 | + 'method' => 'info', |
|
| 211 | + 'args' => [], |
|
| 212 | + ]), |
|
| 213 | + ]); |
|
| 214 | +}); |
|
| 215 | + |
|
| 216 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 217 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 218 | + |
|
| 219 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 220 | +$this->assertCount(1, $aCommands); |
|
| 221 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 222 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 223 | +} |
|
| 224 | + |
|
| 225 | +/** |
|
| 226 | 226 | * @throws RequestException |
| 227 | 227 | */ |
| 228 | - public function testDefaultDialogError() |
|
| 229 | - { |
|
| 230 | - // The server request |
|
| 231 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 232 | - return $c->g(ServerRequestCreator::class) |
|
| 233 | - ->fromGlobals() |
|
| 234 | - ->withQueryParams([ |
|
| 235 | - 'jxncall' => json_encode([ |
|
| 236 | - 'type' => 'class', |
|
| 237 | - 'name' => 'Dialog', |
|
| 238 | - 'method' => 'error', |
|
| 239 | - 'args' => [], |
|
| 240 | - ]), |
|
| 241 | - ]); |
|
| 242 | - }); |
|
| 243 | - |
|
| 244 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 245 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 246 | - |
|
| 247 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 248 | - $this->assertCount(1, $aCommands); |
|
| 249 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 228 | +public function testDefaultDialogError() |
|
| 229 | +{ |
|
| 230 | +// The server request |
|
| 231 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 232 | +return $c->g(ServerRequestCreator::class) |
|
| 233 | + ->fromGlobals() |
|
| 234 | + ->withQueryParams([ |
|
| 235 | + 'jxncall' => json_encode([ |
|
| 236 | + 'type' => 'class', |
|
| 237 | + 'name' => 'Dialog', |
|
| 238 | + 'method' => 'error', |
|
| 239 | + 'args' => [], |
|
| 240 | + ]), |
|
| 241 | + ]); |
|
| 242 | +}); |
|
| 243 | + |
|
| 244 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 245 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 246 | + |
|
| 247 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 248 | +$this->assertCount(1, $aCommands); |
|
| 249 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 250 | +} |
|
| 251 | + |
|
| 252 | +/** |
|
| 253 | 253 | * @throws RequestException |
| 254 | 254 | */ |
| 255 | - public function testDialogLibraryError() |
|
| 256 | - { |
|
| 257 | - jaxon()->setAppOptions([ |
|
| 258 | - 'modal' => 'alertify', |
|
| 259 | - 'alert' => 'alertify', |
|
| 260 | - 'confirm' => 'alertify', |
|
| 261 | - ], 'dialogs.default'); |
|
| 262 | - // The server request |
|
| 263 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 264 | - return $c->g(ServerRequestCreator::class) |
|
| 265 | - ->fromGlobals() |
|
| 266 | - ->withQueryParams([ |
|
| 267 | - 'jxncall' => json_encode([ |
|
| 268 | - 'type' => 'class', |
|
| 269 | - 'name' => 'Dialog', |
|
| 270 | - 'method' => 'error', |
|
| 271 | - 'args' => [], |
|
| 272 | - ]), |
|
| 273 | - ]); |
|
| 274 | - }); |
|
| 275 | - |
|
| 276 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 277 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 278 | - |
|
| 279 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 280 | - $this->assertCount(1, $aCommands); |
|
| 281 | - $this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 282 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 283 | - } |
|
| 284 | - |
|
| 285 | - /** |
|
| 255 | +public function testDialogLibraryError() |
|
| 256 | +{ |
|
| 257 | +jaxon()->setAppOptions([ |
|
| 258 | +'modal' => 'alertify', |
|
| 259 | +'alert' => 'alertify', |
|
| 260 | +'confirm' => 'alertify', |
|
| 261 | +], 'dialogs.default'); |
|
| 262 | +// The server request |
|
| 263 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 264 | +return $c->g(ServerRequestCreator::class) |
|
| 265 | +->fromGlobals() |
|
| 266 | +->withQueryParams([ |
|
| 267 | + 'jxncall' => json_encode([ |
|
| 268 | + 'type' => 'class', |
|
| 269 | + 'name' => 'Dialog', |
|
| 270 | + 'method' => 'error', |
|
| 271 | + 'args' => [], |
|
| 272 | + ]), |
|
| 273 | +]); |
|
| 274 | +}); |
|
| 275 | + |
|
| 276 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 277 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 278 | + |
|
| 279 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 280 | +$this->assertCount(1, $aCommands); |
|
| 281 | +$this->assertEquals('dialog.alert.show', $aCommands[0]['name']); |
|
| 282 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 283 | +} |
|
| 284 | + |
|
| 285 | +/** |
|
| 286 | 286 | * @throws RequestException |
| 287 | 287 | */ |
| 288 | - public function testDialogLibraryShow() |
|
| 289 | - { |
|
| 290 | - jaxon()->setAppOptions([ |
|
| 291 | - 'modal' => 'alertify', |
|
| 292 | - 'alert' => 'alertify', |
|
| 293 | - 'confirm' => 'alertify', |
|
| 294 | - ], 'dialogs.default'); |
|
| 295 | - // The server request |
|
| 296 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 297 | - return $c->g(ServerRequestCreator::class) |
|
| 298 | - ->fromGlobals() |
|
| 299 | - ->withQueryParams([ |
|
| 300 | - 'jxncall' => json_encode([ |
|
| 301 | - 'type' => 'class', |
|
| 302 | - 'name' => 'Dialog', |
|
| 303 | - 'method' => 'show', |
|
| 304 | - 'args' => [], |
|
| 305 | - ]), |
|
| 306 | - ]); |
|
| 307 | - }); |
|
| 308 | - |
|
| 309 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 310 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 311 | - |
|
| 312 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 313 | - $this->assertCount(1, $aCommands); |
|
| 314 | - $this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 315 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 288 | +public function testDialogLibraryShow() |
|
| 289 | +{ |
|
| 290 | +jaxon()->setAppOptions([ |
|
| 291 | +'modal' => 'alertify', |
|
| 292 | +'alert' => 'alertify', |
|
| 293 | +'confirm' => 'alertify', |
|
| 294 | +], 'dialogs.default'); |
|
| 295 | +// The server request |
|
| 296 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 297 | +return $c->g(ServerRequestCreator::class) |
|
| 298 | + ->fromGlobals() |
|
| 299 | + ->withQueryParams([ |
|
| 300 | + 'jxncall' => json_encode([ |
|
| 301 | + 'type' => 'class', |
|
| 302 | + 'name' => 'Dialog', |
|
| 303 | + 'method' => 'show', |
|
| 304 | + 'args' => [], |
|
| 305 | + ]), |
|
| 306 | + ]); |
|
| 307 | +}); |
|
| 308 | + |
|
| 309 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 310 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 311 | + |
|
| 312 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 313 | +$this->assertCount(1, $aCommands); |
|
| 314 | +$this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 315 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 316 | +} |
|
| 317 | + |
|
| 318 | +/** |
|
| 319 | 319 | * @throws RequestException |
| 320 | 320 | */ |
| 321 | - public function testBootboxLibraryShow() |
|
| 322 | - { |
|
| 323 | - jaxon()->setAppOptions([ |
|
| 324 | - 'modal' => 'alertify', |
|
| 325 | - 'alert' => 'alertify', |
|
| 326 | - 'confirm' => 'alertify', |
|
| 327 | - ], 'dialogs.default'); |
|
| 328 | - // The server request |
|
| 329 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 330 | - return $c->g(ServerRequestCreator::class) |
|
| 331 | - ->fromGlobals() |
|
| 332 | - ->withQueryParams([ |
|
| 333 | - 'jxncall' => json_encode([ |
|
| 334 | - 'type' => 'class', |
|
| 335 | - 'name' => 'Dialog', |
|
| 336 | - 'method' => 'show', |
|
| 337 | - 'args' => [], |
|
| 338 | - ]), |
|
| 339 | - ]); |
|
| 340 | - }); |
|
| 341 | - |
|
| 342 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 343 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 344 | - |
|
| 345 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 346 | - $this->assertCount(1, $aCommands); |
|
| 347 | - $this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 348 | - } |
|
| 349 | - |
|
| 350 | - /** |
|
| 321 | +public function testBootboxLibraryShow() |
|
| 322 | +{ |
|
| 323 | +jaxon()->setAppOptions([ |
|
| 324 | +'modal' => 'alertify', |
|
| 325 | +'alert' => 'alertify', |
|
| 326 | +'confirm' => 'alertify', |
|
| 327 | +], 'dialogs.default'); |
|
| 328 | +// The server request |
|
| 329 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 330 | +return $c->g(ServerRequestCreator::class) |
|
| 331 | + ->fromGlobals() |
|
| 332 | + ->withQueryParams([ |
|
| 333 | + 'jxncall' => json_encode([ |
|
| 334 | + 'type' => 'class', |
|
| 335 | + 'name' => 'Dialog', |
|
| 336 | + 'method' => 'show', |
|
| 337 | + 'args' => [], |
|
| 338 | + ]), |
|
| 339 | + ]); |
|
| 340 | +}); |
|
| 341 | + |
|
| 342 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 343 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 344 | + |
|
| 345 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 346 | +$this->assertCount(1, $aCommands); |
|
| 347 | +$this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 348 | +} |
|
| 349 | + |
|
| 350 | +/** |
|
| 351 | 351 | * @throws RequestException |
| 352 | 352 | */ |
| 353 | - public function testDialogLibraryShowWith() |
|
| 354 | - { |
|
| 355 | - jaxon()->setAppOptions([ |
|
| 356 | - 'modal' => 'alertify', |
|
| 357 | - 'alert' => 'alertify', |
|
| 358 | - 'confirm' => 'alertify', |
|
| 359 | - ], 'dialogs.default'); |
|
| 360 | - // The server request |
|
| 361 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 362 | - return $c->g(ServerRequestCreator::class) |
|
| 363 | - ->fromGlobals() |
|
| 364 | - ->withQueryParams([ |
|
| 365 | - 'jxncall' => json_encode([ |
|
| 366 | - 'type' => 'class', |
|
| 367 | - 'name' => 'Dialog', |
|
| 368 | - 'method' => 'showWith', |
|
| 369 | - 'args' => [], |
|
| 370 | - ]), |
|
| 371 | - ]); |
|
| 372 | - }); |
|
| 373 | - |
|
| 374 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 375 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 376 | - |
|
| 377 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 378 | - $this->assertCount(1, $aCommands); |
|
| 379 | - $this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - /** |
|
| 353 | +public function testDialogLibraryShowWith() |
|
| 354 | +{ |
|
| 355 | +jaxon()->setAppOptions([ |
|
| 356 | +'modal' => 'alertify', |
|
| 357 | +'alert' => 'alertify', |
|
| 358 | +'confirm' => 'alertify', |
|
| 359 | +], 'dialogs.default'); |
|
| 360 | +// The server request |
|
| 361 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 362 | +return $c->g(ServerRequestCreator::class) |
|
| 363 | + ->fromGlobals() |
|
| 364 | + ->withQueryParams([ |
|
| 365 | + 'jxncall' => json_encode([ |
|
| 366 | + 'type' => 'class', |
|
| 367 | + 'name' => 'Dialog', |
|
| 368 | + 'method' => 'showWith', |
|
| 369 | + 'args' => [], |
|
| 370 | + ]), |
|
| 371 | + ]); |
|
| 372 | +}); |
|
| 373 | + |
|
| 374 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 375 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 376 | + |
|
| 377 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 378 | +$this->assertCount(1, $aCommands); |
|
| 379 | +$this->assertEquals('dialog.modal.show', $aCommands[0]['name']); |
|
| 380 | +} |
|
| 381 | + |
|
| 382 | +/** |
|
| 383 | 383 | * @throws RequestException |
| 384 | 384 | */ |
| 385 | - public function testDialogLibraryHide() |
|
| 386 | - { |
|
| 387 | - jaxon()->setAppOptions([ |
|
| 388 | - 'modal' => 'alertify', |
|
| 389 | - 'alert' => 'alertify', |
|
| 390 | - 'confirm' => 'alertify', |
|
| 391 | - ], 'dialogs.default'); |
|
| 392 | - // The server request |
|
| 393 | - jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 394 | - return $c->g(ServerRequestCreator::class) |
|
| 395 | - ->fromGlobals() |
|
| 396 | - ->withQueryParams([ |
|
| 397 | - 'jxncall' => json_encode([ |
|
| 398 | - 'type' => 'class', |
|
| 399 | - 'name' => 'Dialog', |
|
| 400 | - 'method' => 'hide', |
|
| 401 | - 'args' => [], |
|
| 402 | - ]), |
|
| 403 | - ]); |
|
| 404 | - }); |
|
| 405 | - |
|
| 406 | - $this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 407 | - jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 408 | - |
|
| 409 | - $aCommands = jaxon()->getResponse()->getCommands(); |
|
| 410 | - $this->assertCount(1, $aCommands); |
|
| 411 | - $this->assertEquals('dialog.modal.hide', $aCommands[0]['name']); |
|
| 412 | - $this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - /** |
|
| 385 | +public function testDialogLibraryHide() |
|
| 386 | +{ |
|
| 387 | +jaxon()->setAppOptions([ |
|
| 388 | +'modal' => 'alertify', |
|
| 389 | +'alert' => 'alertify', |
|
| 390 | +'confirm' => 'alertify', |
|
| 391 | +], 'dialogs.default'); |
|
| 392 | +// The server request |
|
| 393 | +jaxon()->di()->set(ServerRequestInterface::class, function($c) { |
|
| 394 | +return $c->g(ServerRequestCreator::class) |
|
| 395 | + ->fromGlobals() |
|
| 396 | + ->withQueryParams([ |
|
| 397 | + 'jxncall' => json_encode([ |
|
| 398 | + 'type' => 'class', |
|
| 399 | + 'name' => 'Dialog', |
|
| 400 | + 'method' => 'hide', |
|
| 401 | + 'args' => [], |
|
| 402 | + ]), |
|
| 403 | + ]); |
|
| 404 | +}); |
|
| 405 | + |
|
| 406 | +$this->assertTrue(jaxon()->di()->getRequestHandler()->canProcessRequest()); |
|
| 407 | +jaxon()->di()->getRequestHandler()->processRequest(); |
|
| 408 | + |
|
| 409 | +$aCommands = jaxon()->getResponse()->getCommands(); |
|
| 410 | +$this->assertCount(1, $aCommands); |
|
| 411 | +$this->assertEquals('dialog.modal.hide', $aCommands[0]['name']); |
|
| 412 | +$this->assertEquals('dialog', $aCommands[0]['options']['plugin']); |
|
| 413 | +} |
|
| 414 | + |
|
| 415 | +/** |
|
| 416 | 416 | * @throws SetupException |
| 417 | 417 | */ |
| 418 | - public function testConfirmMessageSuccess() |
|
| 419 | - { |
|
| 420 | - jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 421 | - jaxon()->setAppOption('dialogs.default.alert', 'cute'); |
|
| 422 | - jaxon()->setAppOption('dialogs.default.confirm', 'noty'); |
|
| 423 | - $this->assertEquals( |
|
| 424 | - 'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 425 | - '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 426 | - '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 427 | - '"alert":{"lib":"cute","message":{"type":"success","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 428 | - rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 429 | - ->elseSuccess("No confirm")->__toString() |
|
| 430 | - ); |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - /** |
|
| 418 | +public function testConfirmMessageSuccess() |
|
| 419 | +{ |
|
| 420 | +jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 421 | +jaxon()->setAppOption('dialogs.default.alert', 'cute'); |
|
| 422 | +jaxon()->setAppOption('dialogs.default.confirm', 'noty'); |
|
| 423 | +$this->assertEquals( |
|
| 424 | +'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 425 | + '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 426 | + '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 427 | + '"alert":{"lib":"cute","message":{"type":"success","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 428 | +rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 429 | + ->elseSuccess("No confirm")->__toString() |
|
| 430 | +); |
|
| 431 | +} |
|
| 432 | + |
|
| 433 | +/** |
|
| 434 | 434 | * @throws SetupException |
| 435 | 435 | */ |
| 436 | - public function testConfirmMessageInfo() |
|
| 437 | - { |
|
| 438 | - jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 439 | - jaxon()->setAppOptions([ |
|
| 440 | - 'alert' => 'cute', |
|
| 441 | - 'confirm' => 'noty', |
|
| 442 | - ], 'dialogs.default'); |
|
| 443 | - $this->assertEquals( |
|
| 444 | - 'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 445 | - '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 446 | - '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 447 | - '"alert":{"lib":"cute","message":{"type":"info","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 448 | - rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 449 | - ->elseInfo("No confirm")->__toString() |
|
| 450 | - ); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - /** |
|
| 436 | +public function testConfirmMessageInfo() |
|
| 437 | +{ |
|
| 438 | +jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 439 | +jaxon()->setAppOptions([ |
|
| 440 | +'alert' => 'cute', |
|
| 441 | +'confirm' => 'noty', |
|
| 442 | +], 'dialogs.default'); |
|
| 443 | +$this->assertEquals( |
|
| 444 | +'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 445 | + '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 446 | + '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 447 | + '"alert":{"lib":"cute","message":{"type":"info","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 448 | +rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 449 | + ->elseInfo("No confirm")->__toString() |
|
| 450 | +); |
|
| 451 | +} |
|
| 452 | + |
|
| 453 | +/** |
|
| 454 | 454 | * @throws SetupException |
| 455 | 455 | */ |
| 456 | - public function testConfirmMessageWarning() |
|
| 457 | - { |
|
| 458 | - jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 459 | - jaxon()->setAppOptions([ |
|
| 460 | - 'alert' => 'cute', |
|
| 461 | - 'confirm' => 'noty', |
|
| 462 | - ], 'dialogs.default'); |
|
| 463 | - $this->assertEquals( |
|
| 464 | - 'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 465 | - '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 466 | - '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 467 | - '"alert":{"lib":"cute","message":{"type":"warning","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 468 | - rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 469 | - ->elseWarning("No confirm")->__toString() |
|
| 470 | - ); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - /** |
|
| 456 | +public function testConfirmMessageWarning() |
|
| 457 | +{ |
|
| 458 | +jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 459 | +jaxon()->setAppOptions([ |
|
| 460 | +'alert' => 'cute', |
|
| 461 | +'confirm' => 'noty', |
|
| 462 | +], 'dialogs.default'); |
|
| 463 | +$this->assertEquals( |
|
| 464 | +'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 465 | + '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 466 | + '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 467 | + '"alert":{"lib":"cute","message":{"type":"warning","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 468 | +rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 469 | + ->elseWarning("No confirm")->__toString() |
|
| 470 | +); |
|
| 471 | +} |
|
| 472 | + |
|
| 473 | +/** |
|
| 474 | 474 | * @throws SetupException |
| 475 | 475 | */ |
| 476 | - public function testConfirmMessageError() |
|
| 477 | - { |
|
| 478 | - jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 479 | - jaxon()->setAppOptions([ |
|
| 480 | - 'alert' => 'cute', |
|
| 481 | - 'confirm' => 'noty', |
|
| 482 | - ], 'dialogs.default'); |
|
| 483 | - $this->assertEquals( |
|
| 484 | - 'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 485 | - '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 486 | - '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 487 | - '"alert":{"lib":"cute","message":{"type":"error","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 488 | - rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 489 | - ->elseError("No confirm")->__toString() |
|
| 490 | - ); |
|
| 491 | - } |
|
| 476 | +public function testConfirmMessageError() |
|
| 477 | +{ |
|
| 478 | +jaxon()->register(Jaxon::CALLABLE_CLASS, 'SampleDialog', __DIR__ . '/../src/sample.php'); |
|
| 479 | +jaxon()->setAppOptions([ |
|
| 480 | +'alert' => 'cute', |
|
| 481 | +'confirm' => 'noty', |
|
| 482 | +], 'dialogs.default'); |
|
| 483 | +$this->assertEquals( |
|
| 484 | +'jaxon.exec({"_type":"expr","calls":[{"_type":"func","_name":"SampleDialog.method",' . |
|
| 485 | + '"args":[{"_type":"html","_name":"elt_id"}]}],' . |
|
| 486 | + '"confirm":{"lib":"noty","question":{"title":"","phrase":{"str":"Really?","args":[]}}},' . |
|
| 487 | + '"alert":{"lib":"cute","message":{"type":"error","title":"","phrase":{"str":"No confirm","args":[]}}}})', |
|
| 488 | +rq('SampleDialog')->method(pm()->html('elt_id'))->confirm("Really?") |
|
| 489 | + ->elseError("No confirm")->__toString() |
|
| 490 | +); |
|
| 491 | +} |
|
| 492 | 492 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class SampleDialog |
| 6 | 6 | { |
| 7 | - public function myMethod() |
|
| 8 | - { |
|
| 9 | - $xResponse = jaxon()->getResponse(); |
|
| 10 | - $xResponse->alert('This is a response!!'); |
|
| 11 | - } |
|
| 7 | +public function myMethod() |
|
| 8 | +{ |
|
| 9 | +$xResponse = jaxon()->getResponse(); |
|
| 10 | +$xResponse->alert('This is a response!!'); |
|
| 11 | +} |
|
| 12 | 12 | } |
@@ -7,69 +7,69 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Dialog extends CallableClass |
| 9 | 9 | { |
| 10 | - public function success() |
|
| 11 | - { |
|
| 12 | - $this->response->dialog->title('Success')->success('This is a message!!'); |
|
| 13 | - } |
|
| 10 | +public function success() |
|
| 11 | +{ |
|
| 12 | +$this->response->dialog->title('Success')->success('This is a message!!'); |
|
| 13 | +} |
|
| 14 | 14 | |
| 15 | - public function info() |
|
| 16 | - { |
|
| 17 | - $this->response->dialog->title('Info')->info('This is a message!!'); |
|
| 18 | - } |
|
| 15 | +public function info() |
|
| 16 | +{ |
|
| 17 | +$this->response->dialog->title('Info')->info('This is a message!!'); |
|
| 18 | +} |
|
| 19 | 19 | |
| 20 | - public function warning() |
|
| 21 | - { |
|
| 22 | - $this->response->dialog->title('Warning')->warning('This is a message!!'); |
|
| 23 | - } |
|
| 20 | +public function warning() |
|
| 21 | +{ |
|
| 22 | +$this->response->dialog->title('Warning')->warning('This is a message!!'); |
|
| 23 | +} |
|
| 24 | 24 | |
| 25 | - public function error() |
|
| 26 | - { |
|
| 27 | - $this->response->dialog->title('Error')->error('This is a message!!'); |
|
| 28 | - } |
|
| 25 | +public function error() |
|
| 26 | +{ |
|
| 27 | +$this->response->dialog->title('Error')->error('This is a message!!'); |
|
| 28 | +} |
|
| 29 | 29 | |
| 30 | - public function show() |
|
| 31 | - { |
|
| 32 | - $this->response->dialog->show('Dialog', 'This is the dialog content!!', |
|
| 33 | - [['title' => 'Save', 'class' => 'btn', 'click' => $this->rq()->save()->confirm('Save?')]]); |
|
| 34 | - } |
|
| 30 | +public function show() |
|
| 31 | +{ |
|
| 32 | +$this->response->dialog->show('Dialog', 'This is the dialog content!!', |
|
| 33 | +[['title' => 'Save', 'class' => 'btn', 'click' => $this->rq()->save()->confirm('Save?')]]); |
|
| 34 | +} |
|
| 35 | 35 | |
| 36 | - public function showWith() |
|
| 37 | - { |
|
| 38 | - $this->response->dialog->with('bootbox')->show('Dialog', 'This is the dialog content!!', |
|
| 39 | - [['title' => 'Save', 'class' => 'btn', 'click' => $this->rq()->save()->confirm('Save?')]]); |
|
| 40 | - } |
|
| 36 | +public function showWith() |
|
| 37 | +{ |
|
| 38 | +$this->response->dialog->with('bootbox')->show('Dialog', 'This is the dialog content!!', |
|
| 39 | +[['title' => 'Save', 'class' => 'btn', 'click' => $this->rq()->save()->confirm('Save?')]]); |
|
| 40 | +} |
|
| 41 | 41 | |
| 42 | - public function hide() |
|
| 43 | - { |
|
| 44 | - $this->response->dialog->hide(); |
|
| 45 | - } |
|
| 42 | +public function hide() |
|
| 43 | +{ |
|
| 44 | +$this->response->dialog->hide(); |
|
| 45 | +} |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | class TestDialogLibrary extends AbstractLibrary implements LibraryInterface, ConfirmInterface |
| 49 | 49 | { |
| 50 | - /** |
|
| 50 | +/** |
|
| 51 | 51 | * @const The library name |
| 52 | 52 | */ |
| 53 | - public const NAME = 'test'; |
|
| 53 | +public const NAME = 'test'; |
|
| 54 | 54 | |
| 55 | - /** |
|
| 55 | +/** |
|
| 56 | 56 | * @inheritDoc |
| 57 | 57 | */ |
| 58 | - public function getName(): string |
|
| 59 | - { |
|
| 60 | - return self::NAME; |
|
| 61 | - } |
|
| 58 | +public function getName(): string |
|
| 59 | +{ |
|
| 60 | +return self::NAME; |
|
| 61 | +} |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | interface TestInterface |
| 65 | 65 | { |
| 66 | - public function do(); |
|
| 66 | +public function do(); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | class ClassWithInterface implements TestInterface |
| 70 | 70 | { |
| 71 | - public function do() |
|
| 72 | - { |
|
| 73 | - // Do something |
|
| 74 | - } |
|
| 71 | +public function do() |
|
| 72 | +{ |
|
| 73 | +// Do something |
|
| 74 | +} |
|
| 75 | 75 | } |
@@ -63,8 +63,10 @@ |
||
| 63 | 63 | |
| 64 | 64 | interface TestInterface |
| 65 | 65 | { |
| 66 | - public function do(); |
|
| 67 | -} |
|
| 66 | + public function do { |
|
| 67 | + (); |
|
| 68 | + } |
|
| 69 | + } |
|
| 68 | 70 | |
| 69 | 71 | class ClassWithInterface implements TestInterface |
| 70 | 72 | { |
@@ -1,29 +1,29 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'app' => [ |
|
| 5 | - 'dialogs' => [ |
|
| 6 | - 'default' => [ |
|
| 7 | - 'modal' => 'bootbox', |
|
| 8 | - 'alert' => 'noty', |
|
| 9 | - 'confirm' => 'noty', |
|
| 10 | - ], |
|
| 11 | - 'lib' => [ |
|
| 12 | - 'use' => ['alertify', 'bootbox', 'bootstrap', |
|
| 13 | - 'toastr', 'tingle', 'jalert', 'notify', |
|
| 14 | - 'cute', 'noty', 'sweetalert', 'jconfirm'], |
|
| 15 | - ], |
|
| 16 | - 'toastr' => [ |
|
| 17 | - 'options' => [ |
|
| 18 | - 'alert' => [ |
|
| 19 | - 'closeButton' => true, |
|
| 20 | - 'closeDuration' => 0, |
|
| 21 | - 'positionClass' => 'toast-top-center', |
|
| 22 | - ], |
|
| 23 | - ], |
|
| 24 | - ], |
|
| 4 | +'app' => [ |
|
| 5 | +'dialogs' => [ |
|
| 6 | +'default' => [ |
|
| 7 | + 'modal' => 'bootbox', |
|
| 8 | + 'alert' => 'noty', |
|
| 9 | + 'confirm' => 'noty', |
|
| 10 | +], |
|
| 11 | +'lib' => [ |
|
| 12 | + 'use' => ['alertify', 'bootbox', 'bootstrap', |
|
| 13 | + 'toastr', 'tingle', 'jalert', 'notify', |
|
| 14 | + 'cute', 'noty', 'sweetalert', 'jconfirm'], |
|
| 15 | +], |
|
| 16 | +'toastr' => [ |
|
| 17 | + 'options' => [ |
|
| 18 | + 'alert' => [ |
|
| 19 | + 'closeButton' => true, |
|
| 20 | + 'closeDuration' => 0, |
|
| 21 | + 'positionClass' => 'toast-top-center', |
|
| 25 | 22 | ], |
| 26 | 23 | ], |
| 27 | - 'lib' => [ |
|
| 28 | - ], |
|
| 24 | +], |
|
| 25 | +], |
|
| 26 | +], |
|
| 27 | +'lib' => [ |
|
| 28 | +], |
|
| 29 | 29 | ]; |