]> git.mxchange.org Git - friendica-addons.git/blob
aea5f8259f59c27ed6095ec8582af5f80e1a6bdc
[friendica-addons.git] /
1 <?php
2
3 /*
4  * This file is part of the Fxp Composer Asset Plugin package.
5  *
6  * (c) François Pluchino <francois.pluchino@gmail.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Fxp\Composer\AssetPlugin\Tests\Converter;
13
14 use Fxp\Composer\AssetPlugin\Converter\PackageConverterInterface;
15 use Fxp\Composer\AssetPlugin\Tests\Fixtures\Converter\InvalidPackageConverter;
16 use Fxp\Composer\AssetPlugin\Type\AssetTypeInterface;
17
18 /**
19  * Abstract tests of asset package converter.
20  *
21  * @author François Pluchino <francois.pluchino@gmail.com>
22  */
23 abstract class AbstractPackageConverterTest extends \PHPUnit_Framework_TestCase
24 {
25     /**
26      * @var AssetTypeInterface
27      */
28     protected $type;
29
30     /**
31      * @var PackageConverterInterface
32      */
33     protected $converter;
34
35     /**
36      * @var array
37      */
38     protected $asset;
39
40     protected function setUp()
41     {
42         $versionConverter = $this->getMockBuilder('Fxp\Composer\AssetPlugin\Converter\VersionConverterInterface')->getMock();
43         $versionConverter->expects($this->any())
44             ->method('convertVersion')
45             ->will($this->returnCallback(function ($value) {
46                 return $value;
47             }));
48         $versionConverter->expects($this->any())
49             ->method('convertRange')
50             ->will($this->returnCallback(function ($value) {
51                 return $value;
52             }));
53         $type = $this->getMockBuilder('Fxp\Composer\AssetPlugin\Type\AssetTypeInterface')->getMock();
54         $type->expects($this->any())
55             ->method('getComposerVendorName')
56             ->will($this->returnValue('ASSET'));
57         $type->expects($this->any())
58             ->method('getComposerType')
59             ->will($this->returnValue('ASSET_TYPE'));
60         $type->expects($this->any())
61             ->method('getVersionConverter')
62             ->will($this->returnValue($versionConverter));
63         $type->expects($this->any())
64             ->method('formatComposerName')
65             ->will($this->returnCallback(function ($value) {
66                 return 'ASSET/'.$value;
67             }));
68
69         $this->type = $type;
70     }
71
72     protected function tearDown()
73     {
74         $this->type = null;
75         $this->converter = null;
76         $this->asset = array();
77     }
78
79     /**
80      * @expectedException \Fxp\Composer\AssetPlugin\Exception\InvalidArgumentException
81      */
82     public function testConversionWithInvalidKey()
83     {
84         $this->converter = new InvalidPackageConverter($this->type);
85
86         $this->converter->convert(array(
87             'name' => 'foo',
88         ));
89     }
90 }