View source
<?php
namespace Drupal\amazons3Test;
use Drupal\amazons3\S3Url;
class S3UrlTest extends \PHPUnit_Framework_TestCase {
public function testConstruct() {
$url = new S3Url('bucket', 'key');
$this
->assertEquals('s3://bucket/key', (string) $url);
$this
->assertEquals('bucket', $url
->getBucket());
$this
->assertEquals('key', $url
->getKey());
}
public function testGetBucket() {
$url = new S3Url('bucket');
$url
->setBucket('second-bucket');
$this
->assertEquals('second-bucket', $url
->getBucket());
}
public function testGetKey() {
$url = new S3Url('bucket');
$url
->setKey('key');
$this
->assertEquals('key', $url
->getKey());
}
public function testSetPath() {
$url = new S3Url('bucket');
$url
->setPath(array(
'directory',
'key',
));
$this
->assertEquals('/directory/key', $url
->getPath());
}
public function testGetImageStyleUrl() {
$url = new S3Url('bucket', 'key');
$styleUrl = $url
->getImageStyleUrl('style_name');
$this
->assertEquals($styleUrl
->getKey(), "styles/style_name/key");
}
public function testFactory() {
$url = S3Url::factory('s3://bucket/key');
$this
->assertInstanceOf('Drupal\\amazons3\\S3Url', $url);
}
public function testFactoryInvalidUrl() {
$url = S3Url::factory(':');
}
}