container = $this->getContainer(); $this->generalSettings = $this->container->get( 'settings.data.general' ); } public function test_should_persist_path_only_once() { $this->generalSettings->set_installation_path( '' ); $detector = Mockery::mock( ActivationDetector::class ); $repository = new PathRepository( $detector, $this->generalSettings ); $detector->shouldReceive( 'detect_activation_path' ) ->once() ->andReturn( 'foo' ); $detector->shouldReceive( 'detect_activation_path' ) ->once() ->andReturn( 'bar' ); $repository->persist(); $repository->persist(); $this->assertEquals( 'foo', $this->generalSettings->get_installation_path() ); } }