0
0
Laravelframework~10 mins

PHPUnit setup in Laravel - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to run PHPUnit tests in Laravel using the artisan command.

Laravel
php artisan [1]
Drag options to blanks, or click blank then click option'
Atest
Bserve
Cmigrate
Dmake:test
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' instead of 'test' to run tests.
Using 'migrate' which runs database migrations.
Using 'make:test' which creates a new test file.
2fill in blank
medium

Complete the code to specify the test directory when running PHPUnit directly.

Laravel
vendor/bin/phpunit [1]
Drag options to blanks, or click blank then click option'
Aapp/Http
B--filter
C--coverage
Dtests/Feature
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--filter' without a test name.
Using '--coverage' which is for code coverage reports.
Using 'app/Http' which is not a test folder.
3fill in blank
hard

Fix the error in the PHPUnit configuration file by completing the missing XML tag.

Laravel
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php" colors="true">
  <testsuites>
    <testsuite name="Feature">
      <directory>[1]</directory>
    </testsuite>
  </testsuites>
</phpunit>
Drag options to blanks, or click blank then click option'
Aresources/views
Bapp/Models
Ctests/Feature
Ddatabase/migrations
Attempts:
3 left
💡 Hint
Common Mistakes
Pointing to application folders instead of test folders.
Using 'app/Models' or 'resources/views' which are not test directories.
4fill in blank
hard

Fill both blanks to create a basic test method in a Laravel test class.

Laravel
public function [1]()
{
    $response = $this->get('/');
    $response->assertStatus([2]);
}
Drag options to blanks, or click blank then click option'
AtestHomePage
B200
C404
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method name without 'test' prefix.
Asserting status 404 which means not found.
5fill in blank
hard

Fill all three blanks to write a test that checks if the home page contains a welcome message.

Laravel
public function [1]()
{
    $response = $this->get('/');
    $response->assertStatus([2]);
    $response->assertSee('[3]');
}
Drag options to blanks, or click blank then click option'
AtestWelcomeMessage
B200
CWelcome to Laravel
DtestHome
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong method names.
Checking for wrong status codes.
Looking for incorrect text in the page.