-
Notifications
You must be signed in to change notification settings - Fork 50
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
Refactor test helpers and test files #104
Merged
Girgias
merged 6 commits into
php:master
from
haszi:Refactor-test-helpers-and-test-files
Feb 26, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b87a54f
Add Format as an optional constructor dependency to TestRender
f10d03e
Add Config as a constructor dependency to TestRender
8a24dd1
Add Index as an optional constructor dependency to TestRender
7a94797
TestRender to extend Render
547fc20
Config to allow calling instance methods
c5fce08
Refactor test helpers and test directory structure
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -527,6 +527,3 @@ public function setMembership($membership) { | |
} | ||
|
||
} | ||
|
||
|
||
|
2 changes: 1 addition & 1 deletion
2
tests/xhtml/TestChunkedXHTML.php → phpdotnet/phd/TestGenericChunkedXHTML.php
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
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,33 @@ | ||
<?php | ||
namespace phpdotnet\phd; | ||
|
||
class TestRender extends Render { | ||
public function __construct( | ||
protected Reader $reader, | ||
protected Config $config, | ||
protected ?Format $format = null, | ||
protected ?Index $index = null, | ||
) {} | ||
|
||
public function run() { | ||
if ($this->index && $this->index::requireIndexing()) { | ||
if (!file_exists($this->config->output_dir())) { | ||
mkdir($this->config->output_dir(), 0755); | ||
} | ||
$this->attach($this->index); | ||
$this->reader->open($this->config->xml_file()); | ||
$this->execute($this->reader); | ||
$this->detach($this->index); | ||
} | ||
|
||
if ($this->format !== null) { | ||
$this->attach($this->format); | ||
$this->reader->open($this->config->xml_file()); | ||
$this->execute($this->reader); | ||
} | ||
} | ||
|
||
public function getIndex(): ?Index { | ||
return $this->index; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One improvement for later would maybe to make Config a Value Object and use named params to set the config keys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean something like a
readonly
Value Object with named constructor parameters? Because that sounds like something that might make juggling these configurations easier. Unfortunately the properties ofConfig
are not setup in the beginning of rendering so that it can easily be changed to areadonly
VO but with some refactoring that could be done too.I'll make a note of this and will probably start refactoring parts of this one by one (such as
Options_Parser
to return an array instead of settingConfig
directly,Index
's database to be constructor injected so it can be added toConfig
outside ofIndex
as well, moving hardcodedcss
urls out of PHP's XHTML format so it also can be added toConfig
at the very beginning of the script,output_format
s also set at the beginning of the script, etc.).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically yes :) having a magic dictionary array with keys is hard to reason about, could be fixed by using a static analyser array shape, but I doubt any static analysis tool is going to enjoy PhD in the state it currently is :')