user->budgets()->first(); $journal->budgets()->detach(); $this->assertEquals(0, $journal->budgets()->count()); // fire the action: $ruleAction = new RuleAction; $ruleAction->action_value = $budget->name; $action = new SetBudget($ruleAction); $result = $action->act($journal); $this->assertTrue($result); $this->assertEquals(1, $journal->budgets()->count()); $this->assertEquals($budget->name, $journal->budgets()->first()->name); } }