Skip to content

Commit 55a5eb3

Browse files
committed
Add phpunit and test
1 parent 51967fa commit 55a5eb3

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
composer.lock
22
vendor
3+
.phpunit.result.cache

composer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
"Statamic\\Eloquent\\": "src"
77
}
88
},
9+
"autoload-dev": {
10+
"psr-4": {
11+
"Tests\\": "tests"
12+
}
13+
},
914
"extra": {
1015
"statamic": {
1116
"name": "Eloquent Driver",
@@ -19,5 +24,8 @@
1924
},
2025
"require": {
2126
"statamic/cms": "^3.0"
27+
},
28+
"require-dev": {
29+
"phpunit/phpunit": "^9.4"
2230
}
2331
}

phpunit.xml.dist

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false">
11+
<testsuites>
12+
<testsuite name="Tests">
13+
<directory suffix="Test.php">./tests</directory>
14+
</testsuite>
15+
</testsuites>
16+
</phpunit>

tests/Entries/EntryModelTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
namespace Tests\Entries;
4+
5+
use PHPUnit\Framework\TestCase;
6+
use Statamic\Eloquent\Entries\EntryModel;
7+
8+
class EntryModelTest extends TestCase
9+
{
10+
/** @test */
11+
public function it_gets_attributes_from_json_column()
12+
{
13+
$model = new EntryModel([
14+
'slug' => 'the-slug',
15+
'data' => [
16+
'foo' => 'bar'
17+
]
18+
]);
19+
20+
$this->assertEquals('the-slug', $model->slug);
21+
$this->assertEquals('bar', $model->foo);
22+
$this->assertEquals(['foo' => 'bar'], $model->data);
23+
}
24+
}

0 commit comments

Comments
 (0)