OSS\Tests\ContentTypeTest::testByObjectKey PHP Метод

testByObjectKey() публичный Метод

public testByObjectKey ( )
    public function testByObjectKey()
    {
        $client = Common::getOssClient();
        $bucket = Common::getBucketName();
        $object = "test/x.txt";
        $client->putObject($bucket, $object, "hello world");
        $type = $this->getContentType($bucket, $object);
        $this->assertEquals('text/plain', $type);
        $file = '/tmp/x.html';
        $object = 'test/x.txt';
        $this->runCmd('touch ' . $file);
        $client->uploadFile($bucket, $object, $file);
        $type = $this->getContentType($bucket, $object);
        $this->assertEquals('text/html', $type);
        $file = '/tmp/x.none';
        $object = 'test/x.txt';
        $this->runCmd('touch ' . $file);
        $client->uploadFile($bucket, $object, $file);
        $type = $this->getContentType($bucket, $object);
        $this->assertEquals('text/plain', $type);
        $file = '/tmp/x.mp3';
        $object = 'test/y.json';
        $this->runCmd('dd if=/dev/urandom of=' . $file . ' bs=1024 count=100');
        $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100));
        $type = $this->getContentType($bucket, $object);
        $this->assertEquals('audio/mpeg', $type);
        $file = '/tmp/x.none';
        $object = 'test/y.json';
        $this->runCmd('dd if=/dev/urandom of=' . $file . ' bs=1024 count=100');
        $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100));
        $type = $this->getContentType($bucket, $object);
        $this->assertEquals('application/json', $type);
    }