Skip to content

Commit

Permalink
Use getMockBuilder() instead of getMock()
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoirotte committed Sep 17, 2016
1 parent 51844c9 commit 9258325
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 55 deletions.
54 changes: 13 additions & 41 deletions tests/src/eventMatchingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,47 +32,19 @@ public function dummyCallback(
public function setUp()
{
$sxml = new SimpleXMLElement('<foo/>');
$this->_mainConfig = $this->getMock(
'\\Erebot\\Interfaces\\Config\\Main',
array(), array(), '',
FALSE, FALSE, FALSE
);
$networkConfig = $this->getMock(
'\\Erebot\\Interfaces\\Config\\Network',
array(),
array($this->_mainConfig, $sxml),
'',
FALSE,
FALSE,
FALSE
);
$serverConfig = $this->getMock(
'\\Erebot\\Interfaces\\Config\\Server',
array(),
array($networkConfig, $sxml),
'',
FALSE,
FALSE,
FALSE
);
$bot = $this->getMock(
'\\Erebot\\Interfaces\\Core',
array(),
array($this->_mainConfig),
'',
FALSE,
FALSE,
FALSE
);
$this->_connection = $this->getMock(
'\\Erebot\\Interfaces\\Connection',
array(),
array($bot, $serverConfig),
'',
FALSE,
FALSE,
FALSE
);
$this->_mainConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Main')->getMock();
$networkConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Network')
->setConstructorArgs(array($this->_mainConfig, $sxml))
->getMock();
$serverConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Server')
->setConstructorArgs(array($networkConfig, $sxml))
->getMock();
$bot = $this->getMockBuilder('\\Erebot\\Interfaces\\Core')
->setConstructorArgs(array($this->_mainConfig))
->getMock();
$this->_connection = $this->getMockBuilder('\\Erebot\\Interfaces\\Connection')
->setConstructorArgs(array($bot, $serverConfig))
->getMock();
$this->_cb = \Erebot\CallableWrapper::wrap(array($this, 'dummyCallback'));
}

Expand Down
18 changes: 13 additions & 5 deletions tests/src/eventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,19 @@ class EventsTest
public function setUp()
{
$sxml = new SimpleXMLElement('<foo/>');
$this->_mainConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Main', array(), array(), '', FALSE, FALSE, FALSE);
$this->_networkConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Network', array(), array($this->_mainConfig, $sxml), '', FALSE, FALSE, FALSE);
$this->_serverConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Server', array(), array($this->_networkConfig, $sxml), '', FALSE, FALSE, FALSE);
$this->_bot = $this->getMock('\\Erebot\\Interfaces\\Core', array(), array($this->_mainConfig), '', FALSE, FALSE, FALSE);
$this->_connection = $this->getMock('\\Erebot\\Interfaces\\Connection', array(), array($this->_bot, $this->_serverConfig), '', FALSE, FALSE, FALSE);
$this->_mainConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Main')->getMock();
$this->_networkConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Network')
->setConstructorArgs(array($this->_mainConfig, $sxml))
->getMock();
$this->_serverConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Server')
->setConstructorArgs(array($this->_networkConfig, $sxml))
->getMock();
$this->_bot = $this->getMockBuilder('\\Erebot\\Interfaces\\Core')
->setConstructorArgs(array($this->_mainConfig))
->getMock();
$this->_connection = $this->getMockBuilder('\\Erebot\\Interfaces\\IrcConnection')
->setConstructorArgs(array($this->_bot, $this->_serverConfig))
->getMock();
}

public function tearDown()
Expand Down
6 changes: 4 additions & 2 deletions tests/src/identdTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ abstract class AbstractIdentdTest
public function setUp()
{
parent::setUp();
$this->_mainConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Main', array(), array(), '', FALSE, FALSE);
$this->_bot = $this->getMock('\\Erebot\\Interfaces\\Core', array(), array($this->_mainConfig), '', FALSE, FALSE);
$this->_mainConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Main')->getMock();
$this->_bot = $this->getMockBuilder('\\Erebot\\Interfaces\\Core')
->setConstructorArgs(array($this->_mainConfig))
->getMock();

// Create two connected stream-oriented TCP sockets.
// We can't use stream_socket_pair() as it doesn't exist on Windows
Expand Down
25 changes: 18 additions & 7 deletions tests/src/ircParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,24 @@ class IrcParserTest
public function setUp()
{
$sxml = new SimpleXMLElement('<foo/>');
$this->_mainConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Main', array(), array(), '', FALSE, FALSE);
$this->_networkConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Network', array(), array($this->_mainConfig, $sxml), '', FALSE, FALSE);
$this->_serverConfig = $this->getMock('\\Erebot\\Interfaces\\Config\\Server', array(), array($this->_networkConfig, $sxml), '', FALSE, FALSE);
$this->_bot = $this->getMock('\\Erebot\\Interfaces\\Core', array(), array($this->_mainConfig), '', FALSE, FALSE);
$this->_connection = $this->getMock('\\Erebot\\Interfaces\\IrcConnection', array(), array($this->_bot, $this->_serverConfig), '', FALSE, FALSE);
$this->_event = $this->getMock('\\Erebot\\Interfaces\\Event\\Base\\Generic', array(), array(), '', FALSE, FALSE);
$this->_parser = $this->getMock('\\Erebot\\IrcParser', array('makeEvent'), array($this->_connection));
$this->_mainConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Main')->getMock();
$this->_networkConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Network')
->setConstructorArgs(array($this->_mainConfig, $sxml))
->getMock();
$this->_serverConfig = $this->getMockBuilder('\\Erebot\\Interfaces\\Config\\Server')
->setConstructorArgs(array($this->_networkConfig, $sxml))
->getMock();
$this->_bot = $this->getMockBuilder('\\Erebot\\Interfaces\\Core')
->setConstructorArgs(array($this->_mainConfig))
->getMock();
$this->_connection = $this->getMockBuilder('\\Erebot\\Interfaces\\IrcConnection')
->setConstructorArgs(array($this->_bot, $this->_serverConfig))
->getMock();
$this->_event = $this->getMockBuilder('\\Erebot\\Interfaces\\Event\\Base\\Generic')->getMock();
$this->_parser = $this->getMockBuilder('\\Erebot\\IrcParser')
->setMethods(array('makeEvent'))
->setConstructorArgs(array($this->_connection))
->getMock();
}

/**
Expand Down

0 comments on commit 9258325

Please sign in to comment.