3 years ago

Need to get attribute without going through accessor

Posted 3 years ago by edgreenberg

I'm writing unit tests for my mutators and accessors in a particular model.

I set the value in the mutator with:

    public function setParkingTypeAttribute($value)
        $this->attributes['parking_type'] = $this->parkingTypeTranslations[$value];

Then I want to see what is in the attribute (from the test).

$model->getParkingTypeAttribute() returns the translated attribute

$model->$attributeName also returns the translated attribute

I really don't want to just trust the accessor when testing the mutator.

How can I get the actual attribute wihtout persisting the entry and examining the database?

Please sign in or create an account to participate in this conversation.