Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Getting Started with PHP Unit Testing Testing Existing Projects Setup Fixure

Cristina Rosales
Cristina Rosales
10,929 Points

I don't recall there being any explanation on how to set associative array keys and values to a test situation like this

I can't figure this out at all. Will someone please offer a clue?

index.php
<?php
use PHPUnit\Framework\TestCase;

class ArtworkTest extends TestCase
{
    // add your code here
    protected $artwork;
    protected function setUp():void
    {
        $data = [
   'title' => 'mona lisa',
   'artist' => 'leonardo da vinci',
   'century' => '15th century',
   'movement' => 'renaissance',
   'location' => 'the louvre (paris, france)',
   'type' => 'painting',
   'medium' => 'oil on canvas'
 ]; 
      $this->artwork->$data->title;
      $this->artwork->$data->artist;
    }

    /** @test */
    function hasTitle()
    {
        $this->assertEquals(
            "Mona Lisa",
            $this->artwork->getTitle()
        );
    }

    /** @test */
    function isAtTheLouvre()
    {
        $this->assertStringContainsStringIgnoringCase(
            'Louvre', 
            $this->artwork->getLocation()
        );
    }

    //more tests
}