Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Unit Test improvements] Use getMockBuilder rather than getMock directly #12990

Merged
merged 94 commits into from
Dec 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
4f99ff5
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
c4ca3b9
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
9771819
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
e6262cd
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
a3bb8de
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
56df791
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
e149f28
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
fd692ca
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
db25133
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
cd90aee
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
7e6c2cd
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
3e0fd3c
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
e3fee85
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
44b5de8
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
733bd85
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
adaa7f3
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
4612c4a
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
5c658b3
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
5e3c911
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
6e6dfd6
Use the correct $this object
photodude Nov 23, 2016
15fe448
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
1c0d909
Use getMockBuilder rather than getMock directly
photodude Nov 23, 2016
a1182eb
Set up a more mock JTableExtension with getMockBuilder
photodude Nov 24, 2016
5105098
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
93b40e4
Use the correct $this object
photodude Nov 24, 2016
9149b6b
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
b855cf4
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
a427b40
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
5f51380
remove the method after replacing
photodude Nov 24, 2016
b5d6a6d
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
02e9a69
More getMockBuilder in place of getMock
photodude Nov 24, 2016
2605e7d
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
683f6e8
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
2318eac
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
008c64e
Fix testParse mock Constructor Args
photodude Nov 24, 2016
85ef759
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
fa89e7f
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
95bea98
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
b37fbd6
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
18e7afe
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
30fa801
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
6f7db3c
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
608d12c
disableOriginalConstructor
photodude Nov 24, 2016
be5be8a
disableOriginalConstructor()
photodude Nov 24, 2016
2229d90
disableOriginalConstructor()
photodude Nov 24, 2016
41d4474
disableOriginalConstructor()
photodude Nov 24, 2016
26c3692
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
914832f
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
f3c6427
another spot for getMockBuilder
photodude Nov 24, 2016
5115137
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
7a2043a
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
c5d1741
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
4d8ff49
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
fc51c64
Use getMockBuilder rather than getMock directly
photodude Nov 24, 2016
569287c
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
add3066
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
383b537
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
07e57ac
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
1fac14b
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
b7d4476
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
88581f5
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
3593567
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
1a47a2c
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
f9c11a0
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
6a8a383
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
3ebf141
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
76eb291
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
644f75c
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
2014f7e
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
6af8d23
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
0287ad8
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
b92ad2d
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
4338317
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
790b1de
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
0faf6ff
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
c85de30
remove duplicate $this->transport
photodude Nov 25, 2016
2143251
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
ffe74c5
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
f109660
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
44926b4
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
9de5f6b
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
7e5cc80
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
3f1040b
Use getMockBuilder rather than getMock directly
photodude Nov 25, 2016
12e2619
Merge branch 'staging' into patch-14
photodude Nov 25, 2016
52b3848
Add 'setUserState' to MockApplicationCms
photodude Nov 25, 2016
18c1031
mockDatabase fails for mockTableExtension on hhvm
photodude Nov 26, 2016
55fffa2
Merge branch 'staging' into patch-14
photodude Nov 29, 2016
1f16272
Merge branch 'staging' into patch-14
photodude Dec 4, 2016
ead659e
Merge branch 'staging' into patch-14
photodude Dec 7, 2016
7b64d3e
Merge branch 'staging' into patch-14
photodude Dec 9, 2016
7b69531
Merge branch 'staging' into patch-14
photodude Dec 9, 2016
0e9fd59
cs-fix extra semicolon
photodude Dec 9, 2016
ad8af69
remove trailing coma
photodude Dec 9, 2016
144c6a9
remove trailing comma
photodude Dec 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions tests/unit/core/mock/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ public static function create($test)
'getLanguage'
);

// Create the mock.
$mockObject = $test->getMock(
'JApplication',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JApplication')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

$menu = TestMockMenu::create($test);
$mockObject->expects($test->any())
Expand Down
17 changes: 6 additions & 11 deletions tests/unit/core/mock/application/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,12 @@ public static function create($test, $options = array())
// Collect all the relevant methods in JApplicationBase.
$methods = self::getMethods();

// Create the mock.
$mockObject = $test->getMock(
'JApplicationBase',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
true
);
// Build the mock object & allow Call to original constructor
$mockObject = $test->getMockBuilder('JApplicationBase')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->getMock();

$mockObject = self::addBehaviours($test, $mockObject, $options);

Expand Down
17 changes: 6 additions & 11 deletions tests/unit/core/mock/application/cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,12 @@ public static function create($test, $options = array())
// Collect all the relevant methods in JApplicationCli.
$methods = self::getMethods();

// Create the mock.
$mockObject = $test->getMock(
'JApplicationCli',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
true
);
// Build the mock object & allow Call to original constructor.
$mockObject = $test->getMockBuilder('JApplicationCli')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->getMock();

$mockObject = self::addBehaviours($test, $mockObject, $options);

Expand Down
22 changes: 10 additions & 12 deletions tests/unit/core/mock/application/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static function getMethods()
'isAdmin',
'isSite',
'getUserState',
'getUserStateFromRequest'
'getUserStateFromRequest',
'setUserState',
);

return array_merge($methods, parent::getMethods());
Expand Down Expand Up @@ -88,17 +89,14 @@ public static function create($test, $options = array(), $constructor = array())
$methods = self::getMethods();

if (isset($options))
// Create the mock.
$mockObject = $test->getMock(
'JApplicationCms',
$methods,
// Constructor arguments.
$constructor,
// Mock class name.
'',
// Call original constructor.
true
);
{
// Build the mock object & allow call to original constructor.
$mockObject = $test->getMockBuilder('JApplicationCms')
->setMethods($methods)
->setConstructorArgs($constructor)
->setMockClassName('')
->getMock();
}

$mockObject = self::addBehaviours($test, $mockObject, $options);

Expand Down
17 changes: 6 additions & 11 deletions tests/unit/core/mock/application/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,12 @@ public static function create($test, $options = array())
// Collect all the relevant methods in JApplicationWeb (work in progress).
$methods = self::getMethods();

// Create the mock.
$mockObject = $test->getMock(
'JApplicationWeb',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
true
);
// Build the mock object & allow call to original constructor.
$mockObject = $test->getMockBuilder('JApplicationWeb')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->getMock();

$mockObject = self::addBehaviours($test, $mockObject, $options);

Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ public static function create(TestCase $test, $data = array())
'store',
);

// Create the mock.
$mockObject = $test->getMock(
'JCache',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JCache')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

$test->assignMockCallbacks(
$mockObject,
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ public static function create($test)
'set'
);

// Create the mock.
$mockObject = $test->getMock(
'JConfig',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JConfig')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

return $mockObject;
}
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,13 @@ public static function create($test)
'unserialize',
);

// Create the mock.
$mockObject = $test->getMock(
'JControllerBase',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JControllerBase')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

// TODO Mock the input.
TestReflection::setValue($mockObject, 'input', new JInput);
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/database/driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,13 @@ public static function create($test, $driver = '', array $extraMethods = array()
'updateObject',
));

// Create the mock.
$mockObject = $test->getMock(
'JDatabaseDriver' . $driver,
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JDatabaseDriver' . $driver)
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

// Mock selected methods.
$test->assignMockReturns(
Expand Down
19 changes: 7 additions & 12 deletions tests/unit/core/mock/dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,13 @@ public static function create($test, $defaults = true)
'test',
);

// Create the mock.
$mockObject = $test->getMock(
'JEventDispatcher',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);

// Build the mock object.
$mockObject = $test->getMockBuilder('JEventDispatcher')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();
// Mock selected methods.
$test->assignMockReturns(
$mockObject, array(
Expand Down
16 changes: 6 additions & 10 deletions tests/unit/core/mock/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,12 @@ public static function create($test)
);

// Create the mock.
$mockObject = $test->getMock(
'JDocument',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
$mockObject = $test->getMockBuilder('JDocument')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

// Mock selected methods.
$test->assignMockReturns(
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/input.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,13 @@ public function createInput(array $options = null)
$methods = array_merge($methods, $options['methods']);
}

// Create the mock.
$mockObject = self::$test->getMock(
'JInput',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = self::$test->getMockBuilder('JInput')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

self::$test->assignMockCallbacks(
$mockObject,
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,13 @@ public static function create($test)
'test',
);

// Create the mock.
$mockObject = $test->getMock(
'JLanguage',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JLanguage')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

// Mock selected methods.
$test->assignMockReturns(
Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,13 @@ public static function create(PHPUnit_Framework_TestCase $test, $setDefault = tr
'load'
);

// Create the mock.
$mockObject = $test->getMock(
'JMenu',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JMenu')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

self::createMenuSampleData();

Expand Down
18 changes: 7 additions & 11 deletions tests/unit/core/mock/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,13 @@ public static function create($test)
'allow',
);

// Create the mock.
$mockObject = $test->getMock(
'JAccessRules',
$methods,
// Constructor arguments.
array(),
// Mock class name.
'',
// Call original constructor.
false
);
// Build the mock object.
$mockObject = $test->getMockBuilder('JAccessRules')
->setMethods($methods)
->setConstructorArgs(array())
->setMockClassName('')
->disableOriginalConstructor()
->getMock();

$test->assignMockCallbacks(
$mockObject,
Expand Down
Loading