diff --git a/.ci/behat b/.ci/behat index de6e3cc3a..cd175fd59 100755 --- a/.ci/behat +++ b/.ci/behat @@ -3,4 +3,4 @@ set -e export JARNAIZ_JUNIT_OUTPUTDIR=build/ci/behat rm -rf "$JARNAIZ_JUNIT_OUTPUTDIR" && mkdir -p "$JARNAIZ_JUNIT_OUTPUTDIR" -vendor/bin/behat --list-scenarios --tags '~wip' | vendor/bin/fastest --no-interaction --process 8 "JARNAIZ_JUNIT_FILENAME={n}.xml JOURNAL_INSTANCE=behat{p} vendor/bin/behat --strict --format junit {};" +vendor/bin/behat --list-scenarios --tags '@contact' | vendor/bin/fastest --no-interaction --process 8 "JARNAIZ_JUNIT_FILENAME={n}.xml JOURNAL_INSTANCE=behat{p} vendor/bin/behat --strict --format junit {};" diff --git a/.ci/phpunit b/.ci/phpunit index eb842e6b1..c6e3ad99d 100755 --- a/.ci/phpunit +++ b/.ci/phpunit @@ -3,4 +3,4 @@ set -e export FASTEST_OUTPUT_DIR=build/ci/phpunit rm -rf "$FASTEST_OUTPUT_DIR" && mkdir -p "$FASTEST_OUTPUT_DIR" -vendor/bin/fastest --no-interaction --process 4 --xml phpunit.xml.dist "JOURNAL_INSTANCE=phpunit{p} vendor/bin/phpunit --log-junit $FASTEST_OUTPUT_DIR/{n}.xml {};" +vendor/bin/fastest --no-interaction --process 4 --xml phpunit.xml.dist "JOURNAL_INSTANCE=phpunit{p} vendor/bin/phpunit --filter StatusTest::it_returns_200_pong_when_the_application_is_correctly_setup --log-junit $FASTEST_OUTPUT_DIR/{n}.xml {};" diff --git a/.env b/.env index 401bde66a..16d064e9a 100644 --- a/.env +++ b/.env @@ -4,7 +4,7 @@ IMAGE_TAG=develop APP_ENV=dev PHP_VERSION=6ec2cc0701564355436c42b87399ab062d35b1be NODE_VERSION=6.17.0-stretch -DEPENDENCIES_API_DUMMY=410de0c23c7744eaeb883483264f700563674d36 +DEPENDENCIES_API_DUMMY=pr-204 # add '-debug' for VNC support SELENIUM_IMAGE_SUFFIX= JOURNAL_PORT=8080 diff --git a/app/Resources/views/home.html.twig b/app/Resources/views/home.html.twig index 225735394..70356bb33 100644 --- a/app/Resources/views/home.html.twig +++ b/app/Resources/views/home.html.twig @@ -12,10 +12,10 @@ {% block body %} - {% if carousel %} - - {{ render_pattern(carousel) }} - + {% if heroBanner %} +
+ {{ render_pattern(heroBanner) }} +
{% endif %}
diff --git a/app/config/config.yml b/app/config/config.yml index 606a32fd0..0b163b55a 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -25,14 +25,14 @@ csa_guzzle: clients: elife_api: config: - base_uri: '%api_url%' - connect_timeout: '%api_connect_timeout%' + base_uri: 'https://demo--api-dummy.elifesciences.org' + connect_timeout: '%api_connect_timeout_slow%' headers: Authorization: '%api_key%' - timeout: '%api_timeout%' + timeout: '%api_timeout_slow%' elife_api_slow: config: - base_uri: '%api_url%' + base_uri: 'https://demo--api-dummy.elifesciences.org' connect_timeout: '%api_connect_timeout_slow%' headers: Authorization: '%api_key%' diff --git a/app/config/routing.yml b/app/config/routing.yml index 842dfd752..bc36b2a96 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -141,7 +141,7 @@ article-type: defaults: _controller: AppBundle:ArticleTypes:list requirements: - type: '(correction|editorial|feature|insight|research-advance|research-article|research-communication|retraction|registered-report|replication-study|review-article|scientific-correspondence|short-report|tools-resources)' + type: '(reviewed-preprint|correction|editorial|feature|insight|research-advance|research-article|research-communication|retraction|registered-report|replication-study|review-article|scientific-correspondence|short-report|tools-resources)' article-version-xml: path: /articles/{id}v{version}.xml diff --git a/app/config/services.yml b/app/config/services.yml index 0fb595f66..d4e7a36a9 100644 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -151,6 +151,10 @@ services: class: eLife\ApiSdk\Client\Search factory: ['@elife.api_sdk', search] + elife.api_sdk.reviewed.preprint: + class: eLife\ApiSdk\Client\ReviewedPreprints + factory: ['@elife.api_sdk', reviewedPreprint] + elife.api_sdk.search.slow: class: eLife\ApiSdk\Client\Search factory: ['@elife.api_sdk.slow', search] @@ -540,6 +544,17 @@ services: tags: - name: view_model.converter + elife.journal.view_model.converter.reviewed.preprint: + class: eLife\Journal\ViewModel\Converter\ReviewedPreprintConverter + public: false + arguments: + - '@elife.journal.view_model.converter' + - '@router' + - '@security.authorization_checker' + - '%era_articles%' + tags: + - name: view_model.converter + elife.journal.view_model.converter.article.modal: class: eLife\Journal\ViewModel\Converter\ArticleModalConverter public: false @@ -879,12 +894,11 @@ services: tags: - name: view_model.converter - elife.journal.view_model.converter.cover.article.carousel_item: - class: eLife\Journal\ViewModel\Converter\CoverArticleCarouselItemConverter + elife.journal.view_model.converter.cover.article.hero_banner: + class: eLife\Journal\ViewModel\Converter\CoverArticleHeroBannerConverter public: false arguments: - '@router' - - '@elife.journal.view_model.factory.carousel_item_image' tags: - name: view_model.converter @@ -897,12 +911,11 @@ services: tags: - name: view_model.converter - elife.journal.view_model.converter.cover.blog_article.carousel_item: - class: eLife\Journal\ViewModel\Converter\CoverBlogArticleCarouselItemConverter + elife.journal.view_model.converter.cover.blog_article.hero_banner: + class: eLife\Journal\ViewModel\Converter\CoverBlogArticleHeroBannerConverter public: false arguments: - '@router' - - '@elife.journal.view_model.factory.carousel_item_image' tags: - name: view_model.converter @@ -915,12 +928,11 @@ services: tags: - name: view_model.converter - elife.journal.view_model.converter.cover.collection.carousel_item: - class: eLife\Journal\ViewModel\Converter\CoverCollectionCarouselItemConverter + elife.journal.view_model.converter.cover.collection.hero_banner: + class: eLife\Journal\ViewModel\Converter\CoverCollectionHeroBannerConverter public: false arguments: - '@router' - - '@elife.journal.view_model.factory.carousel_item_image' tags: - name: view_model.converter diff --git a/composer.json b/composer.json index c1ecf8047..44cb5026a 100644 --- a/composer.json +++ b/composer.json @@ -21,10 +21,11 @@ "composer/package-versions-deprecated": "1.11.99.2", "csa/guzzle-bundle": "^2.2", "cweagans/composer-patches": "^1.6", - "elife/api-client": "^1.0@dev", - "elife/api-sdk": "dev-master", + "elife/api": "dev-develop", + "elife/api-client": "dev-master", + "elife/api-sdk": "dev-staging", "elife/civi-contacts": "dev-master", - "elife/patterns": "dev-master", + "elife/patterns": "dev-staging", "fabpot/goutte": "^3.2", "fig/link-util": "^1.0", "firebase/php-jwt": "^5.0", @@ -57,7 +58,6 @@ "behat/mink-extension": "^2.3", "behat/mink-selenium2-driver": "^1.3", "behat/symfony2-extension": "^2.1", - "elife/api": "^2.1", "elife/api-validator": "^1.0@dev", "jarnaiz/behat-junit-formatter": "^1.3", "justinrainbow/json-schema": "^5.2", diff --git a/composer.lock b/composer.lock index d06ebb379..1d13fd488 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a55b91cc51f018f8f12ef70c1a59b1f3", + "content-hash": "11c8862fdcfd7e08f3809ae06f3568b7", "packages": [ { "name": "beberlei/assert", @@ -237,6 +237,16 @@ "ssl", "tls" ], + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2020-04-08T08:27:21+00:00" }, { @@ -292,6 +302,20 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], "time": "2021-05-24T07:46:03+00:00" }, { @@ -604,6 +628,20 @@ "redis", "xcache" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcache", + "type": "tidelift" + } + ], "time": "2020-05-27T16:24:54+00:00" }, { @@ -669,6 +707,20 @@ "iterators", "php" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcollections", + "type": "tidelift" + } + ], "time": "2020-05-25T19:24:35+00:00" }, { @@ -752,6 +804,20 @@ "doctrine", "php" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fcommon", + "type": "tidelift" + } + ], "time": "2020-06-05T16:46:05+00:00" }, { @@ -1038,6 +1104,20 @@ "orm", "persistence" ], + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Fpersistence", + "type": "tidelift" + } + ], "time": "2020-03-21T15:13:52+00:00" }, { @@ -1177,18 +1257,43 @@ ], "time": "2020-02-13T22:36:52+00:00" }, + { + "name": "elife/api", + "version": "dev-develop", + "source": { + "type": "git", + "url": "https://github.com/elifesciences/api-raml.git", + "reference": "e4289c613c57a3262df05269b18c16cb1de0ba75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/elifesciences/api-raml/zipball/e4289c613c57a3262df05269b18c16cb1de0ba75", + "reference": "e4289c613c57a3262df05269b18c16cb1de0ba75", + "shasum": "" + }, + "conflict": { + "justinrainbow/json-schema": "<3.0.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "eLife Sciences API specification", + "time": "2022-08-18T09:00:05+00:00" + }, { "name": "elife/api-client", "version": "dev-master", "source": { "type": "git", "url": "https://github.com/elifesciences/api-client-php.git", - "reference": "acbe0ecba674b9c9a0b5f975d96357b332d193c0" + "reference": "42c424ea570a1d8c9eed977dd565cad84464de6f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elifesciences/api-client-php/zipball/acbe0ecba674b9c9a0b5f975d96357b332d193c0", - "reference": "acbe0ecba674b9c9a0b5f975d96357b332d193c0", + "url": "https://api.github.com/repos/elifesciences/api-client-php/zipball/42c424ea570a1d8c9eed977dd565cad84464de6f", + "reference": "42c424ea570a1d8c9eed977dd565cad84464de6f", "shasum": "" }, "require": { @@ -1232,20 +1337,20 @@ "MIT" ], "description": "eLife Sciences API client", - "time": "2021-06-02T11:18:22+00:00" + "time": "2022-08-18T18:50:00+00:00" }, { "name": "elife/api-sdk", - "version": "dev-master", + "version": "dev-staging", "source": { "type": "git", "url": "https://github.com/elifesciences/api-sdk-php.git", - "reference": "2430f058628313e994bc250d74aaa1a2b9f63853" + "reference": "52cdc8465d71524f6683c62ee61bcd54198811da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elifesciences/api-sdk-php/zipball/2430f058628313e994bc250d74aaa1a2b9f63853", - "reference": "2430f058628313e994bc250d74aaa1a2b9f63853", + "url": "https://api.github.com/repos/elifesciences/api-sdk-php/zipball/52cdc8465d71524f6683c62ee61bcd54198811da", + "reference": "52cdc8465d71524f6683c62ee61bcd54198811da", "shasum": "" }, "require": { @@ -1286,7 +1391,7 @@ "MIT" ], "description": "eLife Sciences API SDK", - "time": "2021-10-05T13:20:01+00:00" + "time": "2022-08-31T09:31:12+00:00" }, { "name": "elife/civi-contacts", @@ -1329,16 +1434,16 @@ }, { "name": "elife/patterns", - "version": "dev-master", + "version": "dev-staging", "source": { "type": "git", "url": "https://github.com/elifesciences/patterns-php.git", - "reference": "8d93982d827fc00361bf32534296620a82f063e3" + "reference": "f1f6c692066661a162977f6ba815daffb4e2337e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/elifesciences/patterns-php/zipball/8d93982d827fc00361bf32534296620a82f063e3", - "reference": "8d93982d827fc00361bf32534296620a82f063e3", + "url": "https://api.github.com/repos/elifesciences/patterns-php/zipball/f1f6c692066661a162977f6ba815daffb4e2337e", + "reference": "f1f6c692066661a162977f6ba815daffb4e2337e", "shasum": "" }, "require": { @@ -1375,7 +1480,7 @@ "MIT" ], "description": "eLife patterns", - "time": "2022-08-30T09:47:13+00:00" + "time": "2022-09-01T10:04:37+00:00" }, { "name": "fabpot/goutte", @@ -1792,6 +1897,20 @@ "rest", "web service" ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], "time": "2022-06-09T21:36:50+00:00" }, { @@ -1858,6 +1977,20 @@ "keywords": [ "promise" ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], "time": "2021-10-22T20:56:57+00:00" }, { @@ -1950,6 +2083,20 @@ "uri", "url" ], + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], "time": "2022-03-20T21:51:18+00:00" }, { @@ -2498,6 +2645,12 @@ "paginator", "paging" ], + "funding": [ + { + "url": "https://github.com/mbabker", + "type": "github" + } + ], "time": "2017-03-20T13:46:15+00:00" }, { @@ -2653,6 +2806,20 @@ "x.509", "x509" ], + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], "time": "2022-01-30T08:50:05+00:00" }, { @@ -3232,6 +3399,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-05-12T16:47:27+00:00" }, { @@ -3302,6 +3483,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2022-05-24T11:49:31+00:00" }, { @@ -3369,6 +3564,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2022-05-24T11:49:31+00:00" }, { @@ -3428,6 +3637,20 @@ "portable", "shim" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2022-05-24T11:49:31+00:00" }, { @@ -3648,6 +3871,20 @@ "keywords": [ "framework" ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2021-05-19T12:07:19+00:00" }, { @@ -3714,6 +3951,16 @@ "keywords": [ "templating" ], + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], "time": "2022-04-06T06:45:17+00:00" }, { @@ -4271,6 +4518,7 @@ "framework", "symfony" ], + "abandoned": "friends-of-behat/symfony-extension", "time": "2018-04-20T15:48:23+00:00" }, { @@ -4372,32 +4620,21 @@ "constructor", "instantiate" ], - "time": "2020-05-29T17:27:14+00:00" - }, - { - "name": "elife/api", - "version": "2.5.0", - "source": { - "type": "git", - "url": "https://github.com/elifesciences/api-raml.git", - "reference": "fbfd26f96e1f8d5bd80c4bf7314665fe5de5fa74" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/elifesciences/api-raml/zipball/fbfd26f96e1f8d5bd80c4bf7314665fe5de5fa74", - "reference": "fbfd26f96e1f8d5bd80c4bf7314665fe5de5fa74", - "shasum": "" - }, - "conflict": { - "justinrainbow/json-schema": "<3.0.0" - }, - "type": "library", - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } ], - "description": "eLife Sciences API specification", - "time": "2021-10-05T12:24:35+00:00" + "time": "2020-05-29T17:27:14+00:00" }, { "name": "elife/api-validator", @@ -4807,6 +5044,12 @@ "object", "object graph" ], + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], "time": "2020-06-29T13:22:24+00:00" }, { @@ -6318,6 +6561,7 @@ "aliases": [], "minimum-stability": "stable", "stability-flags": { + "elife/api": 20, "elife/api-client": 20, "elife/api-sdk": 20, "elife/civi-contacts": 20, @@ -6333,5 +6577,6 @@ "platform-dev": [], "platform-overrides": { "php": "7.1.33" - } + }, + "plugin-api-version": "1.1.0" } diff --git a/features/bootstrap/ArchiveContext.php b/features/bootstrap/ArchiveContext.php index 72365672f..e30661472 100644 --- a/features/bootstrap/ArchiveContext.php +++ b/features/bootstrap/ArchiveContext.php @@ -154,11 +154,11 @@ public function researchArticlesWerePublishedDuringMarch(int $number, string $mo new Request( 'GET', "http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=published&start-date=$startDate&end-date=$endDate", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => [$articles[0]], @@ -189,6 +189,7 @@ public function researchArticlesWerePublishedDuringMarch(int $number, string $mo 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -201,11 +202,11 @@ public function researchArticlesWerePublishedDuringMarch(int $number, string $mo new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=100&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=published&start-date=$startDate&end-date=$endDate", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -236,6 +237,7 @@ public function researchArticlesWerePublishedDuringMarch(int $number, string $mo 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -274,11 +276,11 @@ public function magazineArticlesWerePublishedDuringMarch(int $number, string $mo new Request( 'GET', "http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=published&start-date=$startDate&end-date=$endDate", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => [$articles[0]], @@ -303,6 +305,7 @@ public function magazineArticlesWerePublishedDuringMarch(int $number, string $mo 'interview' => $number, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -315,11 +318,11 @@ public function magazineArticlesWerePublishedDuringMarch(int $number, string $mo new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=100&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=published&start-date=$startDate&end-date=$endDate", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -344,6 +347,7 @@ public function magazineArticlesWerePublishedDuringMarch(int $number, string $mo 'interview' => $number, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -429,11 +433,11 @@ public function thereAreMagazineArticles(TableNode $table) new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=published&start-date=2016-03-01&end-date=2016-03-31', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => count($articles), 'items' => [$articles[0]], @@ -470,6 +474,7 @@ public function thereAreMagazineArticles(TableNode $table) return $carry; }, 0), + 'reviewed-preprint' => 0, ], ]) ) @@ -482,11 +487,11 @@ public function thereAreMagazineArticles(TableNode $table) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=100&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=published&start-date=2016-03-01&end-date=2016-03-31", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => count($articles), 'items' => $articleChunk, @@ -523,6 +528,7 @@ public function thereAreMagazineArticles(TableNode $table) return $carry; }, 0), + 'reviewed-preprint' => 0, ], ]) ) @@ -552,11 +558,11 @@ public function iGoToTheArchiveForMarch(string $month, int $year) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=published&start-date=$startDate&end-date=$endDate", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -581,6 +587,7 @@ public function iGoToTheArchiveForMarch(string $month, int $year) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/features/bootstrap/ArticleTypeContext.php b/features/bootstrap/ArticleTypeContext.php index ed379d568..a60065cba 100644 --- a/features/bootstrap/ArticleTypeContext.php +++ b/features/bootstrap/ArticleTypeContext.php @@ -47,11 +47,11 @@ public function articlesHaveBeenPublished(int $number) new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-article&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => [$articles[0]], @@ -82,6 +82,7 @@ public function articlesHaveBeenPublished(int $number) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -94,11 +95,11 @@ public function articlesHaveBeenPublished(int $number) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=$chunk&sort=date&order=desc&type[]=research-article&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -129,6 +130,8 @@ public function articlesHaveBeenPublished(int $number) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/features/bootstrap/HomepageContext.php b/features/bootstrap/HomepageContext.php index 978eac1f3..558fde4f5 100644 --- a/features/bootstrap/HomepageContext.php +++ b/features/bootstrap/HomepageContext.php @@ -58,12 +58,12 @@ public function articlesHaveBeenPublished(int $number) $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => [$articles[0]], @@ -94,6 +94,7 @@ public function articlesHaveBeenPublished(int $number) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -105,12 +106,12 @@ public function articlesHaveBeenPublished(int $number) $this->mockApiResponse( new Request( 'GET', - "http://api.elifesciences.org/search?for=&page=$page&per-page=$chunk&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + "http://api.elifesciences.org/search?for=&page=$page&per-page=$chunk&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default", + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -141,6 +142,7 @@ public function articlesHaveBeenPublished(int $number) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -196,11 +198,11 @@ public function theMagazineHasItems(int $number) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=7&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -231,6 +233,7 @@ public function theMagazineHasItems(int $number) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => $this->numberOfMagazineArticles, + 'reviewed-preprint' => 0, ], ]) ) @@ -246,6 +249,13 @@ public function thereIsACollectionCalled(string $name) // Do nothin. } + /** + * @Given /^There is an article called \'([^\']*)\'$/ + */ + public function thereIsAnArticleCalled($title) + { + // Do nothing + } /** * @Given /^there is a cover linking to the \'([^\']*)\' collection$/ */ @@ -440,12 +450,12 @@ public function iGoToTheHomepage() $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=reviewed-prepeint&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -470,6 +480,7 @@ public function iGoToTheHomepage() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -556,11 +567,11 @@ public function iFillInTheSignUpForm() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -585,6 +596,7 @@ public function iFillInTheSignUpForm() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -639,31 +651,6 @@ public function iShouldSeeTheLatestMagazineItemsInTheMagazineList(int $number) ); } - /** - * @Then /^I should see the \'([^\']*)\' cover in the carousel$/ - */ - public function iShouldSeeTheCoverInTheCarousel(string $name) - { - $this->spin(function () use ($name) { - $this->assertSession()->elementAttributeContains('css', '.carousel-item__title_link', 'href', $this->createId($name)); - }); - } - - /** - * @Then /^I should see the title and image from the \'([^\']*)\' collection used in the \'([^\']*)\' cover$/ - */ - public function iShouldSeeTheTitleAndImageFromTheCollectionUsedInTheCover(string $collectionName, string $coverName) - { - $this->spin(function () { - $this->assertSession()->elementAttributeContains( - 'css', - '.carousel-item__image', - 'src', - 'https://www.example.com/iiif/iden%2Ftifier/0,529,1800,543/1114,336/0/default.jpg' - ); - }); - } - /** * @Then /^I should see the custom title and image used in the \'([^\']*)\' cover$/ */ @@ -701,4 +688,15 @@ private function createId(string $name) : string { return md5($name); } + + /** + * @Then I should see the :title cover in the hero banner + */ + public function iShouldSeeTheCoverInTheHeroBanner($title) + { + $this->assertSession()->elementExists( + 'css', + '.hero-banner__title_link' + ); + } } diff --git a/features/bootstrap/MagazineContext.php b/features/bootstrap/MagazineContext.php index d10b8df32..8331c92df 100644 --- a/features/bootstrap/MagazineContext.php +++ b/features/bootstrap/MagazineContext.php @@ -41,11 +41,11 @@ public function magazineArticlesHaveBeenPublished(int $number) new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => [$articles[0]], @@ -70,6 +70,7 @@ public function magazineArticlesHaveBeenPublished(int $number) 'interview' => $this->numberOfArticles, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -82,11 +83,11 @@ public function magazineArticlesHaveBeenPublished(int $number) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=$chunk&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => $articleChunk, @@ -111,6 +112,7 @@ public function magazineArticlesHaveBeenPublished(int $number) 'interview' => $this->numberOfArticles, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -658,11 +660,11 @@ public function iGoToTheMagazinePage() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -687,6 +689,7 @@ public function iGoToTheMagazinePage() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/features/bootstrap/SearchContext.php b/features/bootstrap/SearchContext.php index ba04c8818..a2cd5034f 100644 --- a/features/bootstrap/SearchContext.php +++ b/features/bootstrap/SearchContext.php @@ -128,6 +128,7 @@ public function thereAreArticlesAbout(int $number, string $type, string $keyword 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ]; foreach (array_keys($typeFilters) as $type) { @@ -155,11 +156,11 @@ public function thereAreArticlesAbout(int $number, string $type, string $keyword new Request( 'GET', sprintf($uri, $thisKeyword, 1, 1), - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => count($articlesWithKeywordAndSubjects), 'items' => count($articlesWithKeywordAndSubjects) ? [$articlesWithKeywordAndSubjects[0]] : [], @@ -180,11 +181,11 @@ public function thereAreArticlesAbout(int $number, string $type, string $keyword new Request( 'GET', sprintf($uri, $thisKeyword, $i + 1, $chunk), - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => count($articlesWithKeywordAndSubjects), 'items' => $articleChunk, diff --git a/features/bootstrap/SubjectContext.php b/features/bootstrap/SubjectContext.php index d49b2df65..ee9145573 100644 --- a/features/bootstrap/SubjectContext.php +++ b/features/bootstrap/SubjectContext.php @@ -237,11 +237,11 @@ public function thereAreArticlesWithTheMSA(int $number, string $subject) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&subject[]=$subjectId&type[]=research-article&type[]=research-communication&type[]=research-advance&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => array_map(function (array $collection) { @@ -278,6 +278,7 @@ public function thereAreArticlesWithTheMSA(int $number, string $subject) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -290,11 +291,11 @@ public function thereAreArticlesWithTheMSA(int $number, string $subject) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=$page&per-page=$chunk&sort=date&order=desc&subject[]=$subjectId&type[]=research-article&type[]=research-communication&type[]=research-advance&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => $number, 'items' => array_map(function (array $collection) { @@ -331,6 +332,7 @@ public function thereAreArticlesWithTheMSA(int $number, string $subject) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -495,11 +497,11 @@ public function iGoTheMSAPage(string $subject) new Request( 'GET', "http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&subject[]=$subjectId&type[]=research-article&type[]=research-communication&type[]=research-advance&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&use-date=default", - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -530,6 +532,7 @@ public function iGoTheMSAPage(string $subject) 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/features/homepage-carousel.feature b/features/homepage-carousel.feature deleted file mode 100644 index 5a55d57c1..000000000 --- a/features/homepage-carousel.feature +++ /dev/null @@ -1,26 +0,0 @@ -@homepage -Feature: Homepage carousel - - Rules: - - Contains between 1 and 3 covers - - Any type eLife content can have a cover - - A cover has a title and image, which can be different from the content that it links to - - Background: - Given 10 articles have been published - - @javascript - Scenario: Covers use details from the content that they link to by default - Given there is a collection called 'Tropical disease' - And there is a cover linking to the 'Tropical disease' collection - When I go to the homepage - Then I should see the 'Tropical disease' cover in the carousel - And I should see the title and image from the 'Tropical disease' collection used in the 'Tropical disease' cover - - @javascript - Scenario: Cover can have a title and image different from the content they link to - Given there is a collection called 'Tropical disease' - And there is a cover linking to the 'Tropical disease' collection with a custom title and image - When I go to the homepage - Then I should see the 'Tropical disease' cover in the carousel - And I should see the custom title and image used in the 'Tropical disease' cover diff --git a/features/homepage-hero-banner.feature b/features/homepage-hero-banner.feature new file mode 100644 index 000000000..739e50668 --- /dev/null +++ b/features/homepage-hero-banner.feature @@ -0,0 +1,16 @@ +@homepage +Feature: Homepage Hero banner + + Rules: + - Contains 1 hero banner + - Any type eLife content can have a cover + - Hero banner has a title, a short text, date, category, subjects, and image + + Background: + Given 10 articles have been published + + Scenario: Cover can have a title and image different from the content they link to + Given there is a collection called 'Tropical disease' + And there is a cover linking to the 'Tropical disease' collection + When I go to the homepage + Then I should see the 'Tropical disease' cover in the hero banner diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 7954b0903..d445e1727 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -3,17 +3,22 @@ namespace eLife\Journal\Controller; use eLife\ApiSdk\Collection\Sequence; +use eLife\ApiSdk\Model\ArticleVersion; +use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Subject; use eLife\Journal\Helper\Callback; +use eLife\Journal\Helper\ModelName; use eLife\Journal\Helper\Paginator; use eLife\Journal\Pagerfanta\SequenceAdapter; -use eLife\Patterns\ViewModel\Carousel; -use eLife\Patterns\ViewModel\CarouselItem; +use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; +use eLife\Patterns\ViewModel\Date; +use eLife\Patterns\ViewModel\HeroBanner; use eLife\Patterns\ViewModel\LeadPara; use eLife\Patterns\ViewModel\LeadParas; use eLife\Patterns\ViewModel\Link; use eLife\Patterns\ViewModel\ListHeading; use eLife\Patterns\ViewModel\ListingTeasers; +use eLife\Patterns\ViewModel\Meta; use eLife\Patterns\ViewModel\SectionListing; use eLife\Patterns\ViewModel\SectionListingLink; use eLife\Patterns\ViewModel\SeeMoreLink; @@ -33,7 +38,7 @@ public function homeAction(Request $request) : Response $arguments = $this->defaultPageArguments($request); $latestResearch = promise_for($this->get('elife.api_sdk.search') - ->forType('research-advance', 'research-article', 'research-communication', 'review-article', 'scientific-correspondence', 'short-report', 'tools-resources', 'replication-study') + ->forType('reviewed-preprint', 'research-advance', 'research-article', 'research-communication', 'review-article', 'scientific-correspondence', 'short-report', 'tools-resources', 'replication-study') ->sortBy('date')) ->then(function (Sequence $sequence) use ($page, $perPage) { $pagerfanta = new Pagerfanta(new SequenceAdapter($sequence, $this->willConvertTo(Teaser::class))); @@ -70,12 +75,15 @@ function (int $page = null) use ($request) { private function createFirstPage(array $arguments) : Response { - $arguments['carousel'] = $this->get('elife.api_sdk.covers') + + $arguments['heroBanner'] = $this->get('elife.api_sdk.covers') ->getCurrent() - ->map($this->willConvertTo(CarouselItem::class)) - ->then(Callback::emptyOr(function (Sequence $covers) { - return new Carousel($covers->toArray(), new ListHeading('Highlights', 'highlights')); - })) + ->then(function (Sequence $items) { + /** @var Cover $item */ + $cover = $items[0]; + + return $this->convertTo($cover, HeroBanner::class); + }) ->otherwise($this->softFailure('Failed to load covers')); $arguments['leadParas'] = new LeadParas([new LeadPara('eLife works to improve research communication through open science and open technology innovation', 'strapline')]); diff --git a/src/Guzzle/SubjectRewritingMiddleware.php b/src/Guzzle/SubjectRewritingMiddleware.php index 8408f9775..6fcc471eb 100644 --- a/src/Guzzle/SubjectRewritingMiddleware.php +++ b/src/Guzzle/SubjectRewritingMiddleware.php @@ -143,7 +143,7 @@ public function __invoke(callable $handler) : callable $data['relatedContent'] = $this->updateItems($data['relatedContent'] ?? []); break; - case 'application/vnd.elife.search+json; version=1': + case 'application/vnd.elife.search+json; version=2': $data['items'] = $this->updateItems($data['items']); $data['subjects'] = $this->updateSearchSubjects($data['subjects'] ?? []); break; diff --git a/src/Helper/ModelName.php b/src/Helper/ModelName.php index bb7995162..89a8eb70d 100644 --- a/src/Helper/ModelName.php +++ b/src/Helper/ModelName.php @@ -103,6 +103,10 @@ final class ModelName 'singular' => 'Highlight', 'plural' => 'Highlights', ], + 'reviewed-preprint' => [ + 'singular' => 'Reviewed Preprint', + 'plural' => 'Reviewed Preprints', + ], ]; private function __construct() diff --git a/src/Router/ModelParameterResolver.php b/src/Router/ModelParameterResolver.php index 7135906fc..7bac2952a 100644 --- a/src/Router/ModelParameterResolver.php +++ b/src/Router/ModelParameterResolver.php @@ -50,6 +50,8 @@ public function resolve(string $route, array $parameters) : array $new = ['id' => $model->getId(), 'slug' => $this->slugify->slugify($model->getTitle())]; } elseif ($model instanceof Model\Subject) { $new = ['id' => $model->getId()]; + } elseif ($model instanceof Model\ReviewedPreprint) { + $new = ['id' => $model->getId(), 'slug' => $this->slugify->slugify($model->getTitle())]; } else { throw new InvalidArgumentException('Unexpected '.get_class($model)); } diff --git a/src/ViewModel/Converter/CoverArticleCarouselItemConverter.php b/src/ViewModel/Converter/CoverArticleHeroBannerConverter.php similarity index 62% rename from src/ViewModel/Converter/CoverArticleCarouselItemConverter.php rename to src/ViewModel/Converter/CoverArticleHeroBannerConverter.php index 143fffafb..4f36437a4 100644 --- a/src/ViewModel/Converter/CoverArticleCarouselItemConverter.php +++ b/src/ViewModel/Converter/CoverArticleHeroBannerConverter.php @@ -7,20 +7,19 @@ use eLife\ApiSdk\Model\Subject; use eLife\Journal\Helper\ModelName; use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; +use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; use eLife\Patterns\ViewModel; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -final class CoverArticleCarouselItemConverter implements ViewModelConverter +final class CoverArticleHeroBannerConverter implements ViewModelConverter { use CreatesDate; private $urlGenerator; - private $carouselItemImageFactory; - public function __construct(UrlGeneratorInterface $urlGenerator, CarouselItemImageFactory $carouselItemImageFactory) + public function __construct(UrlGeneratorInterface $urlGenerator) { $this->urlGenerator = $urlGenerator; - $this->carouselItemImageFactory = $carouselItemImageFactory; } /** @@ -31,28 +30,28 @@ public function convert($object, string $viewModel = null, array $context = []) /** @var ArticleVersion $article */ $article = $object->getItem(); - return new ViewModel\CarouselItem( + return new ViewModel\HeroBanner( $article->getSubjects()->map(function (Subject $subject) { return new ViewModel\Link($subject->getName(), $this->urlGenerator->generate('subject', [$subject])); })->toArray(), - new ViewModel\Link( - $object->getTitle(), - $this->urlGenerator->generate('article', [$article]) - ), - 'Read article', + new ViewModel\Link($object->getTitle(), $this->urlGenerator->generate('article', [$article])), ViewModel\Meta::withLink( new ViewModel\Link( ModelName::singular($article->getType()), - $this->urlGenerator->generate('article-type', ['type' => $article->getType()]) + $this->urlGenerator->generate('article', [$article]) ), $this->simpleDate($article, $context) ), - $this->carouselItemImageFactory->forImage($object->getBanner()) + (new PictureBuilderFactory())->forImage( + $object->getBanner(), $object->getBanner()->getWidth()) + ->build(), + $article->getImpactStatement(), + $article->getAuthorLine() ); } public function supports($object, string $viewModel = null, array $context = []) : bool { - return $object instanceof Cover && ViewModel\CarouselItem::class === $viewModel && $object->getItem() instanceof ArticleVersion; + return $object instanceof Cover && ViewModel\HeroBanner::class === $viewModel && $object->getItem() instanceof ArticleVersion; } } diff --git a/src/ViewModel/Converter/CoverBlogArticleCarouselItemConverter.php b/src/ViewModel/Converter/CoverBlogArticleHeroBannerConverter.php similarity index 72% rename from src/ViewModel/Converter/CoverBlogArticleCarouselItemConverter.php rename to src/ViewModel/Converter/CoverBlogArticleHeroBannerConverter.php index 52c377af6..0b2155e5a 100644 --- a/src/ViewModel/Converter/CoverBlogArticleCarouselItemConverter.php +++ b/src/ViewModel/Converter/CoverBlogArticleHeroBannerConverter.php @@ -6,20 +6,19 @@ use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Subject; use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; +use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; use eLife\Patterns\ViewModel; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -final class CoverBlogArticleCarouselItemConverter implements ViewModelConverter +final class CoverBlogArticleHeroBannerConverter implements ViewModelConverter { use CreatesDate; private $urlGenerator; - private $carouselItemImageFactory; - public function __construct(UrlGeneratorInterface $urlGenerator, CarouselItemImageFactory $carouselItemImageFactory) + public function __construct(UrlGeneratorInterface $urlGenerator) { $this->urlGenerator = $urlGenerator; - $this->carouselItemImageFactory = $carouselItemImageFactory; } /** @@ -30,22 +29,24 @@ public function convert($object, string $viewModel = null, array $context = []) /** @var BlogArticle $blogArticle */ $blogArticle = $object->getItem(); - return new ViewModel\CarouselItem( + return new ViewModel\HeroBanner( $blogArticle->getSubjects()->map(function (Subject $subject) { return new ViewModel\Link($subject->getName(), $this->urlGenerator->generate('subject', [$subject])); })->toArray(), new ViewModel\Link($object->getTitle(), $this->urlGenerator->generate('inside-elife-article', [$blogArticle])), - 'Read article', ViewModel\Meta::withLink( new ViewModel\Link('Inside eLife', $this->urlGenerator->generate('inside-elife')), $this->simpleDate($blogArticle, $context) ), - $this->carouselItemImageFactory->forImage($object->getBanner()) + (new PictureBuilderFactory())->forImage( + $object->getBanner(), $object->getBanner()->getWidth() + )->build(), + $blogArticle->getImpactStatement() ); } public function supports($object, string $viewModel = null, array $context = []) : bool { - return $object instanceof Cover && ViewModel\CarouselItem::class === $viewModel && $object->getItem() instanceof BlogArticle; + return $object instanceof Cover && ViewModel\HeroBanner::class === $viewModel && $object->getItem() instanceof BlogArticle; } } diff --git a/src/ViewModel/Converter/CoverCollectionCarouselItemConverter.php b/src/ViewModel/Converter/CoverCollectionHeroBannerConverter.php similarity index 71% rename from src/ViewModel/Converter/CoverCollectionCarouselItemConverter.php rename to src/ViewModel/Converter/CoverCollectionHeroBannerConverter.php index 2eb04a63f..9ba138c2f 100644 --- a/src/ViewModel/Converter/CoverCollectionCarouselItemConverter.php +++ b/src/ViewModel/Converter/CoverCollectionHeroBannerConverter.php @@ -6,20 +6,19 @@ use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Subject; use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; +use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; use eLife\Patterns\ViewModel; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -final class CoverCollectionCarouselItemConverter implements ViewModelConverter +final class CoverCollectionHeroBannerConverter implements ViewModelConverter { use CreatesDate; private $urlGenerator; - private $carouselItemImageFactory; - public function __construct(UrlGeneratorInterface $urlGenerator, CarouselItemImageFactory $carouselItemImageFactory) + public function __construct(UrlGeneratorInterface $urlGenerator) { $this->urlGenerator = $urlGenerator; - $this->carouselItemImageFactory = $carouselItemImageFactory; } /** @@ -30,19 +29,21 @@ public function convert($object, string $viewModel = null, array $context = []) /** @var Collection $collection */ $collection = $object->getItem(); - return new ViewModel\CarouselItem( + return new ViewModel\HeroBanner( $collection->getSubjects()->map(function (Subject $subject) { return new ViewModel\Link($subject->getName(), $this->urlGenerator->generate('subject', [$subject])); })->toArray(), new ViewModel\Link($object->getTitle(), $this->urlGenerator->generate('collection', [$collection])), - 'Read collection', ViewModel\Meta::withLink(new ViewModel\Link('Collection', $this->urlGenerator->generate('collections')), $this->simpleDate($collection, $context)), - $this->carouselItemImageFactory->forImage($object->getBanner()) + (new PictureBuilderFactory())->forImage( + $object->getBanner(), $object->getBanner()->getWidth() + )->build(), + $collection->getImpactStatement() ); } public function supports($object, string $viewModel = null, array $context = []) : bool { - return $object instanceof Cover && ViewModel\CarouselItem::class === $viewModel && $object->getItem() instanceof Collection; + return $object instanceof Cover && ViewModel\HeroBanner::class === $viewModel && $object->getItem() instanceof Collection; } } diff --git a/src/ViewModel/Converter/ReviewedPreprintConverter.php b/src/ViewModel/Converter/ReviewedPreprintConverter.php new file mode 100644 index 000000000..9e6ebda91 --- /dev/null +++ b/src/ViewModel/Converter/ReviewedPreprintConverter.php @@ -0,0 +1,77 @@ +viewModelConverter = $viewModelConverter; + $this->urlGenerator = $urlGenerator; + $this->authorizationChecker = $authorizationChecker; + $this->eraArticles = $eraArticles; + } + + /** + * @param ReviewedPreprint $object + */ + public function convert($object, string $viewModel = null, array $context = []) : ViewModel + { + $formats = ['HTML']; + + if ($object->getPdf() !== null) { + $formats[] = "PDF"; + } + + $image = null; + if ($object->getThumbnail() !== null) { + $image = $this->smallTeaserImage($object); + } + + return ViewModel\Teaser::main( + $object->getTitle(), + $this->urlGenerator->generate('article', [$object]), + $object instanceof ArticleVoR ? $object->getImpactStatement() : null, + $object->getAuthorLine(), + $this->createContextLabel($object), + $image, + ViewModel\TeaserFooter::forArticle( + ViewModel\Meta::withLink( + new ViewModel\Link( + ModelName::singular('reviewed-preprint'), + $this->urlGenerator->generate('article-type', ['type' => 'reviewed-preprint']) + ), + $this->simpleDate($object, $context) + ), + $formats + ) + ); + } + + public function supports($object, string $viewModel = null, array $context = []) : bool + { + return $object instanceof ReviewedPreprint; + } + + protected function getViewModelConverter() : ViewModelConverter + { + return $this->viewModelConverter; + } +} diff --git a/test/Controller/ArchiveMonthControllerTest.php b/test/Controller/ArchiveMonthControllerTest.php index 6ac042ef5..99f7eb5ca 100644 --- a/test/Controller/ArchiveMonthControllerTest.php +++ b/test/Controller/ArchiveMonthControllerTest.php @@ -90,11 +90,11 @@ protected function getUrl() : string new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=published&start-date=2015-12-01&end-date=2015-12-31', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -119,6 +119,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/ArticleTypeControllerTest.php b/test/Controller/ArticleTypeControllerTest.php index 3ba1d7e81..a9998f3b4 100644 --- a/test/Controller/ArticleTypeControllerTest.php +++ b/test/Controller/ArticleTypeControllerTest.php @@ -83,7 +83,7 @@ function () use ($page) { new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-article&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 404, @@ -103,13 +103,13 @@ protected function getUrl() : string 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-article&use-date=default', [ - 'Accept' => 'application/vnd.elife.search+json; version=1', + 'Accept' => 'application/vnd.elife.search+json; version=2', ] ), new Response( 200, [ - 'Content-Type' => 'application/vnd.elife.search+json; version=1', + 'Content-Type' => 'application/vnd.elife.search+json; version=2', ], json_encode([ 'total' => 0, @@ -141,6 +141,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/AuthenticationTest.php b/test/Controller/AuthenticationTest.php index 4734155d8..61661c6b7 100644 --- a/test/Controller/AuthenticationTest.php +++ b/test/Controller/AuthenticationTest.php @@ -311,12 +311,12 @@ private function readyHomePage() $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -347,6 +347,7 @@ private function readyHomePage() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/HomeControllerTest.php b/test/Controller/HomeControllerTest.php index d685b9883..b4eaddad8 100644 --- a/test/Controller/HomeControllerTest.php +++ b/test/Controller/HomeControllerTest.php @@ -126,12 +126,12 @@ public function it_displays_the_correct_dates_in_the_latest_research_list() $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 2, 'items' => [ @@ -203,6 +203,7 @@ public function it_displays_the_correct_dates_in_the_latest_research_list() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -280,14 +281,14 @@ public function it_displays_the_homepage_even_if_the_api_is_unavailable() $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, [ 'Cache-Control' => 'public, max-age=0, stale-if-error=60', - 'Content-Type' => 'application/vnd.elife.search+json; version=1', + 'Content-Type' => 'application/vnd.elife.search+json; version=2', ], json_encode([ 'total' => 0, @@ -319,6 +320,7 @@ public function it_displays_the_homepage_even_if_the_api_is_unavailable() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -334,7 +336,7 @@ public function it_displays_the_homepage_even_if_the_api_is_unavailable() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 503, @@ -382,8 +384,8 @@ function () use ($page) { $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 404, @@ -558,12 +560,12 @@ protected function getUrl() : string $this->mockApiResponse( new Request( 'GET', - 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=reviewed-preprint&type[]=research-advance&type[]=research-article&type[]=research-communication&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&use-date=default', + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -594,6 +596,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/MagazineControllerTest.php b/test/Controller/MagazineControllerTest.php index 9a9842ac0..258fdf017 100644 --- a/test/Controller/MagazineControllerTest.php +++ b/test/Controller/MagazineControllerTest.php @@ -108,7 +108,7 @@ function () use ($page) { new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 404, @@ -127,11 +127,11 @@ protected function getUrl() : string new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&type[]=interview&type[]=podcast-episode&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -156,6 +156,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/SearchControllerTest.php b/test/Controller/SearchControllerTest.php index afc6ee149..9c839df66 100644 --- a/test/Controller/SearchControllerTest.php +++ b/test/Controller/SearchControllerTest.php @@ -39,11 +39,11 @@ public function it_has_a_search_box_in_the_page() new Request( 'GET', 'http://api.elifesciences.org/search?for=keyword&page=1&per-page=1&sort=relevance&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -74,6 +74,7 @@ public function it_has_a_search_box_in_the_page() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -83,11 +84,11 @@ public function it_has_a_search_box_in_the_page() new Request( 'GET', 'http://api.elifesciences.org/search?for=keyword&page=1&per-page=10&sort=relevance&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -118,6 +119,7 @@ public function it_has_a_search_box_in_the_page() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -142,11 +144,11 @@ public function it_can_be_ordered_by_date() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -177,6 +179,7 @@ public function it_can_be_ordered_by_date() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -186,11 +189,11 @@ public function it_can_be_ordered_by_date() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -221,6 +224,7 @@ public function it_can_be_ordered_by_date() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -235,11 +239,11 @@ public function it_can_be_ordered_by_date() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=asc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -270,6 +274,7 @@ public function it_can_be_ordered_by_date() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -279,11 +284,11 @@ public function it_can_be_ordered_by_date() new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=asc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -314,6 +319,7 @@ public function it_can_be_ordered_by_date() 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -361,11 +367,11 @@ protected function getUrl() : string new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=relevance&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -396,6 +402,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) @@ -405,11 +412,11 @@ protected function getUrl() : string new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=relevance&order=desc&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 200, - ['Content-Type' => 'application/vnd.elife.search+json; version=1'], + ['Content-Type' => 'application/vnd.elife.search+json; version=2'], json_encode([ 'total' => 0, 'items' => [], @@ -440,6 +447,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Controller/SubjectControllerTest.php b/test/Controller/SubjectControllerTest.php index 81a34de21..ae501aeb2 100644 --- a/test/Controller/SubjectControllerTest.php +++ b/test/Controller/SubjectControllerTest.php @@ -130,7 +130,7 @@ function () use ($page) { new Request( 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=1&sort=date&order=desc&subject[]=subject&type[]=research-article&type[]=research-communication&type[]=research-advance&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&use-date=default', - ['Accept' => 'application/vnd.elife.search+json; version=1'] + ['Accept' => 'application/vnd.elife.search+json; version=2'] ), new Response( 404, @@ -293,13 +293,13 @@ protected function getUrl() : string 'GET', 'http://api.elifesciences.org/search?for=&page=1&per-page=10&sort=date&order=desc&subject[]=subject&type[]=research-article&type[]=research-communication&type[]=research-advance&type[]=review-article&type[]=scientific-correspondence&type[]=short-report&type[]=tools-resources&type[]=replication-study&type[]=editorial&type[]=insight&type[]=feature&type[]=collection&use-date=default', [ - 'Accept' => 'application/vnd.elife.search+json; version=1', + 'Accept' => 'application/vnd.elife.search+json; version=2', ] ), new Response( 200, [ - 'Content-Type' => 'application/vnd.elife.search+json; version=1', + 'Content-Type' => 'application/vnd.elife.search+json; version=2', ], json_encode([ 'total' => 0, @@ -331,6 +331,7 @@ protected function getUrl() : string 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ]) ) diff --git a/test/Guzzle/StatusDateOverrideMiddlewareTest.php b/test/Guzzle/StatusDateOverrideMiddlewareTest.php index 57e0f9e89..ab0c8c444 100644 --- a/test/Guzzle/StatusDateOverrideMiddlewareTest.php +++ b/test/Guzzle/StatusDateOverrideMiddlewareTest.php @@ -233,7 +233,7 @@ public function responseProvider() : Traversable ], ], ], - 'application/vnd.elife.search+json; version=1;' => [ + 'application/vnd.elife.search+json; version=2;' => [ [ 'total' => 2, 'items' => [ @@ -261,6 +261,7 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], [ @@ -290,6 +291,7 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], ], diff --git a/test/Guzzle/SubjectRewritingMiddlewareTest.php b/test/Guzzle/SubjectRewritingMiddlewareTest.php index d9ce621b2..edb6e45af 100644 --- a/test/Guzzle/SubjectRewritingMiddlewareTest.php +++ b/test/Guzzle/SubjectRewritingMiddlewareTest.php @@ -324,7 +324,7 @@ public function responseProvider() : Traversable ], ], ], - 'application/vnd.elife.search+json; version=1; with new subject' => [ + 'application/vnd.elife.search+json; version=2; with new subject' => [ [ 'total' => 2, 'items' => [ @@ -356,6 +356,7 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], [ @@ -388,10 +389,11 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], ], - 'application/vnd.elife.search+json; version=1; without new subject' => [ + 'application/vnd.elife.search+json; version=2; without new subject' => [ [ 'total' => 2, 'items' => [ @@ -422,6 +424,7 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], [ @@ -454,6 +457,7 @@ public function responseProvider() : Traversable 'interview' => 0, 'labs-post' => 0, 'podcast-episode' => 0, + 'reviewed-preprint' => 0, ], ], ], diff --git a/test/ViewModel/Converter/CoverArticleCarouselItemConverterTest.php b/test/ViewModel/Converter/CoverArticleHeroBannerConverterTest.php similarity index 57% rename from test/ViewModel/Converter/CoverArticleCarouselItemConverterTest.php rename to test/ViewModel/Converter/CoverArticleHeroBannerConverterTest.php index d412b7569..e46d762cf 100644 --- a/test/ViewModel/Converter/CoverArticleCarouselItemConverterTest.php +++ b/test/ViewModel/Converter/CoverArticleHeroBannerConverterTest.php @@ -5,18 +5,15 @@ use eLife\ApiSdk\Model\ArticleVersion; use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Model; -use eLife\Journal\ViewModel\Converter\CoverArticleCarouselItemConverter; -use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; -use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; -use eLife\Patterns\ViewModel\CarouselItem; -use Symfony\Component\Asset\Packages; +use eLife\Journal\ViewModel\Converter\CoverArticleHeroBannerConverter; +use eLife\Patterns\ViewModel\HeroBanner; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Traversable; -final class CoverArticleCarouselItemConverterTest extends ModelConverterTestCase +final class CoverArticleHeroBannerConverterTest extends ModelConverterTestCase { protected $models = ['cover']; - protected $viewModelClasses = [CarouselItem::class]; + protected $viewModelClasses = [HeroBanner::class]; /** * @before @@ -29,9 +26,8 @@ public function setUpConverter() ->method('generate') ->will($this->returnValue('/')); - $this->converter = new CoverArticleCarouselItemConverter( - $urlGenerator, - new CarouselItemImageFactory(new PictureBuilderFactory(), new Packages()) + $this->converter = new CoverArticleHeroBannerConverter( + $urlGenerator ); } diff --git a/test/ViewModel/Converter/CoverBlogArticleCarouselItemConverterTest.php b/test/ViewModel/Converter/CoverBlogArticleHeroBannerConverterTest.php similarity index 56% rename from test/ViewModel/Converter/CoverBlogArticleCarouselItemConverterTest.php rename to test/ViewModel/Converter/CoverBlogArticleHeroBannerConverterTest.php index 164625699..9151ed2da 100644 --- a/test/ViewModel/Converter/CoverBlogArticleCarouselItemConverterTest.php +++ b/test/ViewModel/Converter/CoverBlogArticleHeroBannerConverterTest.php @@ -5,18 +5,15 @@ use eLife\ApiSdk\Model\BlogArticle; use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Model; -use eLife\Journal\ViewModel\Converter\CoverBlogArticleCarouselItemConverter; -use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; -use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; -use eLife\Patterns\ViewModel\CarouselItem; -use Symfony\Component\Asset\Packages; +use eLife\Journal\ViewModel\Converter\CoverBlogArticleHeroBannerConverter; +use eLife\Patterns\ViewModel\HeroBanner; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Traversable; -final class CoverBlogArticleCarouselItemConverterTest extends ModelConverterTestCase +final class CoverBlogArticleHeroBannerConverterTest extends ModelConverterTestCase { protected $models = ['cover']; - protected $viewModelClasses = [CarouselItem::class]; + protected $viewModelClasses = [HeroBanner::class]; /** * @before @@ -29,9 +26,8 @@ public function setUpConverter() ->method('generate') ->will($this->returnValue('/')); - $this->converter = new CoverBlogArticleCarouselItemConverter( - $urlGenerator, - new CarouselItemImageFactory(new PictureBuilderFactory(), new Packages()) + $this->converter = new CoverBlogArticleHeroBannerConverter( + $urlGenerator ); } diff --git a/test/ViewModel/Converter/CoverCollectionCarouselItemConverterTest.php b/test/ViewModel/Converter/CoverCollectionHeroBannerConverterTest.php similarity index 56% rename from test/ViewModel/Converter/CoverCollectionCarouselItemConverterTest.php rename to test/ViewModel/Converter/CoverCollectionHeroBannerConverterTest.php index 6bc5e51ef..1af5f6053 100644 --- a/test/ViewModel/Converter/CoverCollectionCarouselItemConverterTest.php +++ b/test/ViewModel/Converter/CoverCollectionHeroBannerConverterTest.php @@ -5,18 +5,15 @@ use eLife\ApiSdk\Model\Collection; use eLife\ApiSdk\Model\Cover; use eLife\ApiSdk\Model\Model; -use eLife\Journal\ViewModel\Converter\CoverCollectionCarouselItemConverter; -use eLife\Journal\ViewModel\Factory\CarouselItemImageFactory; -use eLife\Journal\ViewModel\Factory\PictureBuilderFactory; -use eLife\Patterns\ViewModel\CarouselItem; -use Symfony\Component\Asset\Packages; +use eLife\Journal\ViewModel\Converter\CoverCollectionHeroBannerConverter; +use eLife\Patterns\ViewModel\HeroBanner; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Traversable; -final class CoverCollectionCarouselItemConverterTest extends ModelConverterTestCase +final class CoverCollectionHeroBannerConverterTest extends ModelConverterTestCase { protected $models = ['cover']; - protected $viewModelClasses = [CarouselItem::class]; + protected $viewModelClasses = [HeroBanner::class]; /** * @before @@ -29,9 +26,8 @@ public function setUpConverter() ->method('generate') ->will($this->returnValue('/')); - $this->converter = new CoverCollectionCarouselItemConverter( - $urlGenerator, - new CarouselItemImageFactory(new PictureBuilderFactory(), new Packages()) + $this->converter = new CoverCollectionHeroBannerConverter( + $urlGenerator ); } diff --git a/var/.gitkeep b/var/.gitkeep old mode 100644 new mode 100755