ProgressinfoHelperTest
extends TestCase
in package
ProgressinfoHelper Test Class
This class contains the main tests for the ProgressinfoHelper Class.
Table of Contents
Properties
- $autoFixtures : bool
- By default, all fixtures attached to this class will be truncated and reloaded after each test.
- $dropTables : bool
- Control table create/drops on each test method.
- $fixtureManager : FixtureManager|null
- The class responsible for managing the creation, loading and removing of fixtures
- $_configure : array<string|int, mixed>
- Configure values to restore at end of test.
- $_tableLocator : LocatorInterface|null
- Table locator instance
- $defaultTable : string|null
- This object's default table alias.
- $fixtures : array<string|int, string>
- Fixtures used by this test case.
- $fixtureStrategy : FixtureStrategyInterface|null
- $helper : ProgressinfoHelper
- $io : ConsoleIo
- $stub : StubConsoleOutput
Methods
- assertDirectoryDoesNotExist() : void
- Asserts that a directory does not exist.
- assertDoesNotMatchRegularExpression() : void
- Asserts that a string does not match a given regular expression.
- assertEqualsSql() : void
- Assert that a string matches SQL with db-specific characters like quotes removed.
- assertEventFired() : void
- Asserts that a global event was fired. You must track events in your event manager for this assertion to work
- assertEventFiredWith() : void
- Asserts an event was fired with data
- assertFileDoesNotExist() : void
- Asserts that a file does not exist.
- assertHtml() : bool
- Asserts HTML tags.
- assertMatchesRegularExpression() : void
- Asserts that a string matches a given regular expression.
- assertRegExpSql() : void
- Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters `<` and `>`. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
- assertTextContains() : void
- Assert that a string contains another string, ignoring differences in newlines.
- assertTextEndsNotWith() : void
- Asserts that a string ends not with a given prefix, ignoring differences in newlines.
- assertTextEndsWith() : void
- Asserts that a string ends with a given prefix, ignoring differences in newlines.
- assertTextEquals() : void
- Assert text equality, ignoring differences in newlines.
- assertTextNotContains() : void
- Assert that a text doesn't contain another text, ignoring differences in newlines.
- assertTextNotEquals() : void
- Assert text equality, ignoring differences in newlines.
- assertTextStartsNotWith() : void
- Asserts that a string starts not with a given prefix, ignoring differences in newlines.
- assertTextStartsWith() : void
- Asserts that a string starts with a given prefix, ignoring differences in newlines.
- clearPlugins() : void
- Clear all plugins from the global plugin collection.
- deprecated() : void
- Helper method for check deprecation methods
- fetchTable() : Table
- Convenience method to get a table instance.
- getFixtures() : array<string|int, string>
- Get the fixtures this test should use.
- getMockForModel() : Table|MockObject
- Mock a model, maintain fixtures and table association
- getTableLocator() : LocatorInterface
- Gets the table locator.
- loadFixtures() : void
- Chooses which fixtures to load for a given test
- loadPlugins() : BaseApplication
- Load plugins into a simulated application.
- loadRoutes() : void
- Load routes for the application.
- removePlugins() : void
- Remove plugins from the global plugin collection.
- setAppNamespace() : string|null
- Set the app namespace
- setTableLocator() : $this
- Sets the table locator.
- setUp() : void
- setUp method
- skipIf() : bool
- Overrides SimpleTestCase::skipIf to provide a boolean return value
- testAllOptionsCallback() : void
- testIncrementAndRender() : void
- Test using the helper manually.
- testIncrementAndRenderChained() : void
- Test using the helper chained.
- testIncrementAndRenderWithInfo() : void
- Test using the helper manually.
- testIncrementFloatPad() : void
- Test increment and draw with value that makes the pad be a float
- testIncrementWithComposer() : void
- Test increment and draw with options
- testIncrementWithNegatives() : void
- Test negative numbers
- testIncrementWithOptions() : void
- Test increment and draw with options
- testInit() : void
- Test using the helper manually.
- testInitChars() : void
- Test using the helper manually.
- testOptionComposerCallback() : void
- testOutputFailure() : void
- Test that a callback is required.
- testOutputSuccess() : void
- Test that the callback is invoked until 100 is reached.
- testOutputSuccessCallbackInfo() : void
- Test output with options
- testOutputSuccessOptions() : void
- Test output with options
- testOutputSuccessOptionsShowCount() : void
- Test output with options
- testOutputSuccessOptionsShowCountFormat() : void
- Test output with options
- testSetArrowChar1() : void
- Test setting characters.
- testSetArrowChar2() : void
- Test setting characters.
- testSetCloseChar1() : void
- Test setting characters.
- testSetCloseChar2() : void
- Test setting characters.
- testSetOpenChar1() : void
- Test setting characters.
- testSetOpenChar2() : void
- Test setting characters.
- testSetPadChar1() : void
- Test setting characters.
- testSetPadChar2() : void
- Test setting characters.
- testSetProgressChar1() : void
- Test setting characters.
- testSetProgressChar2() : void
- Test setting characters.
- withErrorReporting() : void
- Helper method for tests that needs to use error_reporting()
- _assertAttributes() : string|false
- Check the attributes as part of an assertTags() check.
- _getTableClassName() : string
- Gets the class name for the table.
- _normalizePath() : string
- Normalize a path for comparison.
- addFixture() : $this
- Adds a fixture to this test case.
- assertNotWithinRange() : void
- Compatibility function to test if a value is not between an acceptable range.
- assertPathEquals() : void
- Compatibility function to test paths.
- assertWithinRange() : void
- Compatibility function to test if a value is between an acceptable range.
- getFixtureStrategy() : FixtureStrategyInterface
- Returns fixture strategy used by these tests.
- setupFixtures() : void
- Initialized and loads any use fixtures.
- skipUnless() : bool
- Compatibility function for skipping.
- tearDown() : void
- teardown any static object changes and restore them.
- teardownFixtures() : void
- Unloads any use fixtures.
Properties
$autoFixtures
By default, all fixtures attached to this class will be truncated and reloaded after each test.
autoFixtures is only used by deprecated fixture features. This property will be removed in 5.0
public
bool
$autoFixtures
= true
Set this to false to handle manually
$dropTables
Control table create/drops on each test method.
dropTables is only used by deprecated fixture features. This property will be removed in 5.0
public
bool
$dropTables
= false
If true, tables will still be dropped at the end of each test runner execution.
$fixtureManager
The class responsible for managing the creation, loading and removing of fixtures
public
static FixtureManager|null
$fixtureManager
$_configure
Configure values to restore at end of test.
protected
array<string|int, mixed>
$_configure
= []
$_tableLocator
Table locator instance
protected
LocatorInterface|null
$_tableLocator
$defaultTable
This object's default table alias.
protected
string|null
$defaultTable
= null
$fixtures
Fixtures used by this test case.
protected
array<string|int, string>
$fixtures
= []
$fixtureStrategy
protected
FixtureStrategyInterface|null
$fixtureStrategy
= null
$helper
protected
ProgressinfoHelper
$helper
$io
protected
ConsoleIo
$io
$stub
protected
StubConsoleOutput
$stub
Methods
assertDirectoryDoesNotExist()
Asserts that a directory does not exist.
public
static assertDirectoryDoesNotExist(string $directory[, string $message = '' ]) : void
Parameters
- $directory : string
-
Directory
- $message : string = ''
-
Message
Tags
assertDoesNotMatchRegularExpression()
Asserts that a string does not match a given regular expression.
public
static assertDoesNotMatchRegularExpression(string $pattern, string $string[, string $message = '' ]) : void
Parameters
- $pattern : string
-
Regex pattern
- $string : string
-
String to test
- $message : string = ''
-
Message
Tags
assertEqualsSql()
Assert that a string matches SQL with db-specific characters like quotes removed.
public
assertEqualsSql(string $expected, string $actual[, string $message = '' ]) : void
Parameters
- $expected : string
-
The expected sql
- $actual : string
-
The sql to compare
- $message : string = ''
-
The message to display on failure
assertEventFired()
Asserts that a global event was fired. You must track events in your event manager for this assertion to work
public
assertEventFired(string $name[, EventManager|null $eventManager = null ][, string $message = '' ]) : void
Parameters
- $name : string
-
Event name
- $eventManager : EventManager|null = null
-
Event manager to check, defaults to global event manager
- $message : string = ''
-
Assertion failure message
assertEventFiredWith()
Asserts an event was fired with data
public
assertEventFiredWith(string $name, string $dataKey, mixed $dataValue[, EventManager|null $eventManager = null ][, string $message = '' ]) : void
If a third argument is passed, that value is used to compare with the value in $dataKey
Parameters
- $name : string
-
Event name
- $dataKey : string
-
Data key
- $dataValue : mixed
-
Data value
- $eventManager : EventManager|null = null
-
Event manager to check, defaults to global event manager
- $message : string = ''
-
Assertion failure message
assertFileDoesNotExist()
Asserts that a file does not exist.
public
static assertFileDoesNotExist(string $filename[, string $message = '' ]) : void
Parameters
- $filename : string
-
Filename
- $message : string = ''
-
Message
Tags
assertHtml()
Asserts HTML tags.
public
assertHtml(array<string|int, mixed> $expected, string $string[, bool $fullDebug = false ]) : bool
Takes an array $expected and generates a regex from it to match the provided $string. Samples for $expected:
Checks for an input tag with a name attribute (contains any non-empty value) and an id attribute that contains 'my-input':
['input' => ['name', 'id' => 'my-input']]
Checks for two p elements with some text in them:
[
['p' => true],
'textA',
'/p',
['p' => true],
'textB',
'/p'
]
You can also specify a pattern expression as part of the attribute values, or the tag being defined, if you prepend the value with preg: and enclose it with slashes, like so:
[
['input' => ['name', 'id' => 'preg:/FieldName\d+/']],
'preg:/My\s+field/'
]
Important: This function is very forgiving about whitespace and also accepts any permutation of attribute order. It will also allow whitespace between specified tags.
Parameters
- $expected : array<string|int, mixed>
-
An array, see above
- $string : string
-
An HTML/XHTML/XML string
- $fullDebug : bool = false
-
Whether more verbose output should be used.
Return values
boolassertMatchesRegularExpression()
Asserts that a string matches a given regular expression.
public
static assertMatchesRegularExpression(string $pattern, string $string[, string $message = '' ]) : void
Parameters
- $pattern : string
-
Regex pattern
- $string : string
-
String to test
- $message : string = ''
-
Message
Tags
assertRegExpSql()
Assertion for comparing a regex pattern against a query having its identifiers quoted. It accepts queries quoted with the characters `<` and `>`. If the third parameter is set to true, it will alter the pattern to both accept quoted and unquoted queries
public
assertRegExpSql(string $pattern, string $actual[, bool $optional = false ]) : void
Parameters
- $pattern : string
-
The expected sql pattern
- $actual : string
-
The sql to compare
- $optional : bool = false
-
Whether quote characters (marked with <>) are optional
assertTextContains()
Assert that a string contains another string, ignoring differences in newlines.
public
assertTextContains(string $needle, string $haystack[, string $message = '' ][, bool $ignoreCase = false ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $needle : string
-
The string to search for.
- $haystack : string
-
The string to search through.
- $message : string = ''
-
The message to display on failure.
- $ignoreCase : bool = false
-
Whether the search should be case-sensitive.
assertTextEndsNotWith()
Asserts that a string ends not with a given prefix, ignoring differences in newlines.
public
assertTextEndsNotWith(string $suffix, string $string[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $suffix : string
-
The suffix to not find.
- $string : string
-
The string to search.
- $message : string = ''
-
The message to use for failure.
assertTextEndsWith()
Asserts that a string ends with a given prefix, ignoring differences in newlines.
public
assertTextEndsWith(string $suffix, string $string[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $suffix : string
-
The suffix to find.
- $string : string
-
The string to search.
- $message : string = ''
-
The message to use for failure.
assertTextEquals()
Assert text equality, ignoring differences in newlines.
public
assertTextEquals(string $expected, string $result[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $expected : string
-
The expected value.
- $result : string
-
The actual value.
- $message : string = ''
-
The message to use for failure.
assertTextNotContains()
Assert that a text doesn't contain another text, ignoring differences in newlines.
public
assertTextNotContains(string $needle, string $haystack[, string $message = '' ][, bool $ignoreCase = false ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $needle : string
-
The string to search for.
- $haystack : string
-
The string to search through.
- $message : string = ''
-
The message to display on failure.
- $ignoreCase : bool = false
-
Whether the search should be case-sensitive.
assertTextNotEquals()
Assert text equality, ignoring differences in newlines.
public
assertTextNotEquals(string $expected, string $result[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $expected : string
-
The expected value.
- $result : string
-
The actual value.
- $message : string = ''
-
The message to use for failure.
assertTextStartsNotWith()
Asserts that a string starts not with a given prefix, ignoring differences in newlines.
public
assertTextStartsNotWith(string $prefix, string $string[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $prefix : string
-
The prefix to not find.
- $string : string
-
The string to search.
- $message : string = ''
-
The message to use for failure.
assertTextStartsWith()
Asserts that a string starts with a given prefix, ignoring differences in newlines.
public
assertTextStartsWith(string $prefix, string $string[, string $message = '' ]) : void
Helpful for doing cross platform tests of blocks of text.
Parameters
- $prefix : string
-
The prefix to check for.
- $string : string
-
The string to search in.
- $message : string = ''
-
The message to use for failure.
clearPlugins()
Clear all plugins from the global plugin collection.
public
clearPlugins() : void
Useful in test case teardown methods.
deprecated()
Helper method for check deprecation methods
public
deprecated(callable $callable) : void
Parameters
- $callable : callable
-
callable function that will receive asserts
fetchTable()
Convenience method to get a table instance.
public
fetchTable([string|null $alias = null ][, array<string, mixed> $options = [] ]) : Table
Parameters
- $alias : string|null = null
-
The alias name you want to get. Should be in CamelCase format. If
null
then the value of $defaultTable property is used. - $options : array<string, mixed> = []
-
The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Tags
Return values
TablegetFixtures()
Get the fixtures this test should use.
public
getFixtures() : array<string|int, string>
Return values
array<string|int, string>getMockForModel()
Mock a model, maintain fixtures and table association
public
getMockForModel(string $alias[, array<string|int, string> $methods = [] ][, array<string, mixed> $options = [] ]) : Table|MockObject
Parameters
- $alias : string
-
The model to get a mock for.
- $methods : array<string|int, string> = []
-
The list of methods to mock
- $options : array<string, mixed> = []
-
The config data for the mock's constructor.
Tags
Return values
Table|MockObjectgetTableLocator()
Gets the table locator.
public
getTableLocator() : LocatorInterface
Return values
LocatorInterfaceloadFixtures()
Chooses which fixtures to load for a given test
public
loadFixtures() : void
Disabling auto-fixtures is deprecated and only available using FixtureInjector fixture system.
Each parameter is a model name that corresponds to a fixture, i.e. 'Posts', 'Authors', etc. Passing no parameters will cause all fixtures on the test case to load.
Tags
loadPlugins()
Load plugins into a simulated application.
public
loadPlugins([array<string, mixed> $plugins = [] ]) : BaseApplication
Useful to test how plugins being loaded/not loaded interact with other elements in CakePHP or applications.
Parameters
- $plugins : array<string, mixed> = []
-
List of Plugins to load.
Return values
BaseApplicationloadRoutes()
Load routes for the application.
public
loadRoutes([array<string|int, mixed>|null $appArgs = null ]) : void
If no application class can be found an exception will be raised.
Routes for plugins will not be loaded. Use loadPlugins()
or use
Cake\TestSuite\IntegrationTestCaseTrait
to better simulate all routes
and plugins being loaded.
Parameters
- $appArgs : array<string|int, mixed>|null = null
-
Constructor parameters for the application class.
Tags
removePlugins()
Remove plugins from the global plugin collection.
public
removePlugins([array<string|int, string> $names = [] ]) : void
Useful in test case teardown methods.
Parameters
- $names : array<string|int, string> = []
-
A list of plugins you want to remove.
setAppNamespace()
Set the app namespace
public
static setAppNamespace([string $appNamespace = 'TestApp' ]) : string|null
Parameters
- $appNamespace : string = 'TestApp'
-
The app namespace, defaults to "TestApp".
Return values
string|null —The previous app namespace or null if not set.
setTableLocator()
Sets the table locator.
public
setTableLocator(LocatorInterface $tableLocator) : $this
Parameters
- $tableLocator : LocatorInterface
-
LocatorInterface instance.
Return values
$thissetUp()
setUp method
public
setUp() : void
skipIf()
Overrides SimpleTestCase::skipIf to provide a boolean return value
public
skipIf(bool $shouldSkip[, string $message = '' ]) : bool
Parameters
- $shouldSkip : bool
-
Whether the test should be skipped.
- $message : string = ''
-
The message to display.
Return values
booltestAllOptionsCallback()
public
testAllOptionsCallback() : void
testIncrementAndRender()
Test using the helper manually.
public
testIncrementAndRender() : void
testIncrementAndRenderChained()
Test using the helper chained.
public
testIncrementAndRenderChained() : void
testIncrementAndRenderWithInfo()
Test using the helper manually.
public
testIncrementAndRenderWithInfo() : void
testIncrementFloatPad()
Test increment and draw with value that makes the pad be a float
public
testIncrementFloatPad() : void
testIncrementWithComposer()
Test increment and draw with options
public
testIncrementWithComposer() : void
testIncrementWithNegatives()
Test negative numbers
public
testIncrementWithNegatives() : void
testIncrementWithOptions()
Test increment and draw with options
public
testIncrementWithOptions() : void
testInit()
Test using the helper manually.
public
testInit() : void
testInitChars()
Test using the helper manually.
public
testInitChars() : void
testOptionComposerCallback()
public
testOptionComposerCallback() : void
testOutputFailure()
Test that a callback is required.
public
testOutputFailure() : void
testOutputSuccess()
Test that the callback is invoked until 100 is reached.
public
testOutputSuccess() : void
testOutputSuccessCallbackInfo()
Test output with options
public
testOutputSuccessCallbackInfo() : void
testOutputSuccessOptions()
Test output with options
public
testOutputSuccessOptions() : void
testOutputSuccessOptionsShowCount()
Test output with options
public
testOutputSuccessOptionsShowCount() : void
testOutputSuccessOptionsShowCountFormat()
Test output with options
public
testOutputSuccessOptionsShowCountFormat() : void
testSetArrowChar1()
Test setting characters.
public
testSetArrowChar1() : void
testSetArrowChar2()
Test setting characters.
public
testSetArrowChar2() : void
testSetCloseChar1()
Test setting characters.
public
testSetCloseChar1() : void
testSetCloseChar2()
Test setting characters.
public
testSetCloseChar2() : void
testSetOpenChar1()
Test setting characters.
public
testSetOpenChar1() : void
testSetOpenChar2()
Test setting characters.
public
testSetOpenChar2() : void
testSetPadChar1()
Test setting characters.
public
testSetPadChar1() : void
testSetPadChar2()
Test setting characters.
public
testSetPadChar2() : void
testSetProgressChar1()
Test setting characters.
public
testSetProgressChar1() : void
testSetProgressChar2()
Test setting characters.
public
testSetProgressChar2() : void
withErrorReporting()
Helper method for tests that needs to use error_reporting()
public
withErrorReporting(int $errorLevel, callable $callable) : void
Parameters
- $errorLevel : int
-
value of error_reporting() that needs to use
- $callable : callable
-
callable function that will receive asserts
_assertAttributes()
Check the attributes as part of an assertTags() check.
protected
_assertAttributes(array<string, mixed> $assertions, string $string[, bool $fullDebug = false ][, array<string|int, mixed>|string $regex = '' ]) : string|false
Parameters
- $assertions : array<string, mixed>
-
Assertions to run.
- $string : string
-
The HTML string to check.
- $fullDebug : bool = false
-
Whether more verbose output should be used.
- $regex : array<string|int, mixed>|string = ''
-
Full regexp from
assertHtml
Return values
string|false_getTableClassName()
Gets the class name for the table.
protected
_getTableClassName(string $alias, array<string, mixed> $options) : string
Parameters
- $alias : string
-
The model to get a mock for.
- $options : array<string, mixed>
-
The config data for the mock's constructor.
Tags
Return values
string_normalizePath()
Normalize a path for comparison.
protected
_normalizePath(string $path) : string
Parameters
- $path : string
-
Path separated by "/" slash.
Return values
string —Normalized path separated by DIRECTORY_SEPARATOR.
addFixture()
Adds a fixture to this test case.
protected
addFixture(string $fixture) : $this
Examples:
- core.Tags
- app.MyRecords
- plugin.MyPluginName.MyModelName
Use this method inside your test cases' method to build up the fixture list.
Parameters
- $fixture : string
-
Fixture
Return values
$thisassertNotWithinRange()
Compatibility function to test if a value is not between an acceptable range.
protected
static assertNotWithinRange(float $expected, float $result, float $margin[, string $message = '' ]) : void
Parameters
- $expected : float
- $result : float
- $margin : float
-
the rage of acceptation
- $message : string = ''
-
the text to display if the assertion is not correct
assertPathEquals()
Compatibility function to test paths.
protected
static assertPathEquals(string $expected, string $result[, string $message = '' ]) : void
Parameters
- $expected : string
- $result : string
- $message : string = ''
-
the text to display if the assertion is not correct
assertWithinRange()
Compatibility function to test if a value is between an acceptable range.
protected
static assertWithinRange(float $expected, float $result, float $margin[, string $message = '' ]) : void
Parameters
- $expected : float
- $result : float
- $margin : float
-
the rage of acceptation
- $message : string = ''
-
the text to display if the assertion is not correct
getFixtureStrategy()
Returns fixture strategy used by these tests.
protected
getFixtureStrategy() : FixtureStrategyInterface
Return values
FixtureStrategyInterfacesetupFixtures()
Initialized and loads any use fixtures.
protected
setupFixtures() : void
skipUnless()
Compatibility function for skipping.
protected
skipUnless(bool $condition[, string $message = '' ]) : bool
Parameters
- $condition : bool
-
Condition to trigger skipping
- $message : string = ''
-
Message for skip
Return values
booltearDown()
teardown any static object changes and restore them.
protected
tearDown() : void
teardownFixtures()
Unloads any use fixtures.
protected
teardownFixtures() : void