PHPackages                             n-educatio/testbundle - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. n-educatio/testbundle

ActiveLibrary[Testing &amp; Quality](/categories/testing)

n-educatio/testbundle
=====================

Framework for Specification by Example and e2e testing

2.3.1(12y ago)02807PHPPHP &gt;=5.3.3

Since Oct 11Pushed 11y ago12 watchersCompare

[ Source](https://github.com/n-educatio-pl/TestBundle)[ Packagist](https://packagist.org/packages/n-educatio/testbundle)[ Docs](https://github.com/n-educatio/TestBundle)[ RSS](/packages/n-educatio-testbundle/feed)WikiDiscussions 2.3 Synced 3d ago

READMEChangelogDependencies (13)Versions (10)Used By (0)

TestBundle
==========

[](#testbundle)

Paczka usprawnia mechanizm Symfonowskiego ładowania fixturesów. Paczka jest całkowicie autonomiczna, oraz jest pokryta testami jednostkowymi w 100%. Co więcej, TestBundle wprowadza nową zasadę odwoływania się do konkretnych elementów na stronie za pomocą tak zwanych uchwytów.

[![Build Status](https://camo.githubusercontent.com/a8d32d5cbf26b61ced01d23abe12038dbe1883036e1d2cd5eb183579832fa260/68747470733a2f2f6170692e7472617669732d63692e6f72672f6e2d656475636174696f2d706c2f5465737442756e646c652e706e673f6272616e63683d322e33)](https://travis-ci.org/n-educatio-pl/TestBundle)

Instalacja
----------

[](#instalacja)

Zmiany dla pliku composer.json

```
"repositories": [
    {
        "type": "package",
        "package": {
            "name": "n-educatio/testbundle",
            "version": "dev-master",
            "source": {
                "type": "git",
                "url": "git@github.com:n-educatio/TestBundle.git",
                "reference": "master"
            }
        }
    }
],
"require": {
    "n-educatio/testbundle": "dev-master"
},
"autoload": {
    "psr-0": {
        "Neducatio\\TestBundle": "vendor/n-educatio/testbundle/src"
    }
}
```

Następnie instalujemy brakujące vendorsy:

```
php composer.phar install

```

Uruchamianie testów paczki TestBundle
-------------------------------------

[](#uruchamianie-testów-paczki-testbundle)

ant test - testy phpunit oraz testy behat

Przykład użycia fixturesów
--------------------------

[](#przykład-użycia-fixturesów)

Przykład można zobaczyć [tutaj](https://github.com/n-educatio/TestBundle/tree/master/testapp)

Przykład użycia uchwytów
------------------------

[](#przykład-użycia-uchwytów)

**Przykład testu dla zmiany języka:**

Kontekst

```
class LanguageContext extends BaseSubContext
{
  /**
   * Change website language
   *
   * @param string $language New langauge
   *
   * @When /^I change language to ([^"]*)$/
   */
  public function changeLanguage($language)
  {
    $this->setPage(LanguagePanel::NAME);
    $this->getPage()->changeLanguage($language);
  }
}
```

W naszym przypadku PageObjectem może stać się każdy element na stronie, taki jak menu, panel językowy, itp. Na co należy zwrócić uwagę to pole $proofSelector, które informuje o zasięgu działania PageObjectu.

```
class LanguagePanel extends BasePageObject
{
  const NAME = __CLASS__;
  protected $proofSelector = '.t_languages';
  /**
   * Changes language
   *
   * @param string $language Language
   */
  public function changeLanguage($language)
  {
    //Nasze uchwyty w tym przypadku to
    //t_language_polish
    //t_language_english
    $this->get('language_' . $language)->click();
  }
}
```

Zauważ, że metoda get() pobiera teraz uchwyt id, który musi być zahardkodowany w htmlu jako t\_uchwyt.

Podział na Persony/itp
----------------------

[](#podział-na-personyitp)

Naszym celem jest wczytanie tylko konkrentych Fixturesów potrzebnych do odpalenia testów, stąd każdy Fixture deklarowany jest jako konkrenta Osoba/Kurs/Komentarz/itd, który posiada unikatowe właściwości i atrybuty. Powiedzmy, że w naszym systemie istnieje dwóch testowych użytkowników: Julia Lazy ( persona, która jest już zarejestrowana w serwisie ) oraz Amy Fresh ( persona nie powiązana jeszcze w żaden sposób z aplikacją, ale posiadająca swój własny adres email, nazwę itp. Tworzymy je w następujący sposób: Nasza Amy Fresh

```
class LoadAmyFreshUserData extends LoadActorUserData
{
  const NAME = __CLASS__;
  protected $order = 100;
  protected $userData = array(
    'AmyFresh' => array(
      "username" => "amy.fresh@example.com",
      "description" => "Teacher that visits the app for the first time and wants to give it a try",
      "roles" => "ROLE_USER",
      "firstname" => "Amy",
      "lastname" => "Fresh",
      "registered" => false,
    ),
  );
}
```

Oraz Julia Lazy

```
class LoadJuliaLazyUserData extends LoadActorUserData
{
  const NAME = __CLASS__;
  protected $order = 101;
  protected $userData = array(
    'JuliaLazy' => array(
      "username" => "julia.lazy@example.com",
      "description" => "User that is only registered in the system",
      "roles" => "ROLE_USER",
      "firstname" => "Julia",
      "lastname" => "Lazy",
      "registered" => true,
    ),
  );
}
```

Obie persony w tym przypadku muszą dziedziczyć po klasie [LoadActorUserData](https://github.com/n-educatio/cb/blob/master/src/Neducatio/UserBundle/DataFixtures/ORM/LoadActorUserData.php). Oczywistym staje się fakt, że każdy rodzaj person będzie miał analogicznie budowaną klasę, po której dziedziczą persony tego samego rodzaju.

Zależności
----------

[](#zależności)

\###Dodawanie Przejdżmy teraz do sedna możliwości naszego TestBundle. Załóżmy, że chcemy dodać do naszych Fixturesów pewne zależności. Robimy to w bardzo prosty sposób. W klasie Fixture A, która jest zależna od klasy Fixture B dodajemy taki oto krótki wpis:

```
protected $dependentClasses = array(
  B::NAME,
);
```

Teraz za każdym razem, gdy będziemy próbowali wczytać Fixture A, nasz TestBundle doczyta nam zależny Fixture B.

\###Wczytywanie Czas na ostatni krok, jakim jest wczytanie Fixturesów. By móc tego dokonać należy w metodzie kontekstu dodać poniższy kod:

```
public function mojaMetodaKontekstowa()
{
  $this->loadFixtures(array(
    KLASA_Z_MOIM_PORZADANYM_FIXTUREM::NAME
  ));
  // Dalej robie coś tam z Fixturesami
  // Dla przykładu:
  $this->getReference('mojaReferencja')->jakasMetoda();
}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~53 days

Recently: every ~77 days

Total

7

Last Release

4179d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc40939ddaf7259b88a55c2781b28f37ab8ef539d49f87a92f7a4f24960eb4a5?d=identicon)[n-educatio-pl](/maintainers/n-educatio-pl)

---

Top Contributors

[![sfraszczak-neducatio](https://avatars.githubusercontent.com/u/1758724?v=4)](https://github.com/sfraszczak-neducatio "sfraszczak-neducatio (50 commits)")[![mszymczak-neducatio](https://avatars.githubusercontent.com/u/1135017?v=4)](https://github.com/mszymczak-neducatio "mszymczak-neducatio (19 commits)")[![pgrzeszczak-neducatio](https://avatars.githubusercontent.com/u/1218325?v=4)](https://github.com/pgrzeszczak-neducatio "pgrzeszczak-neducatio (17 commits)")[![n-educatio-pl](https://avatars.githubusercontent.com/u/6573534?v=4)](https://github.com/n-educatio-pl "n-educatio-pl (14 commits)")[![mangulski-neducatio](https://avatars.githubusercontent.com/u/1196557?v=4)](https://github.com/mangulski-neducatio "mangulski-neducatio (8 commits)")[![mpryl-neducatio](https://avatars.githubusercontent.com/u/5690434?v=4)](https://github.com/mpryl-neducatio "mpryl-neducatio (7 commits)")[![mstrzelczyk-neducatio](https://avatars.githubusercontent.com/u/1196117?v=4)](https://github.com/mstrzelczyk-neducatio "mstrzelczyk-neducatio (6 commits)")[![pzmijewski-neducatio](https://avatars.githubusercontent.com/u/5172677?v=4)](https://github.com/pzmijewski-neducatio "pzmijewski-neducatio (6 commits)")[![mkarasiewicz-neducatio](https://avatars.githubusercontent.com/u/3490572?v=4)](https://github.com/mkarasiewicz-neducatio "mkarasiewicz-neducatio (2 commits)")[![educatio-neducatio](https://avatars.githubusercontent.com/u/1183016?v=4)](https://github.com/educatio-neducatio "educatio-neducatio (2 commits)")[![kbiernacki-neducatio](https://avatars.githubusercontent.com/u/6850116?v=4)](https://github.com/kbiernacki-neducatio "kbiernacki-neducatio (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/n-educatio-testbundle/health.svg)

```
[![Health](https://phpackages.com/badges/n-educatio-testbundle/health.svg)](https://phpackages.com/packages/n-educatio-testbundle)
```

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[hautelook/alice-bundle

Symfony bundle to manage fixtures with Alice and Faker.

19519.4M34](/packages/hautelook-alice-bundle)[polishsymfonycommunity/symfony2-mocker-extension

Behat extension for mocking services defined in the Symfony2 dependency injection container.

26253.1k4](/packages/polishsymfonycommunity-symfony2-mocker-extension)[adlarge/fixtures-documentation-bundle

Fixtures documentation generator

1018.7k](/packages/adlarge-fixtures-documentation-bundle)

PHPackages © 2026

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