aimeos /
aimeos-flow
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | namespace Aimeos\Shop\Tests\Unit\Base; |
||
| 5 | |||
| 6 | |||
| 7 | class ContextTest extends \Neos\Flow\Tests\UnitTestCase |
||
|
0 ignored issues
–
show
|
|||
| 8 | { |
||
| 9 | private $object; |
||
| 10 | |||
| 11 | |||
| 12 | public function setUp() |
||
| 13 | { |
||
| 14 | \Aimeos\MShop::cache( false ); |
||
| 15 | |||
| 16 | $this->object = new \Aimeos\Shop\Base\Context(); |
||
| 17 | |||
| 18 | $aimeos = new \Aimeos\Shop\Base\Aimeos(); |
||
| 19 | $config = new \Aimeos\Shop\Base\Config(); |
||
| 20 | $i18n = new \Aimeos\Shop\Base\I18n(); |
||
| 21 | $locale = new \Aimeos\Shop\Base\Locale(); |
||
| 22 | |||
| 23 | $mailer = function() {}; |
||
| 24 | |||
| 25 | $session = $this->getMockBuilder( 'Neos\Flow\Session\Session' ) |
||
| 26 | ->disableOriginalConstructor() |
||
| 27 | ->getMock(); |
||
| 28 | |||
| 29 | $resource = array( |
||
|
0 ignored issues
–
show
|
|||
| 30 | 'host' => '127.0.0.1', |
||
| 31 | 'dbname' => 'flow', |
||
| 32 | 'user' => 'root', |
||
| 33 | 'password' => '', |
||
| 34 | ); |
||
| 35 | |||
| 36 | $settings = array( 'flow' => array( 'apc' => array ( 'enable' => true ) ) ); |
||
| 37 | |||
| 38 | $this->inject( $config, 'aimeos', $aimeos ); |
||
| 39 | $this->inject( $i18n, 'aimeos', $aimeos ); |
||
| 40 | |||
| 41 | $this->inject( $this->object, 'i18n', $i18n ); |
||
| 42 | $this->inject( $this->object, 'aimeos', $aimeos ); |
||
| 43 | $this->inject( $this->object, 'config', $config ); |
||
| 44 | $this->inject( $this->object, 'locale', $locale ); |
||
| 45 | $this->inject( $this->object, 'mailer', $mailer ); |
||
| 46 | $this->inject( $this->object, 'session', $session ); |
||
| 47 | $this->inject( $this->object, 'settings', $settings ); |
||
| 48 | } |
||
| 49 | |||
| 50 | |||
| 51 | public function tearDown() |
||
| 52 | { |
||
| 53 | \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\Aimeos\MShop\Locale\Manager\Standard', null ); |
||
| 54 | } |
||
| 55 | |||
| 56 | |||
| 57 | /** |
||
| 58 | * @test |
||
| 59 | */ |
||
| 60 | public function get() |
||
| 61 | { |
||
| 62 | $request = $this->getMockBuilder( '\Neos\Flow\Mvc\ActionRequest' ) |
||
| 63 | ->setMethods( array( 'getArguments', 'getHttpRequest' ) ) |
||
| 64 | ->disableOriginalConstructor() |
||
| 65 | ->getMock(); |
||
| 66 | |||
| 67 | $request->expects( $this->once() )->method( 'getArguments' ) |
||
| 68 | ->will( $this->returnValue( array( 'site' => 'unittest', 'locale' => 'de', 'currency' => 'EUR' ) ) ); |
||
| 69 | |||
| 70 | $httpRequest = $this->getMockBuilder( '\Neos\Flow\Http\Request' ) |
||
| 71 | ->disableOriginalConstructor() |
||
| 72 | ->getMock(); |
||
| 73 | |||
| 74 | $request->expects( $this->once() )->method( 'getHttpRequest' ) |
||
| 75 | ->will( $this->returnValue( $httpRequest ) ) ; |
||
| 76 | |||
| 77 | |||
| 78 | $localeManager = $this->getMockBuilder( '\Aimeos\MShop\Locale\Manager\Standard' ) |
||
| 79 | ->setMethods( array( 'bootstrap' ) ) |
||
| 80 | ->disableOriginalConstructor() |
||
| 81 | ->getMock(); |
||
| 82 | |||
| 83 | $localeManager->expects( $this->once() )->method( 'bootstrap' ) |
||
| 84 | ->will( $this->returnValue( new \Aimeos\MShop\Locale\Item\Standard( array( 'locale.languageid' => 'de' ) ) ) ); |
||
| 85 | |||
| 86 | \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\Aimeos\MShop\Locale\Manager\Standard', $localeManager ); |
||
| 87 | |||
| 88 | $cache = $this->getMockBuilder( '\Neos\Cache\Frontend\StringFrontend' ) |
||
| 89 | ->disableOriginalConstructor() |
||
| 90 | ->getMock(); |
||
| 91 | |||
| 92 | $this->object->setCache( $cache ); |
||
| 93 | |||
| 94 | |||
| 95 | $context = $this->object->get( $request ); |
||
| 96 | |||
| 97 | $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $context ); |
||
| 98 | } |
||
| 99 | |||
| 100 | |||
| 101 | /** |
||
| 102 | * @test |
||
| 103 | */ |
||
| 104 | public function getNoCache() |
||
| 105 | { |
||
| 106 | $request = $this->getMockBuilder( '\Neos\Flow\Mvc\ActionRequest' ) |
||
| 107 | ->setMethods( array( 'getArguments', 'getHttpRequest' ) ) |
||
| 108 | ->disableOriginalConstructor() |
||
| 109 | ->getMock(); |
||
| 110 | |||
| 111 | $request->expects( $this->once() )->method( 'getArguments' ) |
||
| 112 | ->will( $this->returnValue( array() ) ); |
||
| 113 | |||
| 114 | $httpRequest = $this->getMockBuilder( '\Neos\Flow\Http\Request' ) |
||
| 115 | ->disableOriginalConstructor() |
||
| 116 | ->getMock(); |
||
| 117 | |||
| 118 | $request->expects( $this->once() )->method( 'getHttpRequest' ) |
||
| 119 | ->will( $this->returnValue( $httpRequest ) ); |
||
| 120 | |||
| 121 | |||
| 122 | $localeManager = $this->getMockBuilder( '\Aimeos\MShop\Locale\Manager\Standard' ) |
||
| 123 | ->setMethods( array( 'bootstrap' ) ) |
||
| 124 | ->disableOriginalConstructor() |
||
| 125 | ->getMock(); |
||
| 126 | |||
| 127 | $localeManager->expects( $this->once() )->method( 'bootstrap' ) |
||
| 128 | ->will( $this->returnValue( new \Aimeos\MShop\Locale\Item\Standard( array( 'locale.languageid' => 'de' ) ) ) ); |
||
| 129 | |||
| 130 | \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\Aimeos\MShop\Locale\Manager\Standard', $localeManager ); |
||
| 131 | |||
| 132 | $this->object->injectSettings( array( 'flow' => array( 'cache' => array( 'name' => 'None' ) ) ) ); |
||
| 133 | |||
| 134 | |||
| 135 | $context = $this->object->get( $request ); |
||
| 136 | |||
| 137 | $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $context ); |
||
| 138 | } |
||
| 139 | |||
| 140 | |||
| 141 | /** |
||
| 142 | * @test |
||
| 143 | */ |
||
| 144 | public function getCustomCache() |
||
| 145 | { |
||
| 146 | $request = $this->getMockBuilder( '\Neos\Flow\Mvc\ActionRequest' ) |
||
| 147 | ->setMethods( array( 'getArguments', 'getHttpRequest' ) ) |
||
| 148 | ->disableOriginalConstructor() |
||
| 149 | ->getMock(); |
||
| 150 | |||
| 151 | $request->expects( $this->once() )->method( 'getArguments' ) |
||
| 152 | ->will( $this->returnValue( array() ) ); |
||
| 153 | |||
| 154 | $httpRequest = $this->getMockBuilder( '\Neos\Flow\Http\Request' ) |
||
| 155 | ->disableOriginalConstructor() |
||
| 156 | ->getMock(); |
||
| 157 | |||
| 158 | $request->expects( $this->once() )->method( 'getHttpRequest' ) |
||
| 159 | ->will( $this->returnValue( $httpRequest ) ); |
||
| 160 | |||
| 161 | |||
| 162 | $localeManager = $this->getMockBuilder( '\Aimeos\MShop\Locale\Manager\Standard' ) |
||
| 163 | ->setMethods( array( 'bootstrap' ) ) |
||
| 164 | ->disableOriginalConstructor() |
||
| 165 | ->getMock(); |
||
| 166 | |||
| 167 | $localeManager->expects( $this->once() )->method( 'bootstrap' ) |
||
| 168 | ->will( $this->returnValue( new \Aimeos\MShop\Locale\Item\Standard( array( 'locale.languageid' => 'de' ) ) ) ); |
||
| 169 | |||
| 170 | \Aimeos\MShop\Locale\Manager\Factory::injectManager( '\Aimeos\MShop\Locale\Manager\Standard', $localeManager ); |
||
| 171 | |||
| 172 | $this->object->injectSettings( array( 'flow' => array( 'cache' => array( 'name' => 'Custom' ) ) ) ); |
||
| 173 | |||
| 174 | |||
| 175 | $context = $this->object->get( $request ); |
||
| 176 | |||
| 177 | $this->assertInstanceOf( '\Aimeos\MShop\Context\Item\Iface', $context ); |
||
| 178 | } |
||
| 179 | |||
| 180 | |||
| 181 | /** |
||
| 182 | * @test |
||
| 183 | */ |
||
| 184 | public function injectSettings() |
||
| 185 | { |
||
| 186 | $this->object->injectSettings( array( 'test' ) ); |
||
| 187 | |||
| 188 | $this->assertEquals( array( 'test' ), \PHPUnit\Framework\Assert::readAttribute( $this->object, 'settings' ) ); |
||
|
0 ignored issues
–
show
The type
PHPUnit\Framework\Assert was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 189 | } |
||
| 190 | |||
| 191 | |||
| 192 | /** |
||
| 193 | * @test |
||
| 194 | */ |
||
| 195 | public function setCache() |
||
| 196 | { |
||
| 197 | $cache = $this->getMockBuilder( '\Neos\Cache\Frontend\StringFrontend' ) |
||
| 198 | ->disableOriginalConstructor() |
||
| 199 | ->getMock(); |
||
| 200 | |||
| 201 | $this->object->setCache( $cache ); |
||
| 202 | |||
| 203 | $this->assertEquals( $cache, \PHPUnit\Framework\Assert::readAttribute( $this->object, 'cache' ) ); |
||
| 204 | } |
||
| 205 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths