PHPackages                             mortola/behat-seo-contexts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mortola/behat-seo-contexts

Abandoned → [marcortola/behat-seo-contexts](/?search=marcortola%2Fbehat-seo-contexts)Library

mortola/behat-seo-contexts
==========================

Behat extension for testing some On-Page SEO factors: meta title/description, canonical, hreflang, meta robots, robots.txt, redirects, sitemap validation, HTML validation, performance...

4.0.0(3y ago)135.3k4[1 issues](https://github.com/marcortola/behat-seo-contexts/issues)MITPHPPHP &gt;=7.1

Since Nov 3Pushed 3y ago2 watchersCompare

[ Source](https://github.com/marcortola/behat-seo-contexts)[ Packagist](https://packagist.org/packages/mortola/behat-seo-contexts)[ Docs](https://github.com/marcortola/behat-seo-contexts)[ RSS](/packages/mortola-behat-seo-contexts/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (16)Versions (13)Used By (0)

Behat SEO Contexts
==================

[](#behat-seo-contexts)

[![Latest Version](https://camo.githubusercontent.com/c54dff1607a09924594de788c5bfb94fc2be9dde639cc96f3a1a143036bdc0bb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f6d6172636f72746f6c612f62656861742d73656f2d636f6e74657874732e7376673f7374796c653d666c61742d737175617265)](https://github.com/marcortola/behat-seo-contexts/releases)[![Build Status](https://camo.githubusercontent.com/4cf01c6462c1c00783bb6e7b8ca80bc968ee490cc58592ba310d8c526071f879/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d6172636f72746f6c612f62656861742d73656f2d636f6e74657874732e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/marcortola/behat-seo-contexts)[![Quality Score](https://camo.githubusercontent.com/960974821a3aaeaa144b7f5b52342029488ac3049aeac93f294be10abebae3af/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d6172636f72746f6c612f62656861742d73656f2d636f6e74657874732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/marcortola/behat-seo-contexts)

**Behat extension for testing some On-Page SEO factors.**

Includes contexts for testing:

- title / meta description
- canonical
- hreflang
- meta robots
- robots.txt
- indexation: tests meta robots + robots.txt + X-Robots-Tag header
- redirects
- sitemap validation (inc. multilanguage)
- HTML validation
- assets performance
- accessibility
- UX
- more...

Installation
------------

[](#installation)

Basic requirements:

- PHP 7.1+
- Behat 3+
- Mink + Mink extension

### How to install it

[](#how-to-install-it)

1. [Install Composer](https://getcomposer.org/download/)
2. Execute:

```
$ composer require marcortola/behat-seo-contexts --dev

```

3. Add the Context you need to `behat.yml`:

```
# behat.yml
default:
    # ...
    suites:
        default:
          contexts:
            - MarcOrtola\BehatSEOContexts\Context\MetaContext
            - MarcOrtola\BehatSEOContexts\Context\LocalizationContext
            - MarcOrtola\BehatSEOContexts\Context\RobotsContext
            - MarcOrtola\BehatSEOContexts\Context\IndexationContext
            - MarcOrtola\BehatSEOContexts\Context\RedirectContext
            - MarcOrtola\BehatSEOContexts\Context\SitemapContext
            - MarcOrtola\BehatSEOContexts\Context\HTMLContext
            - MarcOrtola\BehatSEOContexts\Context\PerformanceContext
            - MarcOrtola\BehatSEOContexts\Context\SocialContext
            - MarcOrtola\BehatSEOContexts\Context\AccessibilityContext
            - MarcOrtola\BehatSEOContexts\Context\UXContext
```

### Featured steps

[](#featured-steps)

##### MetaContext

[](#metacontext)

```
Then the page canonical should not be empty
Then the page canonical should be :expectedCanonicalUrl
Then the page title should not be empty
Then the page title should be :expectedTitle
Then the page meta description should not be empty
Then the page meta description should be :expectedMetaDescription
Then the page meta robots should be noindex
Then the page meta robots should not be noindex
```

##### LocalizationContext

[](#localizationcontext)

```
Then the page hreflang markup should be valid
```

##### RobotsContext

[](#robotscontext)

```
Given I am a :crawlerUserAgent crawler
Then I should not be able to crawl :resource
Then I should be able to crawl :resource
Then I should be able to get the sitemap URL
```

##### IndexationContext

[](#indexationcontext)

```
Then the page should be indexable
Then the page should not be indexable
```

##### RedirectContext

[](#redirectcontext)

```
Given I follow redirects
Given I do not follow redirects
Then I should be redirected to :url
```

##### SitemapContext

[](#sitemapcontext)

```
Given the sitemap :sitemapUrl
Then the sitemap should be valid
Then the index sitemap should be valid
Then the multilanguage sitemap should be valid
Then the index sitemap should have a child with URL :childSitemapUrl
Then /^the sitemap should have ([0-9]+) children$/
Then the multilanguage sitemap should pass Google validation
Then the sitemap URLs should be alive
Then /^(\d+) random sitemap URLs? should be alive$/
```

##### HTMLContext

[](#htmlcontext)

```
Then the page HTML markup should be valid
Then /^the page HTML5 doctype declaration should (not |)be valid$
```

##### PerformanceContext

[](#performancecontext)

```
Then /^browser cache should be enabled for (.+\..+|external|internal) (png|jpeg|gif|ico|js|css) resources$/
Then /^Javascript code should load (async|defer)$/
Then HTML code should be minified
Then CSS code should be minified
Then Javascript code should be minified
Then CSS code should load deferred
Then critical CSS code should exist in head
```

##### SocialContext

[](#socialcontext)

```
Then /^the (Twitter|Facebook) Open Graph data should satisfy (minimum|full) requirements$/
```

##### AccessibilityContext

[](#accessibilitycontext)

```
Then the images should have alt text
```

##### UXContext

[](#uxcontext)

```
Then the site should be responsive
Then the site should not be responsive
```

### Examples

[](#examples)

This library is self-tested, and you can find examples inside the [features directory](./tests/features). Feel free to explore it to discover each step definition.

Useful tips
-----------

[](#useful-tips)

- Use [Symfony KernelDriver](https://github.com/Behat/Symfony2Extension) for improving the performance if you are working in a Symfony project.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 78.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Recently: every ~299 days

Total

12

Last Release

1263d ago

Major Versions

0.3 → 1.0.02019-03-16

1.1.0 → 2.0.02019-08-18

2.1.0 → 3.0.02020-01-10

3.1.1 → 4.0.02022-11-28

PHP version history (3 changes)0.1PHP &gt;=5.6

1.0.0PHP &gt;=7.0

2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/7cb342c647d69ea9b4d356eedfff75e22bf0b218a08b5f6dc7da163d4414d2b2?d=identicon)[marcortola](/maintainers/marcortola)

---

Top Contributors

[![marcortola](https://avatars.githubusercontent.com/u/15958009?v=4)](https://github.com/marcortola "marcortola (43 commits)")[![andreitic](https://avatars.githubusercontent.com/u/17015950?v=4)](https://github.com/andreitic "andreitic (9 commits)")[![bystro](https://avatars.githubusercontent.com/u/14996446?v=4)](https://github.com/bystro "bystro (3 commits)")

---

Tags

behat-contextcanonicalizationhreflang-checkerhtml-validationmeta-tagsrobots-txtseositemap-validationBDDContextBehatseoCanonicalizationredirectsHTML validationSitemap validationRobots validationHreflang checker

###  Code Quality

Static AnalysisPHPStan

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mortola-behat-seo-contexts/health.svg)

```
[![Health](https://phpackages.com/badges/mortola-behat-seo-contexts/health.svg)](https://phpackages.com/packages/mortola-behat-seo-contexts)
```

###  Alternatives

[marcortola/behat-seo-contexts

Behat extension for testing some On-Page SEO factors: meta title/description, canonical, hreflang, meta robots, robots.txt, redirects, sitemap validation, HTML validation, performance...

13153.8k](/packages/marcortola-behat-seo-contexts)[soyuka/contexts

Behatch contexts

282.1M11](/packages/soyuka-contexts)[novaway/common-contexts

Novaway Behat common contexts

18187.8k3](/packages/novaway-common-contexts)[dmarynicz/behat-parallel-extension

Parallel extension for Behat

27544.3k](/packages/dmarynicz-behat-parallel-extension)[macpaw/behat-messenger-context

Behat Context for testing Symfony Messenger component

16232.9k](/packages/macpaw-behat-messenger-context)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
