Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Feb 10, 2024
1 parent 7dc6914 commit 806e807
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ on:
jobs:
lint:
runs-on: ubuntu-latest
name: "Lint on PHP ${{ matrix.php-versions }}"

strategy:
matrix:
php-versions: [ '8.1', '8.3' ]
coverage: [none]
fail-fast: false

name: PHP ${{ matrix.php-versions }} on ubuntu-latest

steps:
- name: PHP
uses: shivammathur/setup-php@v2
Expand Down
44 changes: 39 additions & 5 deletions tests/GaletteAuto/tests/units/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,47 @@ class Color extends GaletteTestCase
*/
public function testEmpty(): void
{
/** @var \Galette\Core\Plugins */
global $plugins;

$color = new \GaletteAuto\Color($this->zdb);
$this->assertSame('Color', $color->getFieldLabel());

$this->assertSame([], $color->getList());
$this->assertSame('', $color->displayCount());
$this->assertCount(0, $color->getList());
$this->assertSame('0 color', $color->displayCount());
}

/**
* Test add and update
*
* @return void
*/
public function testAddUpdate(): void
{
$color = new \GaletteAuto\Color($this->zdb);
//ensure the table is empty
$this->assertCount(0, $color->getList());

//Add new color
$color->value = 'Red';
$this->assertTrue($color->store(true));

$this->assertCount(1, $color->getList());
$this->assertSame(1, $color->getList());
$this->assertSame('1 color', $color->displayCount());

//add another one
$color = new \GaletteAuto\Color($this->zdb);
$color->value = 'Blu';
$this->assertTrue($color->store(true));
$id = $color->id;

$this->assertCount(2, $color->getList());
$this->assertSame('2 colors', $color->displayCount());

$color = new \GaletteAuto\Color($this->zdb);
$this->assertTrue($color->load(1));
$color->value = 'Blue';
$this->assertTrue($color->store());

$this->assertCoun(2, $color->getList());
$this->assertSame('2 colors', $color->displayCount());
}
}

0 comments on commit 806e807

Please sign in to comment.