Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.x] DataCollections improvements #1732

Merged
merged 122 commits into from
Jun 25, 2024
Merged
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
10c2809
Merge branch 'master' into 2.x-dev
caendesilva Jun 23, 2024
a2f4219
Add additional fixture for test
caendesilva Jun 23, 2024
71e2212
Test YAML collections without triple dashes
caendesilva Jun 23, 2024
ff89641
Support parsing Yaml data files with both dashes and without
caendesilva Jun 23, 2024
399d447
Merge branch '2.x-dev' into 2x-datacollections-improvements
caendesilva Jun 23, 2024
30b6365
Yaml data files no longer need to start with triple dashes
caendesilva Jun 23, 2024
5b2af72
Simplify Yaml data file parsing
caendesilva Jun 23, 2024
e4e6808
Update RELEASE_NOTES.md
caendesilva Jun 23, 2024
5d655cb
Update RELEASE_NOTES.md
caendesilva Jun 23, 2024
daa7a3a
Revert "Update RELEASE_NOTES.md"
caendesilva Jun 23, 2024
6ebc9c9
Unwrap unnecessary condition
caendesilva Jun 23, 2024
e39067e
Merge branch '2.x-dev' into 2x-datacollections-improvements
caendesilva Jun 23, 2024
b3807fb
Merge branch '2.x-dev' into 2x-datacollections-improvements
caendesilva Jun 23, 2024
22c4b66
No longer automatically create the data collections directory
caendesilva Jun 23, 2024
4245ba5
Breaking: Rename class `DataCollections` to `DataCollection`
caendesilva Jun 23, 2024
a24aa34
Add mockable data collection test class
caendesilva Jun 24, 2024
02b8b06
Get by name
caendesilva Jun 24, 2024
6c91c63
Normalize file contents syntax
caendesilva Jun 24, 2024
dd63ffe
Add array based glob helper
caendesilva Jun 24, 2024
b577a48
Collect using array glob
caendesilva Jun 24, 2024
db62861
Annotate generics
caendesilva Jun 24, 2024
dd698ab
Assert generics and test mock setup
caendesilva Jun 24, 2024
d9bb52a
Mock the filesystem
caendesilva Jun 24, 2024
e8af560
Simplify testing helpers
caendesilva Jun 24, 2024
ba3b72a
Test Markdown method returns collection of Markdown documents
caendesilva Jun 24, 2024
8474481
Test Yaml method returns collection of front matter objects
caendesilva Jun 24, 2024
07e9cc3
Update mocks to better match real setup
caendesilva Jun 24, 2024
330940e
Fix quote usage
caendesilva Jun 24, 2024
c2ad0e9
Test differing Yaml syntaxes
caendesilva Jun 24, 2024
ae8523d
Test Yaml fault tolerance
caendesilva Jun 24, 2024
bc8c4fc
Extract helper to assert front matter collection structure
caendesilva Jun 24, 2024
d36c1a7
Add helper to assert Json collection structure
caendesilva Jun 24, 2024
46a2bb1
Simplify assertion handling
caendesilva Jun 24, 2024
7535cdc
Test Json collection handling
caendesilva Jun 24, 2024
9ce2c98
Remove duplicated word from documentation
caendesilva Jun 24, 2024
d491da1
Refactor to extract helper method
caendesilva Jun 24, 2024
aaffe2c
Move up helper method
caendesilva Jun 24, 2024
194899d
Rename callback parameter
caendesilva Jun 24, 2024
f89f408
Refactor to further extract shared logic to helper
caendesilva Jun 24, 2024
a80b3d4
Add null return type support pending https://github.com/hydephp/devel…
caendesilva Jun 24, 2024
ca6f87d
Annotate helper method generics
caendesilva Jun 24, 2024
0b54e3d
Cleanup PHPDoc comment
caendesilva Jun 24, 2024
c232397
Annotate helper method generics
caendesilva Jun 24, 2024
1edcc24
Inline local variable
caendesilva Jun 24, 2024
308a9c1
Reorder newlines
caendesilva Jun 24, 2024
c2f0faa
Normalize PHPDoc types
caendesilva Jun 24, 2024
24532a1
Introduce local variable
caendesilva Jun 24, 2024
25b4aeb
Update Data Collections to validate JSON data files
caendesilva Jun 24, 2024
ebebaa1
Convert string interpolation to a 'sprintf()' call
caendesilva Jun 24, 2024
06dfada
Display the error that caused the JSON decoding to fail
caendesilva Jun 24, 2024
9702722
Document example to help issue searching lead to upgrade path
caendesilva Jun 24, 2024
b217795
Throw a normalized exception for issues parsing Yaml
caendesilva Jun 25, 2024
d08b187
Throw parse exception for empty Yaml to match `json_validate`
caendesilva Jun 25, 2024
f93cb0e
Document code reasoning
caendesilva Jun 25, 2024
b0d1e22
Remove unreachable null coalesce
caendesilva Jun 25, 2024
65aadb5
Trim trailing periods to make message fit in better
caendesilva Jun 25, 2024
d4c970e
Import used functions
caendesilva Jun 25, 2024
9f52220
Extract helper methods responsible for parsing each file
caendesilva Jun 25, 2024
2d2cfe8
Convert simplified closures to arrow functions
caendesilva Jun 25, 2024
a99947a
Document throws
caendesilva Jun 25, 2024
df820ef
Move return into try/catch block
caendesilva Jun 25, 2024
9b33cfd
Inline local variable
caendesilva Jun 25, 2024
b933be6
Cleanup formatting
caendesilva Jun 25, 2024
fc67b11
Use first class callable syntax where possible
caendesilva Jun 25, 2024
88a9204
Support passing extra arguments to discover method
caendesilva Jun 25, 2024
dc26d88
Clarify parameter name
caendesilva Jun 25, 2024
ea04ed1
Narrow down mixed generic return type to actual supported types
caendesilva Jun 25, 2024
670dd7a
Extract testing helper
caendesilva Jun 25, 2024
e32f6f8
Update testing helper to compare front matter
caendesilva Jun 25, 2024
6c1497b
Support mixed states
caendesilva Jun 25, 2024
8be9527
Test Markdown collections with front matter
caendesilva Jun 25, 2024
bde59d8
Add edge case tests
caendesilva Jun 25, 2024
11a9205
Fix typo in testing helper name
caendesilva Jun 25, 2024
30c2a74
Test Markdown method with invalid front matter
caendesilva Jun 25, 2024
9ca7a79
Normalize exception handling for Markdown data files
caendesilva Jun 25, 2024
4ecabc9
Throw an exception when Markdown data file is empty
caendesilva Jun 25, 2024
005dc15
Reorder test methods
caendesilva Jun 25, 2024
ab762b9
Remove unnecessary trim already run in blank function
caendesilva Jun 25, 2024
6d81d41
Cleanup code
caendesilva Jun 25, 2024
5cf056d
Introduce local variable
caendesilva Jun 25, 2024
6ffd6f9
Refactor to have single try/catch block in loop
caendesilva Jun 25, 2024
415a32a
Simplify and cleanup exception file type label handing
caendesilva Jun 25, 2024
558f407
Create ParseException.php
caendesilva Jun 25, 2024
86c6147
Throw our ParseException instead of InvalidArgumentException
caendesilva Jun 25, 2024
1c7114a
Improve wording
caendesilva Jun 25, 2024
c5bc374
Simplify type label generator to use the file extension
caendesilva Jun 25, 2024
260ce22
Fix parse exception namespace
caendesilva Jun 25, 2024
cf953e6
Fix class name capitalization
caendesilva Jun 25, 2024
2783e0d
Document exception scope
caendesilva Jun 25, 2024
54285af
Revert "Document exception scope"
caendesilva Jun 25, 2024
2fba023
Mark ParseException class as experimental
caendesilva Jun 25, 2024
d2829f2
Test covers ParseException
caendesilva Jun 25, 2024
7f4d48d
Override parent constructor
caendesilva Jun 25, 2024
7960357
Unit test covers ParseException
caendesilva Jun 25, 2024
e5d4c82
Refactor to move exception message assembly to custom exception
caendesilva Jun 25, 2024
f4e18ba
Add unit tests for custom ParseException
caendesilva Jun 25, 2024
301c44c
Improve parse exception message assembly
caendesilva Jun 25, 2024
fcab984
Revert "Unit test covers ParseException"
caendesilva Jun 25, 2024
c604c93
Test parse exception code
caendesilva Jun 25, 2024
eaa3045
Remove unused use statement
caendesilva Jun 25, 2024
4348f1c
Set parse exception status code to 422
caendesilva Jun 25, 2024
5fb82c1
Replace string replacement with match expression
caendesilva Jun 25, 2024
ad15064
Add source code spacing
caendesilva Jun 25, 2024
05910f3
Update RELEASE_NOTES.md
caendesilva Jun 25, 2024
68b096d
Extract helper method
caendesilva Jun 25, 2024
19ac8df
Inline local variable
caendesilva Jun 25, 2024
5393e36
Extract helper method
caendesilva Jun 25, 2024
6fc3d21
Move up method in source
caendesilva Jun 25, 2024
177185b
Inline local variables
caendesilva Jun 25, 2024
770df88
Convert a 'sprintf()' call to string interpolation
caendesilva Jun 25, 2024
e1ce0c3
Revert "Convert a 'sprintf()' call to string interpolation"
caendesilva Jun 25, 2024
3d05b2f
Split comma-separated values into multiple lines
caendesilva Jun 25, 2024
b2d3282
Extract helper method
caendesilva Jun 25, 2024
323abb1
Move up method in source
caendesilva Jun 25, 2024
8fba6af
Conditionally assemble file path string
caendesilva Jun 25, 2024
694b1cd
Refactor and cleanup code
caendesilva Jun 25, 2024
f1e82a1
Remove unnecessary parentheses
caendesilva Jun 25, 2024
e976cee
Revert "Remove unnecessary parentheses"
caendesilva Jun 25, 2024
d6a619f
Update RELEASE_NOTES.md
caendesilva Jun 25, 2024
b2912a3
Draft upcoming change notes
caendesilva Jun 25, 2024
227db4f
Revert "Draft upcoming change notes"
caendesilva Jun 25, 2024
0a3a65a
Clean up release notes
caendesilva Jun 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mock the filesystem
  • Loading branch information
caendesilva committed Jun 24, 2024
commit d9bb52adee743da4afda6428685b7bc1773e6fb3
11 changes: 11 additions & 0 deletions packages/framework/tests/Unit/DataCollectionUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ public static function mockFiles(array $files): void
assert(str_contains($file, '.'), 'File must have an extension.');
}

$filesystem = Mockery::mock(Filesystem::class);
$filesystem->shouldReceive('get')
->andReturnUsing(function (string $file) use ($files) {
$file = unslash(str_replace(Hyde::path(), '', $file));
$files = static::arrayGlob($files, $file, 'md');

return array_values($files)[0] ?? '';
});

app()->instance(Filesystem::class, $filesystem);

static::$mockFiles = $files;
}

Expand Down