| 148 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Mockery
|
|
|
4 |
*
|
|
|
5 |
* LICENSE
|
|
|
6 |
*
|
|
|
7 |
* This source file is subject to the new BSD license that is bundled
|
|
|
8 |
* with this package in the file LICENSE.txt.
|
|
|
9 |
* It is also available through the world-wide-web at this URL:
|
|
|
10 |
* http://github.com/padraic/mockery/blob/master/LICENSE
|
|
|
11 |
* If you did not receive a copy of the license and are unable to
|
|
|
12 |
* obtain it through the world-wide-web, please send an email
|
|
|
13 |
* to padraic@php.net so we can send you a copy immediately.
|
|
|
14 |
*
|
|
|
15 |
* @category Mockery
|
|
|
16 |
* @package Mockery
|
|
|
17 |
* @copyright Copyright (c) 2010 Pádraic Brady (http://blog.astrumfutura.com)
|
|
|
18 |
* @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License
|
|
|
19 |
*/
|
|
|
20 |
|
|
|
21 |
namespace Mockery;
|
|
|
22 |
|
|
|
23 |
class QuickDefinitionsConfiguration
|
|
|
24 |
{
|
|
|
25 |
private const QUICK_DEFINITIONS_MODE_MOCK_AT_LEAST_ONCE = 'QUICK_DEFINITIONS_MODE_MOCK_AT_LEAST_ONCE';
|
|
|
26 |
private const QUICK_DEFINITIONS_MODE_DEFAULT_EXPECTATION = 'QUICK_DEFINITIONS_MODE_DEFAULT_EXPECTATION';
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Defines what a quick definition should produce.
|
|
|
30 |
* Possible options are:
|
|
|
31 |
* - self::QUICK_DEFINITIONS_MODE_DEFAULT_EXPECTATION: in this case quick
|
|
|
32 |
* definitions define a stub.
|
|
|
33 |
* - self::QUICK_DEFINITIONS_MODE_MOCK_AT_LEAST_ONCE: in this case quick
|
|
|
34 |
* definitions define a mock with an 'at least once' expectation.
|
|
|
35 |
*
|
|
|
36 |
* @var string
|
|
|
37 |
*/
|
|
|
38 |
protected $_quickDefinitionsApplicationMode = self::QUICK_DEFINITIONS_MODE_DEFAULT_EXPECTATION;
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* Returns true if quick definitions should setup a stub, returns false when
|
|
|
42 |
* quick definitions should setup a mock with 'at least once' expectation.
|
|
|
43 |
* When parameter $newValue is specified it sets the configuration with the
|
|
|
44 |
* given value.
|
|
|
45 |
*/
|
|
|
46 |
public function shouldBeCalledAtLeastOnce(?bool $newValue = null): bool
|
|
|
47 |
{
|
|
|
48 |
if ($newValue !== null) {
|
|
|
49 |
$this->_quickDefinitionsApplicationMode = $newValue
|
|
|
50 |
? self::QUICK_DEFINITIONS_MODE_MOCK_AT_LEAST_ONCE
|
|
|
51 |
: self::QUICK_DEFINITIONS_MODE_DEFAULT_EXPECTATION;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
return $this->_quickDefinitionsApplicationMode === self::QUICK_DEFINITIONS_MODE_MOCK_AT_LEAST_ONCE;
|
|
|
55 |
}
|
|
|
56 |
}
|