mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
composer.json - move tests-related classes to "autoload-dev" section (used for development purposes only and avoid polluting the autoloader in production)
This commit is contained in:
93
tests/Utilities/ComposerTest.php
Normal file
93
tests/Utilities/ComposerTest.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* (c) Meritoo.pl, http://www.meritoo.pl
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Meritoo\Common\Test\Utilities;
|
||||
|
||||
use Generator;
|
||||
use Meritoo\Common\Test\Base\BaseTestCase;
|
||||
use Meritoo\Common\Utilities\Composer;
|
||||
|
||||
/**
|
||||
* Test case of the useful Composer-related methods
|
||||
*
|
||||
* @author Krzysztof Niziol <krzysztof.niziol@meritoo.pl>
|
||||
* @copyright Meritoo.pl
|
||||
*/
|
||||
class ComposerTest extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* Path of existing composer.json used as source of data for tests
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $composerJsonPath;
|
||||
|
||||
public function verifyConstructor()
|
||||
{
|
||||
static::assertHasNoConstructor(Composer::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $composerJsonPath Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testGetValueNotExistingComposerJson($composerJsonPath)
|
||||
{
|
||||
self::assertNull(Composer::getValue($composerJsonPath, ''));
|
||||
self::assertNull(Composer::getValue('not/existing/composer.json', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $nodeName Empty value, e.g. ""
|
||||
* @dataProvider provideEmptyValue
|
||||
*/
|
||||
public function testGetValueNotExistingNode($nodeName)
|
||||
{
|
||||
self::assertNull(Composer::getValue($this->composerJsonPath, $nodeName));
|
||||
self::assertNull(Composer::getValue($this->composerJsonPath, 'not_existing_node'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $nodeName Name of existing node
|
||||
* @param string $nodeValue Value of existing node
|
||||
*
|
||||
* @dataProvider getExistingNode
|
||||
*/
|
||||
public function testGetValueExistingNode($nodeName, $nodeValue)
|
||||
{
|
||||
self::assertEquals($nodeValue, Composer::getValue($this->composerJsonPath, $nodeName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides names and values of existing nodes
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function getExistingNode()
|
||||
{
|
||||
yield[
|
||||
'name',
|
||||
'test/test',
|
||||
];
|
||||
|
||||
yield[
|
||||
'version',
|
||||
'1.0.2',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->composerJsonPath = $this->getFilePathToTests(Composer::FILE_NAME_MAIN);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user