@@ -10,56 +10,56 @@ |
||
| 10 | 10 | |
| 11 | 11 | class CWPVersionExtensionTest extends SapphireTest |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @var VersionProvider|PHPUnit_Framework_MockObject_MockObject |
|
| 15 | - */ |
|
| 16 | - protected $versionProvider; |
|
| 13 | + /** |
|
| 14 | + * @var VersionProvider|PHPUnit_Framework_MockObject_MockObject |
|
| 15 | + */ |
|
| 16 | + protected $versionProvider; |
|
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @var LeftAndMain|PHPUnit_Framework_MockObject_MockObject |
|
| 20 | - */ |
|
| 21 | - protected $leftAndMain; |
|
| 18 | + /** |
|
| 19 | + * @var LeftAndMain|PHPUnit_Framework_MockObject_MockObject |
|
| 20 | + */ |
|
| 21 | + protected $leftAndMain; |
|
| 22 | 22 | |
| 23 | - protected function setUp() |
|
| 24 | - { |
|
| 25 | - parent::setUp(); |
|
| 23 | + protected function setUp() |
|
| 24 | + { |
|
| 25 | + parent::setUp(); |
|
| 26 | 26 | |
| 27 | - $this->versionProvider = $this->createMock(VersionProvider::class); |
|
| 28 | - $this->leftAndMain = $this->createMock(LeftAndMain::class); |
|
| 27 | + $this->versionProvider = $this->createMock(VersionProvider::class); |
|
| 28 | + $this->leftAndMain = $this->createMock(LeftAndMain::class); |
|
| 29 | 29 | |
| 30 | - $this->leftAndMain |
|
| 31 | - ->expects($this->atLeastOnce()) |
|
| 32 | - ->method('getVersionProvider') |
|
| 33 | - ->willReturn($this->versionProvider); |
|
| 34 | - } |
|
| 30 | + $this->leftAndMain |
|
| 31 | + ->expects($this->atLeastOnce()) |
|
| 32 | + ->method('getVersionProvider') |
|
| 33 | + ->willReturn($this->versionProvider); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @param array $modules |
|
| 38 | - * @param string $expected |
|
| 39 | - * @dataProvider getVersionProvider |
|
| 40 | - */ |
|
| 41 | - public function testGetVersion($modules, $expected) |
|
| 42 | - { |
|
| 43 | - $this->versionProvider->expects($this->once()) |
|
| 44 | - ->method('getModuleVersionFromComposer') |
|
| 45 | - ->willReturn($modules); |
|
| 36 | + /** |
|
| 37 | + * @param array $modules |
|
| 38 | + * @param string $expected |
|
| 39 | + * @dataProvider getVersionProvider |
|
| 40 | + */ |
|
| 41 | + public function testGetVersion($modules, $expected) |
|
| 42 | + { |
|
| 43 | + $this->versionProvider->expects($this->once()) |
|
| 44 | + ->method('getModuleVersionFromComposer') |
|
| 45 | + ->willReturn($modules); |
|
| 46 | 46 | |
| 47 | - $extension = new CWPVersionExtension(); |
|
| 48 | - $extension->setOwner($this->leftAndMain); |
|
| 47 | + $extension = new CWPVersionExtension(); |
|
| 48 | + $extension->setOwner($this->leftAndMain); |
|
| 49 | 49 | |
| 50 | - $result = $extension->getCWPVersionNumber(); |
|
| 51 | - $this->assertSame($expected, $result); |
|
| 52 | - } |
|
| 50 | + $result = $extension->getCWPVersionNumber(); |
|
| 51 | + $this->assertSame($expected, $result); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function getVersionProvider() |
|
| 58 | - { |
|
| 59 | - return [ |
|
| 60 | - 'dev version' => [['cwp/cwp-core' => '2.3.x-dev'], '2.3'], |
|
| 61 | - 'stable version' => [['cwp/cwp-core' => '2.2.0'], '2.2'], |
|
| 62 | - 'not found' => [[], ''], |
|
| 63 | - ]; |
|
| 64 | - } |
|
| 54 | + /** |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function getVersionProvider() |
|
| 58 | + { |
|
| 59 | + return [ |
|
| 60 | + 'dev version' => [['cwp/cwp-core' => '2.3.x-dev'], '2.3'], |
|
| 61 | + 'stable version' => [['cwp/cwp-core' => '2.2.0'], '2.2'], |
|
| 62 | + 'not found' => [[], ''], |
|
| 63 | + ]; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -7,23 +7,23 @@ |
||
| 7 | 7 | |
| 8 | 8 | class CWPVersionExtension extends Extension |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Gets the version of cwp/cwp-core and returns the major.minor version from it |
|
| 12 | - * |
|
| 13 | - * @return string |
|
| 14 | - */ |
|
| 15 | - public function getCWPVersionNumber() |
|
| 16 | - { |
|
| 17 | - /** @var VersionProvider $versionProvider */ |
|
| 18 | - $versionProvider = $this->owner->getVersionProvider(); |
|
| 10 | + /** |
|
| 11 | + * Gets the version of cwp/cwp-core and returns the major.minor version from it |
|
| 12 | + * |
|
| 13 | + * @return string |
|
| 14 | + */ |
|
| 15 | + public function getCWPVersionNumber() |
|
| 16 | + { |
|
| 17 | + /** @var VersionProvider $versionProvider */ |
|
| 18 | + $versionProvider = $this->owner->getVersionProvider(); |
|
| 19 | 19 | |
| 20 | - $modules = $versionProvider->getModuleVersionFromComposer(['cwp/cwp-core']); |
|
| 21 | - if (empty($modules)) { |
|
| 22 | - return ''; |
|
| 23 | - } |
|
| 20 | + $modules = $versionProvider->getModuleVersionFromComposer(['cwp/cwp-core']); |
|
| 21 | + if (empty($modules)) { |
|
| 22 | + return ''; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - // Example: "2.2.x-dev" |
|
| 26 | - $cwpCore = $modules['cwp/cwp-core']; |
|
| 27 | - return (string) substr($cwpCore, 0, strpos($cwpCore, '.', 2)); |
|
| 28 | - } |
|
| 25 | + // Example: "2.2.x-dev" |
|
| 26 | + $cwpCore = $modules['cwp/cwp-core']; |
|
| 27 | + return (string) substr($cwpCore, 0, strpos($cwpCore, '.', 2)); |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -24,6 +24,6 @@ |
||
| 24 | 24 | |
| 25 | 25 | // Example: "2.2.x-dev" |
| 26 | 26 | $cwpCore = $modules['cwp/cwp-core']; |
| 27 | - return (string) substr($cwpCore, 0, strpos($cwpCore, '.', 2)); |
|
| 27 | + return (string)substr($cwpCore, 0, strpos($cwpCore, '.', 2)); |
|
| 28 | 28 | } |
| 29 | 29 | } |