SemanticMediaWiki /
SemanticNotifications
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SMW\Notifications\Tests; |
||
| 4 | |||
| 5 | use SMW\Notifications\DataValues\NotificationGroupValue; |
||
| 6 | use SMW\Notifications\PropertyRegistry; |
||
| 7 | use SMW\DataValueFactory; |
||
| 8 | use SMW\DIWikiPage; |
||
| 9 | use SMW\DIProperty; |
||
| 10 | use SMWDIBlob as DIBlob; |
||
| 11 | use SMW\Tests\TestEnvironment; |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @covers \SMW\Notifications\DataValues\NotificationGroupValue |
||
| 15 | * @group semantic-notifications |
||
| 16 | * |
||
| 17 | * @license GNU GPL v2+ |
||
| 18 | * @since 1.0 |
||
| 19 | * |
||
| 20 | * @author mwjames |
||
| 21 | */ |
||
| 22 | class NotificationGroupValueTest extends \PHPUnit_Framework_TestCase { |
||
| 23 | |||
| 24 | private $store; |
||
| 25 | private $testEnvironment; |
||
| 26 | private $dataValueFactory; |
||
| 27 | |||
| 28 | protected function setUp() { |
||
| 29 | |||
| 30 | $this->store = $this->getMockBuilder( '\SMW\Store' ) |
||
| 31 | ->disableOriginalConstructor() |
||
| 32 | ->getMockForAbstractClass(); |
||
| 33 | |||
| 34 | $this->testEnvironment = new TestEnvironment(); |
||
| 35 | $this->testEnvironment->registerObject( 'Store', $this->store ); |
||
| 36 | $this->dataValueFactory = DataValueFactory::getInstance(); |
||
| 37 | } |
||
| 38 | |||
| 39 | protected function tearDown() { |
||
| 40 | $this->testEnvironment->tearDown(); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function testCanConstruct() { |
||
| 44 | |||
| 45 | $this->assertInstanceOf( |
||
| 46 | NotificationGroupValue::class, |
||
| 47 | new NotificationGroupValue( '' ) |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | public function testSpecialGroup() { |
||
| 52 | |||
| 53 | $this->assertSame( |
||
| 54 | 'entity specification change group', |
||
| 55 | NotificationGroupValue::getSpecialGroupName( 'en' ) |
||
| 56 | ); |
||
| 57 | } |
||
| 58 | |||
| 59 | public function testTryToSetUserValueOnMissingContext() { |
||
| 60 | |||
| 61 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 62 | $instance->setUserValue( 'Foo' ); |
||
| 63 | |||
| 64 | $this->assertSame( |
||
| 65 | 'Foo', |
||
| 66 | $instance->getWikiValue() |
||
| 67 | ); |
||
| 68 | } |
||
| 69 | |||
| 70 | public function testTryToSetUserValueOnMissingUserContext() { |
||
| 71 | |||
| 72 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 73 | |||
| 74 | $instance->setContextPage( |
||
| 75 | DIWikiPage::newFromText( __METHOD__ ) |
||
|
0 ignored issues
–
show
|
|||
| 76 | ); |
||
| 77 | |||
| 78 | $instance->setUserValue( 'Foo' ); |
||
| 79 | |||
| 80 | $this->assertSame( |
||
| 81 | 'error', |
||
| 82 | $instance->getWikiValue() |
||
| 83 | ); |
||
| 84 | } |
||
| 85 | |||
| 86 | public function testSetUserValueWithSpecialGroup() { |
||
| 87 | |||
| 88 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 89 | $instance->setUserValue( NotificationGroupValue::getSpecialGroupName( 'en' ) ); |
||
| 90 | |||
| 91 | $this->assertSame( |
||
| 92 | NotificationGroupValue::getSpecialGroupName( 'en' ), |
||
| 93 | $instance->getWikiValue() |
||
| 94 | ); |
||
| 95 | } |
||
| 96 | |||
| 97 | public function testSetUserValueWithValidUserContext() { |
||
| 98 | |||
| 99 | $property = new DIProperty( |
||
| 100 | PropertyRegistry::NOTIFICATIONS_TO_GROUP |
||
| 101 | ); |
||
| 102 | |||
| 103 | $this->store->expects( $this->once() ) |
||
| 104 | ->method( 'getPropertySubjects' ) |
||
| 105 | ->with( |
||
| 106 | $this->equalTo( $property ), |
||
| 107 | $this->anything() ) |
||
| 108 | ->will( $this->returnValue( array( 'OnlyCompareWhetherItIsAvailableOrNot' ) ) ); |
||
| 109 | |||
| 110 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 111 | |||
| 112 | $instance->setContextPage( |
||
| 113 | DIWikiPage::newFromText( __METHOD__, NS_USER ) |
||
|
0 ignored issues
–
show
\SMW\DIWikiPage::newFromText(__METHOD__, NS_USER) is of type object<SMW\DIWikiPage>, but the function expects a null|object<SMWDIWikiPage>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 114 | ); |
||
| 115 | |||
| 116 | $instance->setUserValue( 'Foo' ); |
||
| 117 | |||
| 118 | $this->assertSame( |
||
| 119 | 'Foo', |
||
| 120 | $instance->getWikiValue() |
||
| 121 | ); |
||
| 122 | } |
||
| 123 | |||
| 124 | public function testTryToSetUserValueOnUnknownGroup() { |
||
| 125 | |||
| 126 | $property = new DIProperty( |
||
| 127 | PropertyRegistry::NOTIFICATIONS_TO_GROUP |
||
| 128 | ); |
||
| 129 | |||
| 130 | $this->store->expects( $this->once() ) |
||
| 131 | ->method( 'getPropertySubjects' ) |
||
| 132 | ->with( |
||
| 133 | $this->equalTo( $property ), |
||
| 134 | $this->anything() ) |
||
| 135 | ->will( $this->returnValue( array() ) ); |
||
| 136 | |||
| 137 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 138 | |||
| 139 | $instance->setContextPage( |
||
| 140 | DIWikiPage::newFromText( __METHOD__, NS_USER ) |
||
|
0 ignored issues
–
show
\SMW\DIWikiPage::newFromText(__METHOD__, NS_USER) is of type object<SMW\DIWikiPage>, but the function expects a null|object<SMWDIWikiPage>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 141 | ); |
||
| 142 | |||
| 143 | $instance->setUserValue( 'Foo' ); |
||
| 144 | |||
| 145 | $this->assertSame( |
||
| 146 | 'error', |
||
| 147 | $instance->getWikiValue() |
||
| 148 | ); |
||
| 149 | } |
||
| 150 | |||
| 151 | public function testSetUserValueWithValidUserContextAndNotNullLinker() { |
||
| 152 | |||
| 153 | $this->store->expects( $this->once() ) |
||
| 154 | ->method( 'getPropertySubjects' ) |
||
| 155 | ->will( $this->returnValue( array( 'WasMentionedAsGroup' ) ) ); |
||
| 156 | |||
| 157 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 158 | |||
| 159 | $instance->setContextPage( |
||
| 160 | DIWikiPage::newFromText( __METHOD__, NS_USER ) |
||
|
0 ignored issues
–
show
\SMW\DIWikiPage::newFromText(__METHOD__, NS_USER) is of type object<SMW\DIWikiPage>, but the function expects a null|object<SMWDIWikiPage>.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 161 | ); |
||
| 162 | |||
| 163 | $instance->setUserValue( 'Foo bar' ); |
||
| 164 | $instance->setCaption( false ); |
||
|
0 ignored issues
–
show
false is of type boolean, but the function expects a string.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 165 | |||
| 166 | $this->assertContains( |
||
| 167 | SMW_NOTIFICATIONS_TO_GROUP . '/' . 'Foo%20bar', |
||
| 168 | $instance->getShortWikiText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 169 | ); |
||
| 170 | |||
| 171 | $this->assertContains( |
||
| 172 | SMW_NOTIFICATIONS_TO_GROUP . '/' . 'Foo%20bar', |
||
| 173 | $instance->getLongWikiText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 174 | ); |
||
| 175 | |||
| 176 | $this->assertContains( |
||
| 177 | 'value=Foo+bar', |
||
| 178 | $instance->getShortHTMLText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 179 | ); |
||
| 180 | |||
| 181 | $this->assertContains( |
||
| 182 | 'value=Foo+bar', |
||
| 183 | $instance->getLongHTMLText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 184 | ); |
||
| 185 | } |
||
| 186 | |||
| 187 | public function testSetDataItem() { |
||
| 188 | |||
| 189 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 190 | |||
| 191 | $instance->setDataItem( |
||
| 192 | new DIBlob( 'Foo' ) |
||
| 193 | ); |
||
| 194 | |||
| 195 | $this->assertContains( |
||
| 196 | SMW_NOTIFICATIONS_TO_GROUP . '/' . 'Foo', |
||
| 197 | $instance->getShortWikiText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 198 | ); |
||
| 199 | |||
| 200 | $this->assertContains( |
||
| 201 | SMW_NOTIFICATIONS_TO_GROUP . '/' . 'Foo', |
||
| 202 | $instance->getLongWikiText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 203 | ); |
||
| 204 | |||
| 205 | $this->assertContains( |
||
| 206 | 'value=Foo', |
||
| 207 | $instance->getShortHTMLText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 208 | ); |
||
| 209 | |||
| 210 | $this->assertContains( |
||
| 211 | 'value=Foo', |
||
| 212 | $instance->getLongHTMLText( '' ) |
||
|
0 ignored issues
–
show
'' is of type string, but the function expects a object<Linker>|null|boolean.
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
| 213 | ); |
||
| 214 | } |
||
| 215 | |||
| 216 | public function testEmptyDataValue() { |
||
| 217 | |||
| 218 | $instance = $this->dataValueFactory->newDataValueByType( NotificationGroupValue::TYPE_ID ); |
||
| 219 | |||
| 220 | $this->assertEmpty( |
||
| 221 | '', |
||
| 222 | $instance->getShortWikiText() |
||
| 223 | ); |
||
| 224 | |||
| 225 | $this->assertEmpty( |
||
| 226 | '', |
||
| 227 | $instance->getShortHTMLText() |
||
| 228 | ); |
||
| 229 | } |
||
| 230 | |||
| 231 | } |
||
| 232 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: