-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
181 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Nette Framework (https://nette.org) | ||
* Copyright (c) 2004 David Grudl (https://davidgrudl.com) | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Nette\Application\Attributes; | ||
|
||
use Attribute; | ||
|
||
|
||
#[Attribute(Attribute::TARGET_PROPERTY)] | ||
class Request | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
/** | ||
* Test: Nette\Application\UI\Presenter::getRequestParams | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
use Nette\Application\Attributes\Persistent; | ||
use Nette\Application\Attributes\Request; | ||
use Nette\Application\UI\ComponentReflection; | ||
use Nette\Application\UI\Presenter; | ||
use Tester\Assert; | ||
|
||
require __DIR__ . '/../bootstrap.php'; | ||
|
||
|
||
class OnePresenter extends Presenter | ||
{ | ||
public static $no1; | ||
public $no2; | ||
|
||
/** @persistent */ | ||
public $yes1; | ||
|
||
#[Persistent] | ||
public $yes2; | ||
|
||
#[Request] | ||
public $yes3; | ||
} | ||
|
||
|
||
class TwoPresenter extends OnePresenter | ||
{ | ||
#[Request] | ||
public $yes2; | ||
public $yes3; | ||
|
||
#[Request] | ||
public $yes4; | ||
} | ||
|
||
|
||
if (PHP_VERSION_ID < 80000) { | ||
Assert::same( | ||
[ | ||
'yes1' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
], | ||
(new ComponentReflection(OnePresenter::class))->getRequestParams() | ||
); | ||
|
||
Assert::same( | ||
[ | ||
'yes1' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
], | ||
(new ComponentReflection(TwoPresenter::class))->getRequestParams() | ||
); | ||
|
||
} else { | ||
Assert::same( | ||
[ | ||
'yes1' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
'yes2' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
'yes3' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => false, | ||
], | ||
], | ||
(new ComponentReflection(OnePresenter::class))->getRequestParams() | ||
); | ||
|
||
Assert::same( | ||
[ | ||
'yes2' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
'yes4' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'TwoPresenter', | ||
'persist' => false, | ||
], | ||
'yes1' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => true, | ||
], | ||
'yes3' => [ | ||
'def' => null, | ||
'type' => 'scalar', | ||
'since' => 'OnePresenter', | ||
'persist' => false, | ||
], | ||
], | ||
(new ComponentReflection(TwoPresenter::class))->getRequestParams() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters