Installing PHPUnit with Composer
- 53Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
53 questions
- 1The package manager command used to add PHPUnit to a PHP project is_____.
Hint
Recall the command that adds a package and updates the project dependencies.
Answer
composer require phpunit/phpunit
- 2When Composer asks whether PHPUnit should be installed as a development dependency, the appropriate response is_____.
Hint
Consider whether a testing tool is needed on the production server.
Answer
yes
- 3Installing PHPUnit as a development dependency keeps it out of the project's_____dependencies.
Hint
These are the dependencies needed on the live server.
Answer
production
- 4The PHPUnit version installed in the example is_____.
Hint
It is the latest version identified in the example.
Answer
10.2.3
- 5The PHPUnit configuration file used as the starting point is_____.
Hint
It is the distribution version of the XML configuration file.
Answer
phpunit.xml.dist
- 6The configuration's bootstrap setting directly loads_____so Composer's autoloader can include project classes.
Hint
This file is generated by Composer and is also loaded by the project's entry point.
Answer
vendor/autoload.php
- 7The PHPUnit configuration option that makes test results appear in color is_____.
Hint
It controls whether test output is displayed in red and green.
Answer
colors
- 8The configuration section that groups tests to be run is called a_____.
Hint
It names and organizes a collection of tests.
Answer
test suite
- 9In the example configuration, the unit test suite looks for tests in the_____directory.
Hint
The directory name is plural in the example.
Answer
tests
- 10The source configuration includes PHP files with the_____extension from the source directory.
Hint
This is the standard extension for PHP source files.
Answer
.php
- 11The test directory convention used in the project is the plural directory named_____.
Hint
It is the directory name specified for the unit test suite.
Answer
tests
- 12A test class for the User entity is named_____to follow the PHPUnit naming convention.
Hint
The class name uses the entity name followed by the test suffix.
Answer
UserTest
- 13A PHPUnit test class should end with the suffix_____so it is identified as a test class.
Hint
It is appended to the name of the class being tested.
Answer
Test
- 14The example places the User entity test in the_____namespace beneath the project's test namespace.
Hint
It corresponds to the kind of project class being tested.
Answer
Entity
- 15To use the project class in a test, the test imports the_____class.
Hint
It is the entity whose getters and unserialization behavior are tested.
Answer
User
- 16The test class extends PHPUnit's_____base class to use its testing features and assertions.
Hint
This base class provides methods such as
assertSame.Answer
TestCase
- 17The project marks its test class as_____to prevent other classes from extending it.
Hint
This PHP keyword prohibits class inheritance.
Answer
final
- 18The declaration that makes PHP enforce declared types strictly is_____.
Hint
It is placed at the beginning of a PHP file and enables strict type behavior.
Answer
declare(strict_types=1)
- 19Under strict typing, a value of the wrong declared type causes a_____rather than being automatically cast.
Hint
Strict typing rejects the type instead of converting it.
Answer
fatal error
- 20A PHPUnit test method in the example is declared with the visibility_____.
Hint
PHPUnit must be able to discover and run the test method.
Answer
public
- 21The setup hook in a PHPUnit test class is named_____.
Hint
It runs before a test to prepare its initial state.
Answer
setUp
- 22The setup hook should call the_____implementation before performing its own initialization.
Hint
It is the setup method inherited from PHPUnit's base test class.
Answer
parent setup
- 23A test method that does not return a value is given the return type_____.
Hint
This type indicates that a function returns no value.
Answer
void
- 24The entity instance reused by the tests is created in the_____method.
Hint
This lifecycle method prepares the state before each test.
Answer
setUp
- 25The example stores the shared User entity in a_____property of the test class.
Hint
This visibility limits access to the property to the class itself.
Answer
private
- 26The assertion used to compare expected and actual values with strict type checking is_____.
Hint
It checks equality using the equivalent of PHP's three-equals operator.
Answer
assertSame
- 27PHP's strict comparison operator corresponds to_____.
Hint
It uses three equals signs rather than two.
Answer
===
- 28The first getter behavior tested on the User entity is retrieval of the_____.
Hint
The example assigns it the value 55 before checking its getter.
Answer
sequential ID
- 29The expected sequential ID in the example's first getter test is_____.
Hint
It is the numeric value assigned before the strict assertion.
Answer
55
- 30The UUID test generates a value using the Ramsey UUID_____method.
Hint
This method generates a version 4 UUID.
Answer
uuid4
- 31Because the Ramsey UUID generator returns an object, the test calls_____to obtain a string.
Hint
This method converts the UUID object into its textual representation.
Answer
toString
- 32The UUID getter test checks that the entity returns the same_____that was assigned to it.
Hint
It is the unique identifier generated by the Ramsey library.
Answer
UUID
- 33The User entity's unserialization test supplies its expected field values in an_____.
Hint
This PHP data structure maps field names to values.
Answer
array
- 34The unserialization test checks that the input ID is available through the_____getter.
Hint
This getter retrieves the entity's numeric identifier.
Answer
getSequentialId
- 35The first-name field in the example's expected user data is_____.
Hint
It is the sample value used to check the first-name getter.
Answer
Pierre
- 36The last-name field in the example's expected user data is_____.
Hint
It is the sample value checked using the last-name getter.
Answer
Surya
- 37The unserialization test checks the email field using the entity's_____getter.
Hint
This getter returns the user's email value.
Answer
getEmail
- 38The unserialization test checks the phone field using the entity's_____getter.
Hint
This getter returns the user's phone value.
Answer
getPhone
- 39The unserialization test checks the password field using the entity's_____getter.
Hint
This getter returns the user's password value.
Answer
getPassword
- 40The test checks the stored creation date using the entity's_____getter.
Hint
This getter returns the date the user entity was created.
Answer
getCreationDate
- 41The example uses a real database row's creation date to ensure the test uses the expected_____.
Hint
The concern is the date's representation, not only its value.
Answer
format
- 42If PHPUnit is installed globally, tests can be run by invoking_____in the terminal.
Hint
This is the executable available on the system path after a global installation.
Answer
phpunit
- 43If PHPUnit is installed only in the project, its executable is run from_____.
Hint
Composer places project-local executable binaries in this directory.
Answer
vendor/bin/phpunit
- 44The command-line option used to run a specific test by class and method is_____.
Hint
It narrows the test run to a matching name.
Answer
--filter
- 45To target one method with a filter, the class and method are separated by_____.
Hint
This is PHP's scope resolution operator.
Answer
::
- 46If a test's expected value differs from the entity's actual value, the assertion_____.
Hint
The test reports that the compared values do not match.
Answer
fails
- 47PHPUnit first uses a project configuration named_____when it exists.
Hint
This is the customized configuration file, rather than the distribution file.
Answer
phpunit.xml
- 48If the customized configuration is absent, PHPUnit falls back to_____.
Hint
It is the distributed default configuration file.
Answer
phpunit.xml.dist
- 49The custom PHPUnit configuration and generated test cache are typically excluded from version control using_____.
Hint
This file lists files and directories Git should ignore.
Answer
.gitignore
- 50The automatically generated PHPUnit cache is stored in the_____directory.
Hint
Its name begins with a dot and identifies PHPUnit's cache.
Answer
.phpunit.cache
- 51Composer package files can be excluded from exported archives by adding_____to
.gitattributes.Hint
This attribute tells Git to omit matching paths from an exported archive.
Answer
export-ignore
- 52The test directory is a candidate for exclusion from a distributed package archive because it is unnecessary for the_____product.
Hint
It refers to the product delivered to package users.
Answer
shipped
- 53The session token and last session time columns are not tested yet because they have not been_____in the User entity.
Hint
The entity does not currently retrieve or support these fields.
Answer
implemented

Ask anything
We've read this whole study set, so questions about it get the best answers.