This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/vendor/drupal/console/Test/Helper/StringHelperTest.php

56 lines
1.4 KiB
PHP
Raw Normal View History

2018-11-23 12:29:20 +00:00
<?php
namespace Drupal\Console\Test\Helper;
use Drupal\Console\Helper\StringHelper;
class StringHelperTest extends \PHPUnit_Framework_TestCase
{
/* @var $stringHelper */
protected $stringHelper;
protected function setUp()
{
$this->stringHelper = new StringHelper();
}
/**
* @dataProvider getDataNames
*/
public function testCreateMachineName($input, $machine_name)
{
$this->assertEquals($this->stringHelper->createMachineName($input), $machine_name);
}
/**
* @dataProvider getDataCamelCaseNames
*/
public function testCamelCaseToMachineName($camel_case, $machine_name)
{
$this->assertEquals($this->stringHelper->camelCaseToMachineName($camel_case), $machine_name);
}
/**
* Random strings and their equivalent machine-name
*/
public function getDataNames()
{
return [
['Test Space between words', 'test_space_between_words'],
['test$special*characters!', 'test_special_characters'],
['URL', 'url'],
];
}
/**
* Camel-case strings and their equivalent machine-name
*/
public function getDataCamelCaseNames()
{
return [
['camelCase', 'camel_case'],
['greatestFunctionEverWritten', 'greatest_function_ever_written'],
['WakeUp', 'wake_up'],
];
}
}