aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-05-10 10:58:19 +0200
committerGitHub <noreply@github.com>2017-05-10 10:58:19 +0200
commit09edbff336a22061d8cac41b1c1e9faa7629d5c6 (patch)
tree3953c2614d1cb493e4feb362f698abb5ac9f5864 /tests
parente538c85ba7f028ff59ceb96f3b4779b1ef41bc14 (diff)
parent150d9ec1dcca0f71ba19a7f55e599eb716541dc3 (diff)
downloadwallabag-09edbff336a22061d8cac41b1c1e9faa7629d5c6.tar.gz
wallabag-09edbff336a22061d8cac41b1c1e9faa7629d5c6.tar.zst
wallabag-09edbff336a22061d8cac41b1c1e9faa7629d5c6.zip
Merge pull request #3101 from wallabag/credentials-new-extrafields
Skip auth when no credentials are found
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php40
1 files changed, 27 insertions, 13 deletions
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index 8341b11f..8b50bce9 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -2,6 +2,8 @@
2 2
3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; 3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
4 4
5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
5use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; 7use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
6use Graby\SiteConfig\SiteConfig as GrabySiteConfig; 8use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
7use PHPUnit_Framework_TestCase; 9use PHPUnit_Framework_TestCase;
@@ -32,14 +34,19 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
32 ->with('example.com') 34 ->with('example.com')
33 ->will($this->returnValue($grabySiteConfig)); 35 ->will($this->returnValue($grabySiteConfig));
34 36
37 $logger = new Logger('foo');
38 $handler = new TestHandler();
39 $logger->pushHandler($handler);
40
35 $this->builder = new GrabySiteConfigBuilder( 41 $this->builder = new GrabySiteConfigBuilder(
36 $grabyConfigBuilderMock, 42 $grabyConfigBuilderMock,
37 ['example.com' => ['username' => 'foo', 'password' => 'bar']] 43 ['example.com' => ['username' => 'foo', 'password' => 'bar']],
44 $logger
38 ); 45 );
39 46
40 $config = $this->builder->buildForHost('example.com'); 47 $config = $this->builder->buildForHost('example.com');
41 48
42 self::assertEquals( 49 $this->assertEquals(
43 new SiteConfig([ 50 new SiteConfig([
44 'host' => 'example.com', 51 'host' => 'example.com',
45 'requiresLogin' => true, 52 'requiresLogin' => true,
@@ -53,6 +60,10 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
53 ]), 60 ]),
54 $config 61 $config
55 ); 62 );
63
64 $records = $handler->getRecords();
65
66 $this->assertCount(1, $records, 'One log was recorded');
56 } 67 }
57 68
58 public function testBuildConfigDoesntExist() 69 public function testBuildConfigDoesntExist()
@@ -67,19 +78,22 @@ class GrabySiteConfigBuilderTest extends PHPUnit_Framework_TestCase
67 ->with('unknown.com') 78 ->with('unknown.com')
68 ->will($this->returnValue(new GrabySiteConfig())); 79 ->will($this->returnValue(new GrabySiteConfig()));
69 80
70 $this->builder = new GrabySiteConfigBuilder($grabyConfigBuilderMock, []); 81 $logger = new Logger('foo');
82 $handler = new TestHandler();
83 $logger->pushHandler($handler);
84
85 $this->builder = new GrabySiteConfigBuilder(
86 $grabyConfigBuilderMock,
87 [],
88 $logger
89 );
71 90
72 $config = $this->builder->buildForHost('unknown.com'); 91 $config = $this->builder->buildForHost('unknown.com');
73 92
74 self::assertEquals( 93 $this->assertFalse($config);
75 new SiteConfig([ 94
76 'host' => 'unknown.com', 95 $records = $handler->getRecords();
77 'requiresLogin' => false, 96
78 'username' => null, 97 $this->assertCount(1, $records, 'One log was recorded');
79 'password' => null,
80 'extraFields' => [],
81 ]),
82 $config
83 );
84 } 98 }
85} 99}