Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ http://www.opensource.org/licenses/mit-license.html

## Change Log ##

* 2.1.1 - Remove the attempt to resolve dot notation in the base view path of the PHP_Engine, as this was causing issues when servers have . in folder names.
* 2.1.0 - Updated to WP6.6, changed PHPCS rules and added a number of new helpers to App_Config.
* App_Config::asset_url() - Returns the full URL to an asset.
* App_Config::asset_path() - Returns the full path to an asset.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"require": {
"php": ">=7.4.0",
"gin0115/dice": "4.1.*",
"psr/container": "^1.0",
"psr/container": "^1.0 || ^2.0",
"pinkcrab/hook-loader": "^1.1",
"pinkcrab/function-constructors": "0.2.*"
},
Expand Down
1 change: 0 additions & 1 deletion src/Services/View/PHP_Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ private function maybe_resolve_dot_notation( string $filename ): string {
* @throws Exception
*/
private function verify_view_path( string $path ): string {
$path = $this->maybe_resolve_dot_notation( $path );
$path = rtrim( $path, '/' ) . '/';

if ( ! \is_dir( $path ) ) {
Expand Down
40 changes: 20 additions & 20 deletions tests/Unit/View/Test_PHP_Engine.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Test_PHP_Engine extends WP_UnitTestCase {
*
* @return void
*/
public function setUp() : void {
public function setUp(): void {
parent::setUp();
$this->view = new PHP_Engine( FIXTURES_PATH . '/views/' );
}
Expand Down Expand Up @@ -164,7 +164,9 @@ public function test_adds_trailing_slash_to_view_path(): void {
$view->render( '/hello.php', array( 'hello' => 'Hello World' ) );
}

/** @testdox An exception should be thrown if the engine attempts to render a component with setting the compiler. */
/**
* @testdox An exception should be thrown if the engine attempts to render a component with setting the compiler.
*/
public function test_throws_exception_if_component_not_set(): void {
$this->expectException( Exception::class );
$this->expectExceptionMessage( 'No component compiler passed to PHP_Engine' );
Expand All @@ -191,20 +193,12 @@ public function test_can_render_path_using_dot_notation_with_extension(): void {
);
}

/** @testdox It should be possible to define the base path for view using dot notation. */
public function test_can_set_base_path_using_dot_notation(): void {
$this->expectOutputString( 'foo' );
$view = new PHP_Engine( \dirname( __DIR__, 2 ) . '.Fixtures.views.' );
$view->render(
'sub_path.template',
array( 'variable' => 'foo' ),
View::PRINT_VIEW // Optional as print view is default.
);
}

/** @testdox It should be possible to use filepaths with or without the .php extensions */
/**
* @testdox It should be possible to use filepaths with or without the .php extensions
*/
public function test_can_render_path_with_or_without_php_extension(): void {
function() {
function () {
$this->expectOutputString( 'foo' );
$this->view->render(
'sub_path.template',
Expand All @@ -221,7 +215,9 @@ function() {
);
}

/** @testdox It should be possible to access the base_path from the engine. */
/**
* @testdox It should be possible to access the base_path from the engine.
*/
public function test_can_get_base_path(): void {
$path = FIXTURES_PATH . '/views/';
$this->assertEquals(
Expand All @@ -230,7 +226,9 @@ public function test_can_get_base_path(): void {
);
}

/** @testdox By default view_models should be printed, unless false is passed as the param for $print */
/**
* @testdox By default view_models should be printed, unless false is passed as the param for $print
*/
public function test_view_models_print_by_default(): void {
$this->expectOutputString( 'partial_value' );
$this->view->view_model(
Expand All @@ -241,7 +239,9 @@ public function test_view_models_print_by_default(): void {
);
}

/** @testdox By default the partial() method should print the view, unless false is passed as the param for $prinr */
/**
* @testdox By default the partial() method should print the view, unless false is passed as the param for $prinr
*/
public function test_returns_partial_from_template(): void {
$this->expectOutputString( 'rendered partial using PHPEngine->partial()' );
$this->view->partial(
Expand All @@ -250,11 +250,11 @@ public function test_returns_partial_from_template(): void {
);
}

/** @testdox Any path passed as a view, should be trimmed for all whitespace. */
/**
* @testdox Any path passed as a view, should be trimmed for all whitespace.
*/
public function test_view_path_is_trimmed(): void {
$this->expectOutputString( 'Hello World' );
$this->view->render( ' hello ', array( 'hello' => 'Hello World' ) );
}


}
Loading