CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.3 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 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

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
      • Constraint
      • Fixture
      • Stub
    • Utility
    • Validation
    • View

Class TestSuite

A class to contain test cases and run them with shared fixtures

Namespace: Cake\TestSuite

Property Summary

  • $backupGlobals protected
    bool

    Enable or disable the backup and restoration of the $GLOBALS array.

  • $backupStaticAttributes protected
    bool

    Enable or disable the backup and restoration of static attributes.

  • $foundClasses protected
    array
  • $groups protected
    array

    The test groups of the test suite.

  • $name protected
    string

    The name of the test suite.

  • $numTests protected
    int

    The number of tests in the test suite.

  • $runTestInSeparateProcess protected
    bool
  • $testCase protected
    bool
  • $tests protected
    array

    The tests in the test suite.

Method Summary

  • __construct() public

    Constructs a new TestSuite:

  • addTest() public

    Adds a test to the suite.

  • addTestDirectory() public

    Adds all the files in a directory to the test suite. Does not recursive through directories.

  • addTestDirectoryRecursive() public

    Recursively adds all the files in a directory to the test suite.

  • addTestFile() public

    Wraps both addTest() and addTestSuite as well as the separate import statements for the user's convenience.

  • addTestFiles() public

    Wrapper for addTestFile() that adds multiple test files.

  • addTestMethod() protected
  • addTestSuite() public

    Adds the tests from the given class to the suite.

  • count() public

    Counts the number of test cases that will be run by this test.

  • createResult() protected

    Creates a default TestResult object.

  • createTest() public static
  • getGroupDetails() public
  • getGroups() public

    Returns the test groups of the suite.

  • getIterator() public

    Returns an iterator for this test suite.

  • getName() public

    Returns the name of the suite.

  • incompleteTest() protected static
  • injectFilter() public
  • isTestMethod() public static
  • markTestSuiteSkipped() public

    Mark the test suite as skipped.

  • run() public

    Runs the tests and collects their result in a TestResult.

  • runTest() public deprecated

    Runs a test.

  • setBackupGlobals() public
  • setBackupStaticAttributes() public
  • setBeStrictAboutChangesToGlobalState() public
  • setGroupDetails() public

    Set tests groups of the test case

  • setName() public

    Sets the name of the suite.

  • setRunTestInSeparateProcess() public
  • setTests() public

    Set tests of the test suite

  • setUp() protected

    Template Method that is called before the tests of this test suite are run.

  • skipTest() protected static
  • tearDown() protected

    Template Method that is called after the tests of this test suite have finished running.

  • testAt() public

    Returns the test at the given index.

  • tests() public

    Returns the tests as an enumeration.

  • toString() public

    Returns a string representation of the test suite.

  • warning() protected static

Method Detail

__construct() ¶ public

__construct(mixed $theClass = '', string $name = '')

Constructs a new TestSuite:

  • PHPUnit_Framework_TestSuite() constructs an empty TestSuite.

  • PHPUnit_Framework_TestSuite(ReflectionClass) constructs a TestSuite from the given class.

  • PHPUnit_Framework_TestSuite(ReflectionClass, String) constructs a TestSuite from the given class with the given name.

  • PHPUnit_Framework_TestSuite(String) either constructs a TestSuite from the given class (if the passed string is the name of an existing class) or constructs an empty TestSuite with the given name.

Parameters
mixed $theClass optional
string $name optional
Throws
PHPUnit_Framework_Exception

addTest() ¶ public

addTest(PHPUnit_Framework_Test $test, array $groups = [])

Adds a test to the suite.

Parameters
PHPUnit_Framework_Test $test
array $groups optional

addTestDirectory() ¶ public

addTestDirectory(string $directory = '.'): void

Adds all the files in a directory to the test suite. Does not recursive through directories.

Parameters
string $directory optional

The directory to add tests from.

Returns
void

addTestDirectoryRecursive() ¶ public

addTestDirectoryRecursive(string $directory = '.'): void

Recursively adds all the files in a directory to the test suite.

Parameters
string $directory optional

The directory subtree to add tests from.

Returns
void

addTestFile() ¶ public

addTestFile(string $filename)

Wraps both addTest() and addTestSuite as well as the separate import statements for the user's convenience.

If the named file cannot be read or there are no new tests that can be added, a PHPUnit_Framework_WarningTestCase will be created instead, leaving the current test run untouched.

Parameters
string $filename
Throws
PHPUnit_Framework_Exception

addTestFiles() ¶ public

addTestFiles(array|Iterator $filenames)

Wrapper for addTestFile() that adds multiple test files.

Parameters
array|Iterator $filenames
Throws
PHPUnit_Framework_Exception

addTestMethod() ¶ protected

addTestMethod(ReflectionClass $class, ReflectionMethod $method)
Parameters
ReflectionClass $class
ReflectionMethod $method

addTestSuite() ¶ public

addTestSuite(mixed $testClass)

Adds the tests from the given class to the suite.

Parameters
mixed $testClass
Throws
PHPUnit_Framework_Exception

count() ¶ public

count(bool $preferCache = false): int

Counts the number of test cases that will be run by this test.

Parameters
bool $preferCache optional

Indicates if cache is preferred.

Returns
int

createResult() ¶ protected

createResult(): PHPUnit_Framework_TestResult

Creates a default TestResult object.

Returns
PHPUnit_Framework_TestResult

createTest() ¶ public static

createTest(ReflectionClass $theClass, string $name): PHPUnit_Framework_Test
Parameters
ReflectionClass $theClass
string $name
Returns
PHPUnit_Framework_Test
Throws
PHPUnit_Framework_Exception

getGroupDetails() ¶ public

getGroupDetails()

getGroups() ¶ public

getGroups(): array

Returns the test groups of the suite.

Returns
array

getIterator() ¶ public

getIterator(): RecursiveIteratorIterator

Returns an iterator for this test suite.

Returns
RecursiveIteratorIterator

getName() ¶ public

getName(): string

Returns the name of the suite.

Returns
string

incompleteTest() ¶ protected static

incompleteTest(string $class, string $methodName, string $message): PHPUnit_Framework_IncompleteTestCase
Parameters
string $class
string $methodName
string $message
Returns
PHPUnit_Framework_IncompleteTestCase

injectFilter() ¶ public

injectFilter(PHPUnit_Runner_Filter_Factory $filter)
Parameters
PHPUnit_Runner_Filter_Factory $filter

isTestMethod() ¶ public static

isTestMethod(ReflectionMethod $method): bool
Parameters
ReflectionMethod $method
Returns
bool

markTestSuiteSkipped() ¶ public

markTestSuiteSkipped(string $message = '')

Mark the test suite as skipped.

Parameters
string $message optional
Throws
PHPUnit_Framework_SkippedTestSuiteError

run() ¶ public

run(PHPUnit_Framework_TestResult $result = null): PHPUnit_Framework_TestResult

Runs the tests and collects their result in a TestResult.

Parameters
PHPUnit_Framework_TestResult $result optional
Returns
PHPUnit_Framework_TestResult

runTest() ¶ public

runTest(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result)

Runs a test.

Parameters
PHPUnit_Framework_Test $test
PHPUnit_Framework_TestResult $result

setBackupGlobals() ¶ public

setBackupGlobals(bool $backupGlobals)
Parameters
bool $backupGlobals

setBackupStaticAttributes() ¶ public

setBackupStaticAttributes(bool $backupStaticAttributes)
Parameters
bool $backupStaticAttributes

setBeStrictAboutChangesToGlobalState() ¶ public

setBeStrictAboutChangesToGlobalState(bool $beStrictAboutChangesToGlobalState)
Parameters
bool $beStrictAboutChangesToGlobalState

setGroupDetails() ¶ public

setGroupDetails(array $groups)

Set tests groups of the test case

Parameters
array $groups

setName() ¶ public

setName(mixed $name)

Sets the name of the suite.

Parameters
$name

setRunTestInSeparateProcess() ¶ public

setRunTestInSeparateProcess(bool $runTestInSeparateProcess)
Parameters
bool $runTestInSeparateProcess
Throws
PHPUnit_Framework_Exception

setTests() ¶ public

setTests(array $tests)

Set tests of the test suite

Parameters
array $tests

setUp() ¶ protected

setUp()

Template Method that is called before the tests of this test suite are run.

skipTest() ¶ protected static

skipTest(string $class, string $methodName, string $message): PHPUnit_Framework_SkippedTestCase
Parameters
string $class
string $methodName
string $message
Returns
PHPUnit_Framework_SkippedTestCase

tearDown() ¶ protected

tearDown()

Template Method that is called after the tests of this test suite have finished running.

testAt() ¶ public

testAt(mixed $index): PHPUnit_Framework_Test

Returns the test at the given index.

Parameters
$index
Returns
PHPUnit_Framework_Test

tests() ¶ public

tests(): array

Returns the tests as an enumeration.

Returns
array

toString() ¶ public

toString(): string

Returns a string representation of the test suite.

Returns
string

warning() ¶ protected static

warning(string $message): PHPUnit_Framework_WarningTestCase
Parameters
string $message
Returns
PHPUnit_Framework_WarningTestCase

Property Detail

$backupGlobals ¶ protected

Enable or disable the backup and restoration of the $GLOBALS array.

Type
bool

$backupStaticAttributes ¶ protected

Enable or disable the backup and restoration of static attributes.

Type
bool

$foundClasses ¶ protected

Type
array

$groups ¶ protected

The test groups of the test suite.

Type
array

$name ¶ protected

The name of the test suite.

Type
string

$numTests ¶ protected

The number of tests in the test suite.

Type
int

$runTestInSeparateProcess ¶ protected

Type
bool

$testCase ¶ protected

Type
bool

$tests ¶ protected

The tests in the test suite.

Type
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs