CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Team
    • Issues (Github)
    • YouTube Channel
    • Get Involved
    • Bakery
    • Featured Resources
    • Newsletter
    • Certification
    • My CakePHP
    • CakeFest
    • Facebook
    • Twitter
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.5 Red Velvet API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 3.5
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Cake
    • Auth
      • Storage
    • Cache
      • Engine
    • Collection
      • Iterator
    • Console
      • Exception
    • Controller
      • Component
      • Exception
    • Core
      • Configure
        • Engine
      • Exception
    • Database
      • Driver
      • Exception
      • Expression
      • Schema
      • Statement
      • Type
    • Datasource
      • Exception
    • Error
      • Middleware
    • Event
      • Decorator
    • Filesystem
    • Form
    • Http
      • Client
        • Adapter
        • Auth
      • Cookie
      • Middleware
    • I18n
      • Formatter
      • Middleware
      • Parser
    • Log
      • Engine
    • Mailer
      • Exception
      • Transport
    • Network
      • Exception
      • Session
    • ORM
      • Association
      • Behavior
        • Translate
      • Exception
      • Locator
      • Rule
    • Routing
      • Exception
      • Filter
      • Middleware
      • Route
    • Shell
      • Helper
      • Task
    • TestSuite
      • Constraint
      • Fixture
      • Stub
    • Utility
      • Exception
    • Validation
    • View
      • Exception
      • Form
      • Helper
      • Widget
  • None

Classes

  • ConsoleIntegrationTestCase
  • IntegrationTestCase
  • LegacyCommandRunner
  • LegacyShellDispatcher
  • TestCase
  • TestSuite

Traits

  • EmailAssertTrait
  • StringCompareTrait

Class ConsoleIntegrationTestCase

A test case class intended to make integration tests of cake console commands easier.

PHPUnit\Framework\TestCase
Extended by Cake\TestSuite\TestCase
Extended by Cake\TestSuite\ConsoleIntegrationTestCase
Namespace: Cake\TestSuite
Location: TestSuite/ConsoleIntegrationTestCase.php

Properties summary

  • $_err protected
    Cake\Console\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null
    Console error output stub
  • $_exitCode protected
    integer|null
    Last exit code
  • $_in protected
    Cake\Console\ConsoleInput|PHPUnit_Framework_MockObject_MockObject|null
    Console input mock
  • $_out protected
    Cake\Console\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null
    Console output stub
  • $_useCommandRunner protected
    boolean
    Whether or not to use the CommandRunner

Inherited Properties

  • _configure, _pathRestore, autoFixtures, dropTables, fixtureManager

Method Summary

  • _commandStringToArgs() protected
    Creates an $argv array from a command string
  • _makeRunner() protected
    Builds the appropriate command dispatcher
  • assertErrorContains() public
    Asserts stderr contains expected output
  • assertErrorEmpty() public
    Asserts that stderr is empty
  • assertErrorRegExp() public
    Asserts stderr contains expected regexp
  • assertExitCode() public
    Asserts shell exited with the expected code
  • assertOutputContains() public
    Asserts stdout contains expected output
  • assertOutputContainsRow() protected
    Check that a row of cells exists in the output.
  • assertOutputEmpty() public
    Asserts that stdout is empty
  • assertOutputRegExp() public
    Asserts stdout contains expected regexp
  • exec() public
    Runs cli integration test
  • tearDown() public
    tearDown
  • useCommandRunner() public

    Set this test case to use the CommandRunner rather than the legacy ShellDispatcher

Method Detail

_commandStringToArgs() protected ¶

_commandStringToArgs( string $command )

Creates an $argv array from a command string

Parameters
string $command
Command string
Returns
array

_makeRunner() protected ¶

_makeRunner( )

Builds the appropriate command dispatcher

Returns
Cake\Console\CommandRunner|Cake\TestSuite\LegacyCommandRunner

assertErrorContains() public ¶

assertErrorContains( string $expected , string $message '' )

Asserts stderr contains expected output

Parameters
string $expected
Expected output
string $message optional ''
Failure message

assertErrorEmpty() public ¶

assertErrorEmpty( string $message 'stderr was not empty' )

Asserts that stderr is empty

Parameters
string $message optional 'stderr was not empty'
The message to output when the assertion fails.

assertErrorRegExp() public ¶

assertErrorRegExp( string $pattern , string $message '' )

Asserts stderr contains expected regexp

Parameters
string $pattern
Expected pattern
string $message optional ''
Failure message

assertExitCode() public ¶

assertExitCode( integer $expected , string $message '' )

Asserts shell exited with the expected code

Parameters
integer $expected
Expected exit code
string $message optional ''
Failure message to be appended to the generated message

assertOutputContains() public ¶

assertOutputContains( string $expected , string $message '' )

Asserts stdout contains expected output

Parameters
string $expected
Expected output
string $message optional ''
Failure message

assertOutputContainsRow() protected ¶

assertOutputContainsRow( array $row , string $message '' )

Check that a row of cells exists in the output.

Parameters
array $row
Row of cells to ensure exist in the output.
string $message optional ''
Failure message.

assertOutputEmpty() public ¶

assertOutputEmpty( string $message 'stdout was not empty' )

Asserts that stdout is empty

Parameters
string $message optional 'stdout was not empty'
The message to output when the assertion fails.

assertOutputRegExp() public ¶

assertOutputRegExp( string $pattern , string $message '' )

Asserts stdout contains expected regexp

Parameters
string $pattern
Expected pattern
string $message optional ''
Failure message

exec() public ¶

exec( string $command , array $input [] )

Runs cli integration test

Parameters
string $command
Command to run
array $input optional []
Input values to pass to an interactive shell

tearDown() public ¶

tearDown( )

tearDown

Overrides
Cake\TestSuite\TestCase::tearDown()

useCommandRunner() public ¶

useCommandRunner( )

Set this test case to use the CommandRunner rather than the legacy ShellDispatcher

Methods inherited from Cake\TestSuite\TestCase

_assertAttributes() protected ¶

_assertAttributes( array $assertions , string $string , boolean $fullDebug false , array|string $regex '' )

Check the attributes as part of an assertTags() check.

Parameters
array $assertions
Assertions to run.
string $string
The HTML string to check.
boolean $fullDebug optional false
Whether or not more verbose output should be used.
array|string $regex optional ''
Full regexp from assertHtml
Returns
string|boolean

_normalizePath() protected ¶

_normalizePath( string $path )

Normalize a path for comparison.

Parameters
string $path
Path separated by "/" slash.
Returns
string
Normalized path separated by DIRECTORY_SEPARATOR.

assertEventFired() public ¶

assertEventFired( string $name , Cake\Event\EventManager|null $eventManager null , string $message '' )

Asserts that a global event was fired. You must track events in your event manager for this assertion to work

Parameters
string $name
Event name
Cake\Event\EventManager|null $eventManager optional null
Event manager to check, defaults to global event manager
string $message optional ''
Assertion failure message

assertEventFiredWith() public ¶

assertEventFiredWith( string $name , string $dataKey , string $dataValue , Cake\Event\EventManager|null $eventManager null , string $message '' )

Asserts an event was fired with data

If a third argument is passed, that value is used to compare with the value in $dataKey

Parameters
string $name
Event name
string $dataKey
Data key
string $dataValue
Data value
Cake\Event\EventManager|null $eventManager optional null
Event manager to check, defaults to global event manager
string $message optional ''
Assertion failure message

assertHtml() public ¶

assertHtml( array $expected , string $string , boolean $fullDebug false )

Asserts HTML tags.

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
array $expected
An array, see above
string $string
An HTML/XHTML/XML string
boolean $fullDebug optional false
Whether or not more verbose output should be used.
Returns
boolean

assertNotWithinRange() protected static ¶

assertNotWithinRange( float $expected , float $result , float $margin , string $message '' )

Compatibility function to test if a value is not between an acceptable range.

Parameters
float $expected
float $result
float $margin
the rage of acceptation
string $message optional ''
the text to display if the assertion is not correct

assertPathEquals() protected static ¶

assertPathEquals( string $expected , string $result , string $message '' )

Compatibility function to test paths.

Parameters
string $expected
string $result
string $message optional ''
the text to display if the assertion is not correct

assertTags() public ¶

assertTags( string $string , array $expected , boolean $fullDebug false )

Asserts HTML tags.

Deprecated
3.0. Use assertHtml() instead.
Parameters
string $string
An HTML/XHTML/XML string
array $expected
An array, see above
boolean $fullDebug optional false
Whether or not more verbose output should be used.

assertTextContains() public ¶

assertTextContains( string $needle , string $haystack , string $message '' , boolean $ignoreCase false )

Assert that a string contains another string, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $needle
The string to search for.
string $haystack
The string to search through.
string $message optional ''
The message to display on failure.
boolean $ignoreCase optional false
Whether or not the search should be case-sensitive.

assertTextEndsNotWith() public ¶

assertTextEndsNotWith( string $suffix , string $string , string $message '' )

Asserts that a string ends not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $suffix
The suffix to not find.
string $string
The string to search.
string $message optional ''
The message to use for failure.

assertTextEndsWith() public ¶

assertTextEndsWith( string $suffix , string $string , string $message '' )

Asserts that a string ends with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $suffix
The suffix to find.
string $string
The string to search.
string $message optional ''
The message to use for failure.

assertTextEquals() public ¶

assertTextEquals( string $expected , string $result , string $message '' )

Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $expected
The expected value.
string $result
The actual value.
string $message optional ''
The message to use for failure.

assertTextNotContains() public ¶

assertTextNotContains( string $needle , string $haystack , string $message '' , boolean $ignoreCase false )

Assert that a text doesn't contain another text, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $needle
The string to search for.
string $haystack
The string to search through.
string $message optional ''
The message to display on failure.
boolean $ignoreCase optional false
Whether or not the search should be case-sensitive.

assertTextNotEquals() public ¶

assertTextNotEquals( string $expected , string $result , string $message '' )

Assert text equality, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $expected
The expected value.
string $result
The actual value.
string $message optional ''
The message to use for failure.

assertTextStartsNotWith() public ¶

assertTextStartsNotWith( string $prefix , string $string , string $message '' )

Asserts that a string starts not with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $prefix
The prefix to not find.
string $string
The string to search.
string $message optional ''
The message to use for failure.

assertTextStartsWith() public ¶

assertTextStartsWith( string $prefix , string $string , string $message '' )

Asserts that a string starts with a given prefix, ignoring differences in newlines. Helpful for doing cross platform tests of blocks of text.

Parameters
string $prefix
The prefix to check for.
string $string
The string to search in.
string $message optional ''
The message to use for failure.

assertWithinRange() protected static ¶

assertWithinRange( float $expected , float $result , float $margin , string $message '' )

Compatibility function to test if a value is between an acceptable range.

Parameters
float $expected
float $result
float $margin
the rage of acceptation
string $message optional ''
the text to display if the assertion is not correct

getMockForModel() public ¶

getMockForModel( string $alias , array $methods [] , array $options [] )

Mock a model, maintain fixtures and table association

Parameters
string $alias
The model to get a mock for.
array $methods optional []
The list of methods to mock
array $options optional []
The config data for the mock's constructor.
Returns
Cake\ORM\Table|PHPUnit_Framework_MockObject_MockObject
Throws
Cake\ORM\Exception\MissingTableClassException

loadFixtures() public ¶

loadFixtures( )

Chooses which fixtures to load for a given test

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.

Throws
Exception
when no fixture manager is available.
See
\Cake\TestSuite\TestCase::$autoFixtures

setAppNamespace() public static ¶

setAppNamespace( string $appNamespace 'TestApp' )

Set the app namespace

Parameters
string $appNamespace optional 'TestApp'
The app namespace, defaults to "TestApp".

setUp() public ¶

setUp( )

Setup the test case, backup the static object values so they can be restored. Specifically backs up the contents of Configure and paths in App if they have not already been backed up.

skipIf() public ¶

skipIf( boolean $shouldSkip , string $message '' )

Overrides SimpleTestCase::skipIf to provide a boolean return value

Parameters
boolean $shouldSkip
Whether or not the test should be skipped.
string $message optional ''
The message to display.
Returns
boolean

skipUnless() protected ¶

skipUnless( boolean $condition , string $message '' )

Compatibility function for skipping.

Parameters
boolean $condition
Condition to trigger skipping
string $message optional ''
Message for skip
Returns
boolean

Properties detail

$_err ¶

protected Cake\Console\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null

Console error output stub

$_exitCode ¶

protected integer|null

Last exit code

$_in ¶

protected Cake\Console\ConsoleInput|PHPUnit_Framework_MockObject_MockObject|null

Console input mock

$_out ¶

protected Cake\Console\ConsoleOutput|PHPUnit_Framework_MockObject_MockObject|null

Console output stub

$_useCommandRunner ¶

protected boolean

Whether or not to use the CommandRunner

false
Follow @CakePHP
#IRC
OpenHub
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Logos & Trademarks
  • Community
  • Team
  • Issues (Github)
  • YouTube Channel
  • Get Involved
  • Bakery
  • Featured Resources
  • Newsletter
  • Certification
  • My CakePHP
  • CakeFest
  • Facebook
  • Twitter
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs