PortableInfobox/tests/InfoboxParamsValidatorTest.php

69 lines
1.5 KiB
PHP
Raw Normal View History

2015-06-11 10:54:10 +00:00
<?php
class InfoboxParamsValidatorTest extends WikiaBaseTest {
private $InfoboxParamsValidator;
2015-06-11 11:19:05 +00:00
private $invalidParamsExpectionName =
2015-06-11 10:54:10 +00:00
'Wikia\PortableInfobox\Helpers\InvalidInfoboxParamsException';
protected function setUp() {
$this->setupFile = dirname( __FILE__ ) . '/../PortableInfobox.setup.php';
parent::setUp();
2016-02-03 11:06:44 +00:00
$this->InfoboxParamsValidator = new \Wikia\PortableInfobox\Helpers\InfoboxParamsValidator();
2015-06-11 10:54:10 +00:00
}
/**
* @param array $params
* @dataProvider testInfoboxParamsFailValidationDataProvider
*/
public function testInfoboxParamsFailValidation ( $params ) {
2015-06-11 11:19:05 +00:00
$this->setExpectedException( $this->invalidParamsExpectionName );
2015-06-11 10:54:10 +00:00
$this->InfoboxParamsValidator->validateParams( $params );
}
/**
* @param array $params
* @dataProvider testInfoboxParamsPassValidationDataProvider
*/
public function testInfoboxParamsPassValidation ( $params ) {
$this->assertEquals( true, $this->InfoboxParamsValidator->validateParams( $params ) );
}
public function testInfoboxParamsFailValidationDataProvider() {
return [
[
'params' => [
'theme' => 'test',
'abc' => 'def',
'layout' => 'myLayout'
]
],
[
'params' => [
'abc' => 'def',
]
],
];
}
public function testInfoboxParamsPassValidationDataProvider() {
return [
[
'params' => [],
],
[
'params' => [
'theme' => 'test',
'theme-source' => 'loremIpsum',
'layout' => 'myLayout'
]
],
[
'params' => [
'theme' => 'test',
]
]
];
}
}