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

T172892 Determine skin to use based on request #955

Merged
merged 13 commits into from Sep 24, 2017
Merged

Conversation

wiese
Copy link
Contributor

@wiese wiese commented Sep 19, 2017

Works best with additional config.prod.json

"skin": {
	"options": [
		"10h16", "cat17"
	]
},
"cookie": {
	"secure": false
}

Resources:

@JeroenDeDauw
Copy link
Contributor

continue;
}
$this->assertSame( $expected, $cookie->getValue() );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not found, no assertion will be made. While this results in a warning (or error?) when using PHPUnit strict mode, it is a bit dodgy. You could return after the assert and put a $this->fail() at the end of the method.

$client->request( 'GET', '/' );

$this->assertContains( '10h16', $client->getResponse()->getContent() );
$this->assertNoSkinResponseCookie( $client->getResponse() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put the assert methods (and all methods really) right below where they are first used, less vertical scrolling is needed to real the class.

@JeroenDeDauw
Copy link
Contributor

Looks good so far apart from minor CS-ish stuff

@@ -468,6 +471,10 @@ function( string $name, array $parameters = [] ): string {
return new SofortClient( $config['config-key'] );
};

$pimple['skin'] = function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since skin is more of a parameter than a service I think it's sufficient to assign it directly instead of using a function with a return value.


use InvalidArgumentException;

class SkinManager {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this class "manages" anything, it looks like a fancy mutable value object to me. Maybe call it SkinSettings, SkinConfiguration or just Skins?

@wiese wiese changed the title [WIP] T172892 Determine skin to use based on request T172892 Determine skin to use based on request Sep 22, 2017
Improve descriptions in config schema doc

public function testDefaultSkinIsSet(): void {
$manager = new SkinSettings( ['a', 'b'], 'a', 500 );
$this->assertSame( 'a', $manager->getDefaultSkin() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose SkinSettings was renamed, cause $manager is kinda weird like this

@JeroenDeDauw JeroenDeDauw merged commit 73eec75 into master Sep 24, 2017
@JeroenDeDauw JeroenDeDauw deleted the skin-on-request branch September 24, 2017 23:37
JeroenDeDauw added a commit that referenced this pull request Sep 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants