Files
wordpress-develop/tests/phpunit/tests/xmlrpc/wp/uploadFile.php
T
Sergey Biryukov b396844d38 Tests: Clean up skipping conditions and requirements for various tests.
This improves the consistency of test skipping and ensures that:

* The `@requires` annotations use the right condition and format, and are on the right level (class vs. function).
* Inline conditions with a `markTestSkipped()` call are only used when annotations cannot be used.
* All `markTestSkipped()` calls contain a verbose explanation of why the test is being skipped.

Props jrf, hellofromTonya.
Fixes #53009.

git-svn-id: https://develop.svn.wordpress.org/trunk@51415 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-13 10:43:42 +00:00

38 lines
927 B
PHP

<?php
/**
* @group xmlrpc
* @requires function imagejpeg
*/
class Tests_XMLRPC_wp_uploadFile extends WP_XMLRPC_UnitTestCase {
public function tearDown() {
$this->remove_added_uploads();
parent::tearDown();
}
function test_valid_attachment() {
$this->make_user_by_role( 'editor' );
// Create attachment.
$filename = ( DIR_TESTDATA . '/images/a2-small.jpg' );
$contents = file_get_contents( $filename );
$data = array(
'name' => 'a2-small.jpg',
'type' => 'image/jpeg',
'bits' => $contents,
);
$result = $this->myxmlrpcserver->mw_newMediaObject( array( 0, 'editor', 'editor', $data ) );
$this->assertNotIXRError( $result );
// Check data types.
$this->assertIsString( $result['id'] );
$this->assertStringMatchesFormat( '%d', $result['id'] );
$this->assertIsString( $result['file'] );
$this->assertIsString( $result['url'] );
$this->assertIsString( $result['type'] );
}
}