I have unit tests running for my component (using a bootstrap file to get the usual requirements) but as soon as I add any logging, I get:

Class '\Joomla\CMS\Log\Log' not found`

I have tried mocking out the Log class, but I don't know how to assign my mock to the global JLog namespace. My tests were passing before I added logging to the methods, so I know that the bootstrap is good in principle, it just seems to be the log that is throwing it.

My setup looks like this:

public function setUp():void {
    $this->channel_store = $this->createMock('ChannelStore');
    $this->application = $this->getMockBuilder(JApplication::class)
                              ->setMethods(['get', 'set'])
    JFactory::$application = $this->application;

    $this->log = $this->getMockBuilder(JLog::class)

    //  JLog = $this->log; ???

What do I need to do in order to mock out JLog correctly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.