| 1 | <?php |
||
| 20 | class PreTextFormatterTest extends \PHPUnit_Framework_TestCase { |
||
| 21 | |||
| 22 | use PHPUnitCompat; |
||
| 23 | |||
| 24 | const LF = "\n"; |
||
| 25 | |||
| 26 | public function testCanConstruct() { |
||
| 27 | |||
| 28 | $this->assertInstanceOf( |
||
| 29 | '\SCI\PreTextFormatter', |
||
| 30 | new PreTextFormatter() |
||
| 31 | ); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @dataProvider parametersProvider |
||
| 36 | */ |
||
| 37 | public function testFormat( $params ) { |
||
| 38 | |||
| 39 | $instance = new PreTextFormatter(); |
||
| 40 | |||
| 41 | $this->assertInternalType( |
||
| 42 | 'array', |
||
| 43 | $instance->format( $params ) |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @dataProvider parametersProvider |
||
| 49 | */ |
||
| 50 | public function testGetFormattedSciteFuncFrom( $params, $expected ) { |
||
| 51 | |||
| 52 | $instance = new PreTextFormatter(); |
||
| 53 | |||
| 54 | $this->assertSame( |
||
| 55 | $expected, |
||
| 56 | $instance->getFormattedSciteFuncFrom( $params ) |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | |||
| 60 | public function parametersProvider() { |
||
| 61 | |||
| 62 | $provider[] = [ |
||
| 63 | [ |
||
| 64 | 'Bar', |
||
| 65 | '@Foobar' |
||
| 66 | ], |
||
| 67 | "<pre>{{#scite:" . self::LF . " |Bar" . self::LF . "}}</pre>" |
||
| 68 | ]; |
||
| 69 | |||
| 70 | $provider[] = [ |
||
| 71 | [ |
||
| 72 | 'Bar', |
||
| 73 | '+sep=,', |
||
| 74 | '@Foobar', |
||
| 75 | 'Foo' |
||
| 76 | ], |
||
| 77 | "<pre>{{#scite:" . self::LF . " |Bar|+sep=," . self::LF . " |Foo" . self::LF . "}}</pre>" |
||
| 78 | ]; |
||
| 79 | |||
| 80 | return $provider; |
||
| 81 | } |
||
| 82 | |||
| 83 | } |
||
| 84 |