Skip to content

Commit

Permalink
Merge pull request #35 from markhuot/additional-versions
Browse files Browse the repository at this point in the history
add additional versions to test
  • Loading branch information
markhuot authored Oct 1, 2024
2 parents 1aca25c + 09aa9f6 commit 9724d5c
Show file tree
Hide file tree
Showing 70 changed files with 2,008 additions and 38 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,18 @@ jobs:
config: 4
- constraint: ~4.6.0
config: 4
- constraint: ~4.7.0
- constraint: ~4.7.0
config: 4
- constraint: ~5.0.0
config: 5
- constraint: ~5.1.0
config: 5
- constraint: ~5.2.0
config: 5.2
- constraint: ~5.3.0
config: 5.3
- constraint: ~5.4.0
config: 5.4

env:
CRAFT_APP_ID: pest
Expand Down
19 changes: 16 additions & 3 deletions src/behaviors/TestableResponseBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace markhuot\craftpest\behaviors;

use Carbon\Carbon;
use Illuminate\Support\Arr;
use markhuot\craftpest\dom\Form;
use markhuot\craftpest\dom\NodeList;
Expand Down Expand Up @@ -267,7 +268,13 @@ public function assertCookieExpired(string $name)

// Then check the expiration of it
$cookie = $this->response->cookies->get($name);
if ($cookie->expire === 0 || $cookie->expire >= time()) {

if ($cookie->expire === null) {
Assert::fail('Cookie `'.$name.'` does not have an expiration date.');
}

$expiration = Carbon::parse($cookie->expire);
if ($expiration->isAfter(Carbon::now())) {
Assert::fail('Cookie `'.$name.'` does not have an expiration in the past.');
}

Expand All @@ -288,8 +295,14 @@ public function assertCookieNotExpired(string $name)

// Then check the expiration of it
$cookie = $this->response->cookies->get($name);
if ($cookie->expire !== 0 && $cookie->expire < time()) {
Assert::fail('Cookie `'.$name.'` does not have an expiration in the future.');

if ($cookie->expire === null) {
Assert::fail('Cookie `'.$name.'` does not have an expiration date.');
}

$expiration = Carbon::parse($cookie->expire);
if ($expiration->isAfter(Carbon::now())) {
Assert::fail('Cookie `'.$name.'` does not have an expiration in the past.');
}

return $this->response;
Expand Down
3 changes: 2 additions & 1 deletion src/http/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ public function addHeader(string $name, $value): self
return $this;
}

public function addCookie(string $key, $value): self
public function addCookie(string $key, $value, $expire = 0): self
{
$this->request->cookies->add(new Cookie([
'name' => $key,
'value' => $value,
'expire' => $expire,
]));

return $this;
Expand Down
5 changes: 4 additions & 1 deletion src/test/CookieState.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace markhuot\craftpest\test;

use Carbon\Carbon;
use yii\web\Cookie;
use yii\web\CookieCollection;

Expand Down Expand Up @@ -94,7 +95,9 @@ public function storeCookieCollection(?CookieCollection $cookies)
// We have to manually clear our expired cookies because this is normally handled
// by the browser for us
foreach ($this->cookies as $cookie) {
if ($cookie->expire !== 0 && $cookie->expire < time()) {
$expiration = Carbon::parse($cookie->expire);

if ($cookie->expire !== 0 && $expiration->isBefore(Carbon::now())) {
$this->cookies->remove($cookie, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
color: null
fieldLayouts:
2f77cf1c-a3db-4396-8d2f-efff2172466e:
tabs:
-
elementCondition: null
elements:
-
autocapitalize: true
autocomplete: false
autocorrect: true
class: null
disabled: false
elementCondition: null
id: null
includeInCards: false
inputType: null
instructions: null
label: null
max: null
min: null
name: null
orientation: null
placeholder: null
providesThumbs: false
readonly: false
requirable: false
size: null
step: null
tip: null
title: null
type: craft\fieldlayoutelements\entries\EntryTitleField
uid: 463de371-8db2-4f1d-b9b1-b9aca58b5c86
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: c05f8773-60a8-4f5e-9925-3cc36a064793 # Field One
handle: null
includeInCards: true
instructions: null
label: 'Field One'
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: 6a242257-5d04-4ffb-8afb-f0b091472335
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: 10199d0e-57f0-4724-aefb-1ef4ed73b408 # Field Two
handle: null
includeInCards: false
instructions: null
label: 'Field Two'
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: 4b8f210d-545c-4d57-9777-08cdb93862df
userCondition: null
warning: null
width: 100
name: Content
uid: aad92478-a4a8-49e5-b88b-5fff4734eb2c
userCondition: null
handle: blockTypeOne
hasTitleField: false
icon: null
name: 'Block Type One'
showSlugField: true
showStatusField: true
slugTranslationKeyFormat: null
slugTranslationMethod: site
titleFormat: null
titleTranslationKeyFormat: null
titleTranslationMethod: site
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
color: null
fieldLayouts:
50cdf242-1476-44dc-ab8b-e3ad70ef3163:
tabs:
-
elementCondition: null
elements:
-
autocapitalize: true
autocomplete: false
autocorrect: true
class: null
disabled: false
elementCondition: null
id: null
includeInCards: false
inputType: null
instructions: null
label: null
max: null
min: null
name: null
orientation: null
placeholder: null
providesThumbs: false
readonly: false
requirable: false
size: null
step: null
tip: null
title: null
type: craft\fieldlayoutelements\entries\EntryTitleField
uid: 880e50a3-79fb-4456-836b-89c970af40b9
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: c7529b61-60cd-4e18-a272-3084aee7fa89 # Matrix Field
handle: null
includeInCards: false
instructions: null
label: null
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: 90a7fa0d-77cd-4612-92f9-4fafd4c1a66d
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: c148dfb3-a122-49ed-8538-de26d0482663 # Entries Field
handle: null
includeInCards: false
instructions: null
label: null
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: efbdd2ca-b829-4604-bd1e-f66fad9093e2
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: 7d1a7bf3-c346-48bc-bb77-f7d76fcacf2e # Text Field
handle: null
includeInCards: false
instructions: null
label: null
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: 189519d9-7809-47fc-bc54-d2441a85ae9d
userCondition: null
warning: null
width: 100
-
elementCondition: null
fieldUid: 17685ada-d64c-459c-b9fc-678d43e4bee8 # Dropdown Field
handle: null
includeInCards: false
instructions: null
label: null
providesThumbs: false
required: false
tip: null
type: craft\fieldlayoutelements\CustomField
uid: 1440d116-5fe9-45a3-8031-7f3c9b71ef9d
userCondition: null
warning: null
width: 100
name: Content
uid: a914e695-0910-4b04-841b-cbe6f689856b
userCondition: null
handle: default
hasTitleField: true
icon: null
name: Default
showSlugField: true
showStatusField: true
slugTranslationKeyFormat: null
slugTranslationMethod: site
titleFormat: null
titleTranslationKeyFormat: null
titleTranslationMethod: site
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
columnSuffix: vqczhrcp
handle: dropdownField
instructions: null
name: 'Dropdown Field'
searchable: false
settings:
options:
-
__assoc__:
-
- label
- One
-
- value
- one
-
- default
- ''
-
__assoc__:
-
- label
- Two
-
- value
- two
-
- default
- ''
translationKeyFormat: null
translationMethod: none
type: craft\fields\Dropdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
columnSuffix: null
handle: entriesField
instructions: null
name: 'Entries Field'
searchable: false
settings:
allowSelfRelations: false
branchLimit: null
localizeRelations: false
maintainHierarchy: false
maxRelations: null
minRelations: null
selectionLabel: null
showCardsInGrid: false
showSiteMenu: false
sources: '*'
targetSiteId: null
validateRelatedElements: false
viewMode: null
translationKeyFormat: null
translationMethod: site
type: craft\fields\Entries
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
columnSuffix: jnvscjst
handle: fieldOne
instructions: null
name: 'Matrix Field - Block Type One - Field One'
searchable: false
settings:
byteLimit: null
charLimit: null
code: false
initialRows: 4
multiline: false
placeholder: null
uiMode: normal
translationKeyFormat: null
translationMethod: none
type: craft\fields\PlainText
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
columnSuffix: swmzeype
handle: fieldTwo
instructions: null
name: 'Matrix Field - Block Type One - Field Two'
searchable: false
settings:
byteLimit: null
charLimit: null
code: false
initialRows: 4
multiline: false
placeholder: null
uiMode: normal
translationKeyFormat: null
translationMethod: none
type: craft\fields\PlainText
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
columnSuffix: null
handle: matrixField
instructions: null
name: 'Matrix Field'
searchable: false
settings:
entryTypes:
- b5c238dd-588f-4f0a-b9e4-8a988f0e7468 # Block Type One
includeTableView: false
maxEntries: null
minEntries: null
pageSize: null
propagationKeyFormat: null
propagationMethod: all
showCardsInGrid: false
viewMode: blocks
translationKeyFormat: null
translationMethod: site
type: craft\fields\Matrix
Loading

0 comments on commit 9724d5c

Please sign in to comment.