Ejemplo n.º 1
0
    /**
     * @dataProvider getDataProvider
     */
    public function testAddComposerTimeWithSimpleKey($resourceKey)
    {
        $composer = array(
            'name' => 'test',
        );
        $driver = new MockVcsDriver();

        $value = null;
        $keys = explode('.', $resourceKey);
        $start = count($keys) - 1;

        for ($i = $start; $i>=0; $i--) {
            if (null === $value) {
                $value = 'level ' . $i;
            }

            $value = array($keys[$i] => $value);
        }

        $driver->contents = json_encode($value);
        $composerValid = array_merge($composer, array(
            'time' => 'level ' . (count($keys) - 1),
        ));

        $composer = Util::addComposerTime($composer, $resourceKey, 'http://example.tld', $driver);

        $this->assertSame($composerValid, $composer);
    }
Ejemplo n.º 2
0
    /**
     * Format composer content.
     *
     * @param array              $composer   The composer
     * @param string             $identifier The identifier
     * @param string             $scheme     The scheme
     * @param string             $owner      The owner
     * @param string             $repository The repository
     * @param VcsDriverInterface $driver     The vcs driver
     * @param string             $method     The method for get content
     *
     * @return array
     */
    protected static function formatComposerContent(array $composer, $identifier, $scheme, $owner, $repository, $driver, $method)
    {
        $resource = $scheme . '://api.bitbucket.org/1.0/repositories/'.$owner.'/'.$repository.'/changesets/'.$identifier;
        $composer = Util::addComposerTime($composer, 'timestamp', $resource, $driver, $method);

        return $composer;
    }
Ejemplo n.º 3
0
    /**
     * Converts json composer file to array.
     *
     * @param string $composer
     * @param string $resource
     * @param string $identifier
     *
     * @return array
     */
    protected function convertComposerContent($composer, $resource, $identifier)
    {
        $composer = JsonFile::parseJson($composer, $resource);
        $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
        $composer = Util::addComposerTime($composer, 'commit.committer.date', $resource, $this);

        if (!isset($composer['support']['source'])) {
            $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
            $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
        }
        if (!isset($composer['support']['issues']) && $this->hasIssues) {
            $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
        }

        return $composer;
    }