These are not only 100% identical to the actual code, but also: * It's error-prone. Some are already wrong. * These test…() functions are not meant to be called from anywhere. What is the target audience for this documentation? * There is a @dataProvider. What such @param tags actually do is document the provider, but in an odd place. Just looking at the provider should give the same information. * The MediaWiki CodeSniffer allows to skip @param when there is a @dataProvider, for the reasone listed. Change-Id: I0f6f42f9a15776df944a0da48a50f9d5a2fb6349
56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Wikimedia\Tests\Reflection;
|
|
|
|
use MediaWikiUnitTestCase;
|
|
use Wikimedia\Reflection\GhostFieldTestClass;
|
|
use Wikimedia\Tests\SerializationTestUtils;
|
|
|
|
/**
|
|
* @covers \Wikimedia\Reflection\GhostFieldAccessTrait
|
|
* @package Wikimedia\Tests\Reflection
|
|
*/
|
|
class GhostFieldAccessTraitTest extends MediaWikiUnitTestCase {
|
|
|
|
private function provideUnserializedInstances( string $testCaseName ) {
|
|
// Not using the trait since we only need deserialization tests.
|
|
$serializationTestUtils = new SerializationTestUtils(
|
|
__DIR__ . '/../../../data/GhostFieldAccess',
|
|
[],
|
|
'serialized',
|
|
'serialize',
|
|
'unserialize'
|
|
);
|
|
$instances = $serializationTestUtils
|
|
->getDeserializedInstancesForTestCase( 'GhostFieldTestClass', $testCaseName );
|
|
foreach ( $instances as $instance ) {
|
|
yield "{$instance->version}" => [ $instance->object ];
|
|
}
|
|
}
|
|
|
|
public function provideUnserializedInstancesWithValues() {
|
|
return $this->provideUnserializedInstances( 'withValues' );
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideUnserializedInstancesWithValues
|
|
*/
|
|
public function testUnserializedWithValues( GhostFieldTestClass $instance ) {
|
|
$this->assertSame( 'private_value', $instance->getPrivateField() );
|
|
$this->assertSame( 'protected_value', $instance->getProtectedField() );
|
|
$this->assertSame( 'public_value', $instance->getPublicField() );
|
|
}
|
|
|
|
public function provideUnserializedInstancesWithNulls() {
|
|
return $this->provideUnserializedInstances( 'withNulls' );
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideUnserializedInstancesWithNulls
|
|
*/
|
|
public function testUnserializedWithNulls( GhostFieldTestClass $instance ) {
|
|
$this->assertNull( $instance->getPrivateField() );
|
|
$this->assertNull( $instance->getProtectedField() );
|
|
$this->assertNull( $instance->getPublicField() );
|
|
}
|
|
}
|